From f5ae3c77c614d0e294e4c346ba859b0fc566452d Mon Sep 17 00:00:00 2001 From: stsypanov Date: Thu, 7 Nov 2019 17:52:01 +0200 Subject: [PATCH 0001/2315] Use Method::getParameterCount where possible --- .../aop/framework/AopProxyUtils.java | 4 +-- .../beans/ExtendedBeanInfo.java | 5 ++- .../beans/PropertyDescriptorUtils.java | 4 +-- .../AutowiredAnnotationBeanPostProcessor.java | 11 ++++--- .../factory/support/ConstructorResolver.java | 32 +++++++++++++------ .../support/DisposableBeanAdapter.java | 6 ++-- .../InterfaceBasedMBeanInfoAssembler.java | 1 + .../core/BridgeMethodResolver.java | 5 +-- .../springframework/util/MethodInvoker.java | 4 +-- .../springframework/util/ReflectionUtils.java | 16 ++++++++-- .../ReflectiveConstructorExecutor.java | 3 +- .../ReflectiveConstructorResolver.java | 10 +++--- .../support/ReflectiveMethodExecutor.java | 3 +- .../support/ReflectiveMethodResolver.java | 10 +++--- 14 files changed, 68 insertions(+), 46 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java b/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java index a501d4614f27..e417f6ebed6b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java @@ -224,8 +224,8 @@ static Object[] adaptArgumentsIfNecessary(Method method, @Nullable Object[] argu return new Object[0]; } if (method.isVarArgs()) { - Class[] paramTypes = method.getParameterTypes(); - if (paramTypes.length == arguments.length) { + if (method.getParameterCount() == arguments.length) { + Class[] paramTypes = method.getParameterTypes(); int varargIndex = paramTypes.length - 1; Class varargType = paramTypes[varargIndex]; if (varargType.isArray()) { diff --git a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java index e8952301f28f..13320a607df9 100644 --- a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java +++ b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java @@ -145,11 +145,10 @@ private List findCandidateWriteMethods(MethodDescriptor[] methodDescript public static boolean isCandidateWriteMethod(Method method) { String methodName = method.getName(); - Class[] parameterTypes = method.getParameterTypes(); - int nParams = parameterTypes.length; + int nParams = method.getParameterCount(); return (methodName.length() > 3 && methodName.startsWith("set") && Modifier.isPublic(method.getModifiers()) && (!void.class.isAssignableFrom(method.getReturnType()) || Modifier.isStatic(method.getModifiers())) && - (nParams == 1 || (nParams == 2 && int.class == parameterTypes[0]))); + (nParams == 1 || (nParams == 2 && int.class == method.getParameterTypes()[0]))); } private void handleCandidateWriteMethod(Method method) throws IntrospectionException { diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java index c5ac50cb4b42..9cf7acceee30 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java @@ -66,8 +66,8 @@ public static Class findPropertyType(@Nullable Method readMethod, @Nullable M Class propertyType = null; if (readMethod != null) { - Class[] params = readMethod.getParameterTypes(); - if (params.length != 0) { + int parameterCount = readMethod.getParameterCount(); + if (parameterCount != 0) { throw new IntrospectionException("Bad read method arg count: " + readMethod); } propertyType = readMethod.getReturnType(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index 4b2d208a32e2..75063ba2e6b8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -696,10 +696,10 @@ protected void inject(Object bean, @Nullable String beanName, @Nullable Property arguments = resolveCachedArguments(beanName); } else { - Class[] paramTypes = method.getParameterTypes(); - arguments = new Object[paramTypes.length]; - DependencyDescriptor[] descriptors = new DependencyDescriptor[paramTypes.length]; - Set autowiredBeans = new LinkedHashSet<>(paramTypes.length); + int argumentCount = method.getParameterCount(); + arguments = new Object[argumentCount]; + DependencyDescriptor[] descriptors = new DependencyDescriptor[argumentCount]; + Set autowiredBeans = new LinkedHashSet<>(argumentCount); Assert.state(beanFactory != null, "No BeanFactory available"); TypeConverter typeConverter = beanFactory.getTypeConverter(); for (int i = 0; i < arguments.length; i++) { @@ -724,8 +724,9 @@ protected void inject(Object bean, @Nullable String beanName, @Nullable Property if (arguments != null) { DependencyDescriptor[] cachedMethodArguments = Arrays.copyOf(descriptors, arguments.length); registerDependentBeans(beanName, autowiredBeans); - if (autowiredBeans.size() == paramTypes.length) { + if (autowiredBeans.size() == argumentCount) { Iterator it = autowiredBeans.iterator(); + Class[] paramTypes = method.getParameterTypes(); for (int i = 0; i < paramTypes.length; i++) { String autowiredBeanName = it.next(); if (beanFactory.containsBean(autowiredBeanName) && diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java index 8dcfff8d3ee8..e43306b50b78 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java @@ -202,21 +202,23 @@ public BeanWrapper autowireConstructor(String beanName, RootBeanDefinition mbd, LinkedList causes = null; for (Constructor candidate : candidates) { - Class[] paramTypes = candidate.getParameterTypes(); - if (constructorToUse != null && argsToUse != null && argsToUse.length > paramTypes.length) { + int parameterCount = candidate.getParameterCount(); + + if (constructorToUse != null && argsToUse != null && argsToUse.length > parameterCount) { // Already found greedy constructor that can be satisfied -> // do not look any further, there are only less greedy constructors left. break; } - if (paramTypes.length < minNrOfArgs) { + if (parameterCount < minNrOfArgs) { continue; } ArgumentsHolder argsHolder; + Class[] paramTypes = candidate.getParameterTypes(); if (resolvedValues != null) { try { - String[] paramNames = ConstructorPropertiesChecker.evaluate(candidate, paramTypes.length); + String[] paramNames = ConstructorPropertiesChecker.evaluate(candidate, parameterCount); if (paramNames == null) { ParameterNameDiscoverer pnd = this.beanFactory.getParameterNameDiscoverer(); if (pnd != null) { @@ -240,7 +242,7 @@ public BeanWrapper autowireConstructor(String beanName, RootBeanDefinition mbd, } else { // Explicit arguments given -> arguments length must match exactly. - if (paramTypes.length != explicitArgs.length) { + if (parameterCount != explicitArgs.length) { continue; } argsHolder = new ArgumentsHolder(explicitArgs); @@ -340,15 +342,24 @@ public void resolveFactoryMethodIfPossible(RootBeanDefinition mbd) { if (uniqueCandidate == null) { uniqueCandidate = candidate; } - else if (!Arrays.equals(uniqueCandidate.getParameterTypes(), candidate.getParameterTypes())) { - uniqueCandidate = null; - break; + else { + boolean paramsNotMatch = isParamsNotMatch(uniqueCandidate, candidate); + if (paramsNotMatch) { + uniqueCandidate = null; + break; + } } } } mbd.factoryMethodToIntrospect = uniqueCandidate; } + private boolean isParamsNotMatch(Method uniqueCandidate, Method candidate) { + int uniqueCandidateParameterCount = uniqueCandidate.getParameterCount(); + int candidateParameterCount = candidate.getParameterCount(); + return uniqueCandidateParameterCount != candidateParameterCount || !Arrays.equals(uniqueCandidate.getParameterTypes(), candidate.getParameterTypes()); + } + /** * Retrieve all candidate methods for the given class, considering * the {@link RootBeanDefinition#isNonPublicAccessAllowed()} flag. @@ -505,11 +516,12 @@ public BeanWrapper instantiateUsingFactoryMethod( LinkedList causes = null; for (Method candidate : candidates) { - Class[] paramTypes = candidate.getParameterTypes(); - if (paramTypes.length >= minNrOfArgs) { + int parameterCount = candidate.getParameterCount(); + if (parameterCount >= minNrOfArgs) { ArgumentsHolder argsHolder; + Class[] paramTypes = candidate.getParameterTypes(); if (explicitArgs != null) { // Explicit arguments given -> arguments length must match exactly. if (paramTypes.length != explicitArgs.length) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java index 36768418cdd8..c506958cf28f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java @@ -311,9 +311,9 @@ private Method findDestroyMethod(String name) { * assuming a "force" parameter), else logging an error. */ private void invokeCustomDestroyMethod(final Method destroyMethod) { - Class[] paramTypes = destroyMethod.getParameterTypes(); - final Object[] args = new Object[paramTypes.length]; - if (paramTypes.length == 1) { + int paramCount = destroyMethod.getParameterCount(); + final Object[] args = new Object[paramCount]; + if (paramCount == 1) { args[0] = Boolean.TRUE; } if (logger.isTraceEnabled()) { diff --git a/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java b/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java index b7d3186ee81e..8248215725aa 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java @@ -231,6 +231,7 @@ private boolean isDeclaredInInterface(Method method, String beanKey) { for (Class ifc : ifaces) { for (Method ifcMethod : ifc.getMethods()) { if (ifcMethod.getName().equals(method.getName()) && + ifcMethod.getParameterCount() == method.getParameterCount() && Arrays.equals(ifcMethod.getParameterTypes(), method.getParameterTypes())) { return true; } diff --git a/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java b/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java index 4061c6d98ae4..1615469dd154 100644 --- a/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java +++ b/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java @@ -149,10 +149,10 @@ static boolean isBridgeMethodFor(Method bridgeMethod, Method candidateMethod, Cl */ private static boolean isResolvedTypeMatch(Method genericMethod, Method candidateMethod, Class declaringClass) { Type[] genericParameters = genericMethod.getGenericParameterTypes(); - Class[] candidateParameters = candidateMethod.getParameterTypes(); - if (genericParameters.length != candidateParameters.length) { + if (genericParameters.length != candidateMethod.getParameterCount()) { return false; } + Class[] candidateParameters = candidateMethod.getParameterTypes(); for (int i = 0; i < candidateParameters.length; i++) { ResolvableType genericParameter = ResolvableType.forMethodParameter(genericMethod, i, declaringClass); Class candidateParameter = candidateParameters[i]; @@ -235,6 +235,7 @@ public static boolean isVisibilityBridgeMethodPair(Method bridgeMethod, Method b return true; } return (bridgeMethod.getReturnType().equals(bridgedMethod.getReturnType()) && + bridgeMethod.getParameterCount() == bridgedMethod.getParameterCount() && Arrays.equals(bridgeMethod.getParameterTypes(), bridgedMethod.getParameterTypes())); } diff --git a/spring-core/src/main/java/org/springframework/util/MethodInvoker.java b/spring-core/src/main/java/org/springframework/util/MethodInvoker.java index e7b78ec5661f..8672b0197a60 100644 --- a/spring-core/src/main/java/org/springframework/util/MethodInvoker.java +++ b/spring-core/src/main/java/org/springframework/util/MethodInvoker.java @@ -225,8 +225,8 @@ protected Method findMatchingMethod() { for (Method candidate : candidates) { if (candidate.getName().equals(targetMethod)) { - Class[] paramTypes = candidate.getParameterTypes(); - if (paramTypes.length == argCount) { + if (candidate.getParameterCount() == argCount) { + Class[] paramTypes = candidate.getParameterTypes(); int typeDiffWeight = getTypeDifferenceWeight(paramTypes, arguments); if (typeDiffWeight < minTypeDiffWeight) { minTypeDiffWeight = typeDiffWeight; diff --git a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java index eaefe0d8a44d..8f7b320d2d4b 100644 --- a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java @@ -240,7 +240,7 @@ public static Method findMethod(Class clazz, String name, @Nullable Class. getDeclaredMethods(searchType, false); for (Method method : methods) { if (name.equals(method.getName()) && - (paramTypes == null || Arrays.equals(paramTypes, method.getParameterTypes()))) { + (paramTypes == null || hasSameParams(method, paramTypes))) { return method; } } @@ -249,6 +249,13 @@ public static Method findMethod(Class clazz, String name, @Nullable Class. return null; } + private static boolean hasSameParams(Method method, @Nullable Class[] paramTypes) { + if (paramTypes.length != method.getParameterCount()) { + return false; + } + return Arrays.equals(paramTypes, method.getParameterTypes()); + } + /** * Invoke the specified {@link Method} against the supplied target object with no arguments. * The target object can be {@code null} when invoking a static {@link Method}. @@ -413,6 +420,7 @@ public static Method[] getUniqueDeclaredMethods(Class leafClass, @Nullable Me Method methodBeingOverriddenWithCovariantReturnType = null; for (Method existingMethod : methods) { if (method.getName().equals(existingMethod.getName()) && + method.getParameterCount() == existingMethod.getParameterCount() && Arrays.equals(method.getParameterTypes(), existingMethod.getParameterTypes())) { // Is this a covariant return type situation? if (existingMethod.getReturnType() != method.getReturnType() && @@ -504,8 +512,10 @@ public static boolean isEqualsMethod(@Nullable Method method) { if (method == null || !method.getName().equals("equals")) { return false; } - Class[] paramTypes = method.getParameterTypes(); - return (paramTypes.length == 1 && paramTypes[0] == Object.class); + if (method.getParameterCount() != 1) { + return false; + } + return method.getParameterTypes()[0] == Object.class; } /** diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorExecutor.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorExecutor.java index 971297b561f6..e77eaa3ac586 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorExecutor.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorExecutor.java @@ -44,8 +44,7 @@ public class ReflectiveConstructorExecutor implements ConstructorExecutor { public ReflectiveConstructorExecutor(Constructor ctor) { this.ctor = ctor; if (ctor.isVarArgs()) { - Class[] paramTypes = ctor.getParameterTypes(); - this.varargsPosition = paramTypes.length - 1; + this.varargsPosition = ctor.getParameterCount() - 1; } else { this.varargsPosition = null; diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java index 82a307f6b9c2..c2de81e37897 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java @@ -69,13 +69,13 @@ public ConstructorExecutor resolve(EvaluationContext context, String typeName, L Constructor matchRequiringConversion = null; for (Constructor ctor : ctors) { - Class[] paramTypes = ctor.getParameterTypes(); - List paramDescriptors = new ArrayList<>(paramTypes.length); - for (int i = 0; i < paramTypes.length; i++) { + int paramCount = ctor.getParameterCount(); + List paramDescriptors = new ArrayList<>(paramCount); + for (int i = 0; i < paramCount; i++) { paramDescriptors.add(new TypeDescriptor(new MethodParameter(ctor, i))); } ReflectionHelper.ArgumentsMatchInfo matchInfo = null; - if (ctor.isVarArgs() && argumentTypes.size() >= paramTypes.length - 1) { + if (ctor.isVarArgs() && argumentTypes.size() >= paramCount - 1) { // *sigh* complicated // Basically.. we have to have all parameters match up until the varargs one, then the rest of what is // being provided should be @@ -84,7 +84,7 @@ public ConstructorExecutor resolve(EvaluationContext context, String typeName, L // we are supplied does match exactly (it is an array already). matchInfo = ReflectionHelper.compareArgumentsVarargs(paramDescriptors, argumentTypes, typeConverter); } - else if (paramTypes.length == argumentTypes.size()) { + else if (paramCount == argumentTypes.size()) { // worth a closer look matchInfo = ReflectionHelper.compareArguments(paramDescriptors, argumentTypes, typeConverter); } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodExecutor.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodExecutor.java index 046e63dd4ce2..2de25448b470 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodExecutor.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodExecutor.java @@ -61,8 +61,7 @@ public ReflectiveMethodExecutor(Method method) { this.originalMethod = method; this.methodToInvoke = ClassUtils.getInterfaceMethodIfPossible(method); if (method.isVarArgs()) { - Class[] paramTypes = method.getParameterTypes(); - this.varargsPosition = paramTypes.length - 1; + this.varargsPosition = method.getParameterCount() - 1; } else { this.varargsPosition = null; diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java index 745cd527e562..451aee275d99 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java @@ -160,17 +160,17 @@ else if (m1.isVarArgs() && !m2.isVarArgs()) { for (Method method : methodsToIterate) { if (method.getName().equals(name)) { - Class[] paramTypes = method.getParameterTypes(); - List paramDescriptors = new ArrayList<>(paramTypes.length); - for (int i = 0; i < paramTypes.length; i++) { + int paramCount = method.getParameterCount(); + List paramDescriptors = new ArrayList<>(paramCount); + for (int i = 0; i < paramCount; i++) { paramDescriptors.add(new TypeDescriptor(new MethodParameter(method, i))); } ReflectionHelper.ArgumentsMatchInfo matchInfo = null; - if (method.isVarArgs() && argumentTypes.size() >= (paramTypes.length - 1)) { + if (method.isVarArgs() && argumentTypes.size() >= (paramCount - 1)) { // *sigh* complicated matchInfo = ReflectionHelper.compareArgumentsVarargs(paramDescriptors, argumentTypes, typeConverter); } - else if (paramTypes.length == argumentTypes.size()) { + else if (paramCount == argumentTypes.size()) { // Name and parameter number match, check the arguments matchInfo = ReflectionHelper.compareArguments(paramDescriptors, argumentTypes, typeConverter); } From 6a48bb7b4defa47f7bd07bf95358c4a1d20e9ce3 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 7 Nov 2019 22:08:29 +0100 Subject: [PATCH 0002/2315] Polishing --- .../beans/PropertyDescriptorUtils.java | 5 ++--- .../factory/support/ConstructorResolver.java | 14 ++++++-------- .../springframework/util/ReflectionUtils.java | 16 ++++++---------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java index 9cf7acceee30..aa9909822d18 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -66,8 +66,7 @@ public static Class findPropertyType(@Nullable Method readMethod, @Nullable M Class propertyType = null; if (readMethod != null) { - int parameterCount = readMethod.getParameterCount(); - if (parameterCount != 0) { + if (readMethod.getParameterCount() != 0) { throw new IntrospectionException("Bad read method arg count: " + readMethod); } propertyType = readMethod.getReturnType(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java index e43306b50b78..cf43c433a26c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java @@ -342,22 +342,20 @@ public void resolveFactoryMethodIfPossible(RootBeanDefinition mbd) { if (uniqueCandidate == null) { uniqueCandidate = candidate; } - else { - boolean paramsNotMatch = isParamsNotMatch(uniqueCandidate, candidate); - if (paramsNotMatch) { - uniqueCandidate = null; - break; - } + else if (isParamMismatch(uniqueCandidate, candidate)) { + uniqueCandidate = null; + break; } } } mbd.factoryMethodToIntrospect = uniqueCandidate; } - private boolean isParamsNotMatch(Method uniqueCandidate, Method candidate) { + private boolean isParamMismatch(Method uniqueCandidate, Method candidate) { int uniqueCandidateParameterCount = uniqueCandidate.getParameterCount(); int candidateParameterCount = candidate.getParameterCount(); - return uniqueCandidateParameterCount != candidateParameterCount || !Arrays.equals(uniqueCandidate.getParameterTypes(), candidate.getParameterTypes()); + return (uniqueCandidateParameterCount != candidateParameterCount || + !Arrays.equals(uniqueCandidate.getParameterTypes(), candidate.getParameterTypes())); } /** diff --git a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java index 8f7b320d2d4b..9b9decee7353 100644 --- a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java @@ -235,12 +235,10 @@ public static Method findMethod(Class clazz, String name, @Nullable Class. Assert.notNull(name, "Method name must not be null"); Class searchType = clazz; while (searchType != null) { - Method[] methods = searchType.isInterface() ? - searchType.getMethods() : - getDeclaredMethods(searchType, false); + Method[] methods = (searchType.isInterface() ? searchType.getMethods() : + getDeclaredMethods(searchType, false)); for (Method method : methods) { - if (name.equals(method.getName()) && - (paramTypes == null || hasSameParams(method, paramTypes))) { + if (name.equals(method.getName()) && (paramTypes == null || hasSameParams(method, paramTypes))) { return method; } } @@ -249,11 +247,9 @@ public static Method findMethod(Class clazz, String name, @Nullable Class. return null; } - private static boolean hasSameParams(Method method, @Nullable Class[] paramTypes) { - if (paramTypes.length != method.getParameterCount()) { - return false; - } - return Arrays.equals(paramTypes, method.getParameterTypes()); + private static boolean hasSameParams(Method method, Class[] paramTypes) { + return (paramTypes.length == method.getParameterCount() && + Arrays.equals(paramTypes, method.getParameterTypes())); } /** From d394c7a5c0e675ac920f3c6d040bd5fa4d93a47f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 7 Nov 2019 22:08:52 +0100 Subject: [PATCH 0003/2315] Upgrade to RxJava 2.2.14, OkHttp 3.14.4, JRuby 9.2.9, Rhino 1.7.11, Awaitility 3.1.6 --- build.gradle | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 3b28c31172c1..40db4edbaa50 100644 --- a/build.gradle +++ b/build.gradle @@ -78,7 +78,7 @@ configure(allprojects) { project -> dependency "io.reactivex:rxjava:1.3.8" dependency "io.reactivex:rxjava-reactive-streams:1.2.1" - dependency "io.reactivex.rxjava2:rxjava:2.2.13" + dependency "io.reactivex.rxjava2:rxjava:2.2.14" dependency "com.caucho:hessian:4.0.62" dependency "com.fasterxml:aalto-xml:1.2.2" @@ -159,7 +159,7 @@ configure(allprojects) { project -> } } - dependencySet(group: 'com.squareup.okhttp3', version: '3.14.3') { + dependencySet(group: 'com.squareup.okhttp3', version: '3.14.4') { entry 'okhttp' entry 'mockwebserver' } @@ -171,9 +171,9 @@ configure(allprojects) { project -> } dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.0.3" - dependency "org.jruby:jruby:9.2.7.0" + dependency "org.jruby:jruby:9.2.9.0" dependency "org.python:jython-standalone:2.7.1" - dependency "org.mozilla:rhino:1.7.10" + dependency "org.mozilla:rhino:1.7.11" dependency "commons-fileupload:commons-fileupload:1.4" dependency "org.synchronoss.cloud:nio-multipart-parser:1.1.0" @@ -195,7 +195,7 @@ configure(allprojects) { project -> } dependency "org.testng:testng:6.14.3" dependency "org.hamcrest:hamcrest:2.1" - dependency "org.awaitility:awaitility:3.1.3" + dependency "org.awaitility:awaitility:3.1.6" dependency "org.assertj:assertj-core:3.14.0" dependencySet(group: 'org.xmlunit', version: '2.6.2') { entry 'xmlunit-assertj' From afae8c304539f0e29f3d068194edb44071ef4172 Mon Sep 17 00:00:00 2001 From: Lorenzo Torracchi Date: Thu, 24 Oct 2019 00:45:33 +0200 Subject: [PATCH 0004/2315] Avoid default "Accept" from HttpUrlConnection Closes gh-23740 --- .../web/client/RestTemplate.java | 3 + .../web/client/RestTemplateTests.java | 62 +++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java index 9ccd5e4dd731..4e21a9f9e061 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java @@ -739,6 +739,9 @@ protected T doExecute(URI url, @Nullable HttpMethod method, @Nullable Reques if (requestCallback != null) { requestCallback.doWithRequest(request); } + if ((method == HttpMethod.DELETE || method == HttpMethod.PUT) && request.getHeaders().getAccept().isEmpty()) { + request.getHeaders().add("Accept", "*/*"); + } response = request.execute(); handleResponse(url, method, response); return (responseExtractor != null ? responseExtractor.extractData(response) : null); diff --git a/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java b/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java index fbe20803a067..f899e6802ae4 100644 --- a/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java @@ -25,8 +25,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; +import java.util.stream.Collectors; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -43,6 +48,7 @@ import org.springframework.http.client.ClientHttpRequestInitializer; import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.ClientHttpResponse; +import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.http.converter.GenericHttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.util.StreamUtils; @@ -486,6 +492,47 @@ public void putNull() throws Exception { verify(response).close(); } + @Test + public void headerAcceptAllOnPut() throws Exception { + MockWebServer server = new MockWebServer(); + server.enqueue(new MockResponse().setResponseCode(500).setBody("internal server error")); + server.start(); + template.setRequestFactory(new SimpleClientHttpRequestFactory()); + + template.put(server.url("/internal/server/error").uri(), null); + + RecordedRequest request = server.takeRequest(); + assertThat(request.getHeader("Accept")).isEqualTo("*/*"); + + server.shutdown(); + } + + @Test + public void keepGivenAcceptHeaderOnPut() throws Exception { + MockWebServer server = new MockWebServer(); + server.enqueue(new MockResponse().setResponseCode(500).setBody("internal server error")); + server.start(); + + template.setRequestFactory(new SimpleClientHttpRequestFactory()); + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + HttpEntity entity = new HttpEntity<>(null, headers); + template.exchange(server.url("/internal/server/error").uri(), PUT, entity, Void.class); + + RecordedRequest request = server.takeRequest(); + + final List> accepts = request.getHeaders().toMultimap().entrySet().stream() + .filter(entry -> entry.getKey().equalsIgnoreCase("accept")) + .map(Entry::getValue) + .collect(Collectors.toList()); + + assertThat(accepts).hasSize(1); + assertThat(accepts.get(0)).hasSize(1); + assertThat(accepts.get(0).get(0)).isEqualTo("application/json"); + + server.shutdown(); + } + @Test public void patchForObject() throws Exception { mockTextPlainHttpMessageConverter(); @@ -532,6 +579,21 @@ public void delete() throws Exception { verify(response).close(); } + @Test + public void headerAcceptAllOnDelete() throws Exception { + MockWebServer server = new MockWebServer(); + server.enqueue(new MockResponse().setResponseCode(500).setBody("internal server error")); + server.start(); + template.setRequestFactory(new SimpleClientHttpRequestFactory()); + + template.delete(server.url("/internal/server/error").uri()); + + RecordedRequest request = server.takeRequest(); + assertThat(request.getHeader("Accept")).isEqualTo("*/*"); + + server.shutdown(); + } + @Test public void optionsForAllow() throws Exception { mockSentRequest(OPTIONS, "https://example.com"); From 1261e6446586ac153e01a0ba8602cd42cc783093 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 8 Nov 2019 08:39:18 +0000 Subject: [PATCH 0005/2315] Minor refactoring Apply default Accept header for HttpUrlConnection only. See gh-23855 --- .../SimpleBufferingClientHttpRequest.java | 8 +++ .../web/client/RestTemplate.java | 3 - .../SimpleClientHttpRequestFactoryTests.java | 5 +- .../web/client/RestTemplateTests.java | 70 ++++++++++--------- 4 files changed, 48 insertions(+), 38 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingClientHttpRequest.java index 52c3eb60e81e..394a83076354 100644 --- a/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingClientHttpRequest.java @@ -91,6 +91,14 @@ protected ClientHttpResponse executeInternal(HttpHeaders headers, byte[] buffere * @param headers the headers to add */ static void addHeaders(HttpURLConnection connection, HttpHeaders headers) { + String method = connection.getRequestMethod(); + if (method.equals("PUT") || method.equals("DELETE")) { + if (!StringUtils.hasText(headers.getFirst(HttpHeaders.ACCEPT))) { + // Avoid "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + // from HttpUrlConnection which prevents JSON error response details. + headers.set(HttpHeaders.ACCEPT, "*/*"); + } + } headers.forEach((headerName, headerValues) -> { if (HttpHeaders.COOKIE.equalsIgnoreCase(headerName)) { // RFC 6265 String headerValue = StringUtils.collectionToDelimitedString(headerValues, "; "); diff --git a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java index 4e21a9f9e061..9ccd5e4dd731 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java @@ -739,9 +739,6 @@ protected T doExecute(URI url, @Nullable HttpMethod method, @Nullable Reques if (requestCallback != null) { requestCallback.doWithRequest(request); } - if ((method == HttpMethod.DELETE || method == HttpMethod.PUT) && request.getHeaders().getAccept().isEmpty()) { - request.getHeaders().add("Accept", "*/*"); - } response = request.execute(); handleResponse(url, method, response); return (responseExtractor != null ? responseExtractor.extractData(response) : null); diff --git a/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java index f698b01728b0..df8f9a58893f 100644 --- a/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java @@ -22,6 +22,7 @@ import org.springframework.http.HttpHeaders; +import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -31,9 +32,11 @@ */ public class SimpleClientHttpRequestFactoryTests { - @Test // SPR-13225 + + @Test // SPR-13225 public void headerWithNullValue() { HttpURLConnection urlConnection = mock(HttpURLConnection.class); + given(urlConnection.getRequestMethod()).willReturn("GET"); HttpHeaders headers = new HttpHeaders(); headers.set("foo", null); SimpleBufferingClientHttpRequest.addHeaders(urlConnection, headers); diff --git a/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java b/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java index f899e6802ae4..3877572704d4 100644 --- a/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java @@ -492,45 +492,47 @@ public void putNull() throws Exception { verify(response).close(); } - @Test + @Test // gh-23740 public void headerAcceptAllOnPut() throws Exception { MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setResponseCode(500).setBody("internal server error")); server.start(); - template.setRequestFactory(new SimpleClientHttpRequestFactory()); - - template.put(server.url("/internal/server/error").uri(), null); - - RecordedRequest request = server.takeRequest(); - assertThat(request.getHeader("Accept")).isEqualTo("*/*"); - - server.shutdown(); + try { + template.setRequestFactory(new SimpleClientHttpRequestFactory()); + template.put(server.url("/internal/server/error").uri(), null); + assertThat(server.takeRequest().getHeader("Accept")).isEqualTo("*/*"); + } + finally { + server.shutdown(); + } } - @Test + @Test // gh-23740 public void keepGivenAcceptHeaderOnPut() throws Exception { MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setResponseCode(500).setBody("internal server error")); server.start(); + try { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + HttpEntity entity = new HttpEntity<>(null, headers); + template.setRequestFactory(new SimpleClientHttpRequestFactory()); + template.exchange(server.url("/internal/server/error").uri(), PUT, entity, Void.class); - template.setRequestFactory(new SimpleClientHttpRequestFactory()); - HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - HttpEntity entity = new HttpEntity<>(null, headers); - template.exchange(server.url("/internal/server/error").uri(), PUT, entity, Void.class); - - RecordedRequest request = server.takeRequest(); + RecordedRequest request = server.takeRequest(); final List> accepts = request.getHeaders().toMultimap().entrySet().stream() - .filter(entry -> entry.getKey().equalsIgnoreCase("accept")) - .map(Entry::getValue) - .collect(Collectors.toList()); + .filter(entry -> entry.getKey().equalsIgnoreCase("accept")) + .map(Entry::getValue) + .collect(Collectors.toList()); - assertThat(accepts).hasSize(1); - assertThat(accepts.get(0)).hasSize(1); - assertThat(accepts.get(0).get(0)).isEqualTo("application/json"); - - server.shutdown(); + assertThat(accepts).hasSize(1); + assertThat(accepts.get(0)).hasSize(1); + assertThat(accepts.get(0).get(0)).isEqualTo("application/json"); + } + finally { + server.shutdown(); + } } @Test @@ -579,19 +581,19 @@ public void delete() throws Exception { verify(response).close(); } - @Test + @Test // gh-23740 public void headerAcceptAllOnDelete() throws Exception { MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setResponseCode(500).setBody("internal server error")); server.start(); - template.setRequestFactory(new SimpleClientHttpRequestFactory()); - - template.delete(server.url("/internal/server/error").uri()); - - RecordedRequest request = server.takeRequest(); - assertThat(request.getHeader("Accept")).isEqualTo("*/*"); - - server.shutdown(); + try { + template.setRequestFactory(new SimpleClientHttpRequestFactory()); + template.delete(server.url("/internal/server/error").uri()); + assertThat(server.takeRequest().getHeader("Accept")).isEqualTo("*/*"); + } + finally { + server.shutdown(); + } } @Test From 91f5f42d136ccae798e01e71356787d4a12913e6 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Wed, 6 Nov 2019 11:07:59 +0900 Subject: [PATCH 0006/2315] Add tests for PrincipalMethodArgumentResolver --- .../PrincipalMethodArgumentResolverTests.java | 76 +++++++++++++++++++ .../PrincipalMethodArgumentResolverTests.java | 2 +- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/PrincipalMethodArgumentResolverTests.java diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/PrincipalMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/PrincipalMethodArgumentResolverTests.java new file mode 100644 index 000000000000..0f9664aa403c --- /dev/null +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/PrincipalMethodArgumentResolverTests.java @@ -0,0 +1,76 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.messaging.simp.annotation.support; + +import java.security.Principal; +import java.util.Collections; +import java.util.Optional; + +import org.junit.jupiter.api.Test; + +import org.springframework.core.MethodParameter; +import org.springframework.messaging.Message; +import org.springframework.messaging.handler.invocation.ResolvableMethod; +import org.springframework.messaging.simp.SimpMessageHeaderAccessor; +import org.springframework.messaging.support.GenericMessage; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Unit tests for {@link PrincipalMethodArgumentResolver}. + * + * @author Rossen Stoyanchev + * @author Johnny Lim + */ +public class PrincipalMethodArgumentResolverTests { + + private final PrincipalMethodArgumentResolver resolver = new PrincipalMethodArgumentResolver(); + + private final ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); + + + @Test + public void supportsParameter() { + assertThat(this.resolver.supportsParameter(this.testMethod.arg(Principal.class))).isTrue(); + assertThat(this.resolver.supportsParameter(this.testMethod.arg(Optional.class, Principal.class))).isTrue(); + } + + + @Test + public void resolverArgument() { + Principal user = () -> "Joe"; + Message message = new GenericMessage<>("Hello, world!", + Collections.singletonMap(SimpMessageHeaderAccessor.USER_HEADER, user)); + + MethodParameter param = this.testMethod.arg(Principal.class); + Object actual = this.resolver.resolveArgument(param, message); + assertThat(actual).isSameAs(user); + + param = this.testMethod.arg(Optional.class, Principal.class); + actual = this.resolver.resolveArgument(param, message); + assertThat(Optional.class.isAssignableFrom(actual.getClass())).isTrue(); + assertThat(((Optional) actual).get()).isSameAs(user); + } + + + @SuppressWarnings("unused") + void handle( + Principal user, + Optional optionalUser) { + } + +} diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java index 4ad26e732e3b..e12ab799285c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java @@ -42,7 +42,7 @@ public class PrincipalMethodArgumentResolverTests { private final PrincipalMethodArgumentResolver resolver = new PrincipalMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance()); - private ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); + private final ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); @Test From 0e1a237139e8035860457d129bd93451291e11f5 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 8 Nov 2019 09:17:25 +0000 Subject: [PATCH 0007/2315] Polishing --- .../support/PrincipalMethodArgumentResolverTests.java | 7 ++----- .../annotation/PrincipalMethodArgumentResolverTests.java | 8 +++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/PrincipalMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/PrincipalMethodArgumentResolverTests.java index 0f9664aa403c..7ccbb7e79a89 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/PrincipalMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/PrincipalMethodArgumentResolverTests.java @@ -62,15 +62,12 @@ public void resolverArgument() { param = this.testMethod.arg(Optional.class, Principal.class); actual = this.resolver.resolveArgument(param, message); - assertThat(Optional.class.isAssignableFrom(actual.getClass())).isTrue(); - assertThat(((Optional) actual).get()).isSameAs(user); + assertThat(actual).isInstanceOf(Optional.class).extracting(o -> ((Optional) o).get()).isSameAs(user); } @SuppressWarnings("unused") - void handle( - Principal user, - Optional optionalUser) { + void handle(Principal user, Optional optionalUser) { } } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java index e12ab799285c..32078174ff84 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java @@ -55,24 +55,22 @@ public void supportsParameter() { @Test public void resolverArgument() { - BindingContext context = new BindingContext(); Principal user = () -> "Joe"; ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")) .mutate().principal(Mono.just(user)).build(); + BindingContext context = new BindingContext(); MethodParameter param = this.testMethod.arg(Principal.class); Object actual = this.resolver.resolveArgument(param, context, exchange).block(); assertThat(actual).isSameAs(user); param = this.testMethod.arg(Mono.class, Principal.class); actual = this.resolver.resolveArgument(param, context, exchange).block(); - assertThat(Mono.class.isAssignableFrom(actual.getClass())).isTrue(); - assertThat(((Mono) actual).block()).isSameAs(user); + assertThat(actual).isInstanceOf(Mono.class).extracting(o -> ((Mono) o).block()).isSameAs(user); param = this.testMethod.arg(Single.class, Principal.class); actual = this.resolver.resolveArgument(param, context, exchange).block(); - assertThat(Single.class.isAssignableFrom(actual.getClass())).isTrue(); - assertThat(((Single) actual).blockingGet()).isSameAs(user); + assertThat(actual).isInstanceOf(Single.class).extracting(o -> ((Single) o).blockingGet()).isSameAs(user); } From 9b8da04e643bdb580055d5305dec68b5c2c3ea6c Mon Sep 17 00:00:00 2001 From: Qimiao Chen Date: Fri, 8 Nov 2019 20:39:02 +0800 Subject: [PATCH 0008/2315] Delete unnecessary variable assignment Closes gh-23955 --- .../beans/factory/support/AbstractBeanFactory.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index 29fe3a8c4649..c8305b30cfb0 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -1317,7 +1317,6 @@ protected RootBeanDefinition getMergedBeanDefinition( if (mbd == null || mbd.stale) { previous = mbd; - mbd = null; if (bd.getParentName() == null) { // Use copy of given root bean definition. if (bd instanceof RootBeanDefinition) { From 21d390a01860fc89856750dd6c836ea2205bb023 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Thu, 15 Aug 2019 11:22:52 -0400 Subject: [PATCH 0009/2315] Replacing netty-all with specific dependencies --- spring-web/spring-web.gradle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-web/spring-web.gradle b/spring-web/spring-web.gradle index 70ac9dc0a7d5..6784d44483b3 100644 --- a/spring-web/spring-web.gradle +++ b/spring-web/spring-web.gradle @@ -21,7 +21,10 @@ dependencies { optional("io.reactivex:rxjava") optional("io.reactivex:rxjava-reactive-streams") optional("io.reactivex.rxjava2:rxjava") - optional("io.netty:netty-all") + optional("io.netty:netty-buffer") + optional("io.netty:netty-handler") + optional("io.netty:netty-codec-http") // Until Netty4ClientHttpRequest is removed + optional("io.netty:netty-transport") // Until Netty4ClientHttpRequest is removed optional("io.projectreactor.netty:reactor-netty") optional("io.undertow:undertow-core") optional("org.apache.tomcat.embed:tomcat-embed-core") From 801cca8cf80de2a50bbf6749e333b9efd1eb1bbe Mon Sep 17 00:00:00 2001 From: Ilya Lukyanovich Date: Mon, 5 Aug 2019 13:35:39 +0300 Subject: [PATCH 0010/2315] Preserve ErrorMessage#getOriginalMessage() See gh-23417 --- .../messaging/support/MessageBuilder.java | 11 ++++++- .../support/MessageBuilderTests.java | 29 ++++++++++++++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java index e722bafc8ace..cd909f4baf45 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java @@ -99,6 +99,7 @@ public MessageBuilder removeHeaders(String... headerPatterns) { this.headerAccessor.removeHeaders(headerPatterns); return this; } + /** * Remove the value for the given header name. */ @@ -153,7 +154,11 @@ public Message build() { } MessageHeaders headersToUse = this.headerAccessor.toMessageHeaders(); if (this.payload instanceof Throwable) { - return (Message) new ErrorMessage((Throwable) this.payload, headersToUse); + Message originalMessage = null; + if (this.originalMessage != null && this.originalMessage instanceof ErrorMessage) { + originalMessage = ((ErrorMessage) this.originalMessage).getOriginalMessage(); + } + return (Message) new ErrorMessage((Throwable) this.payload, headersToUse, originalMessage); } else { return new GenericMessage<>(this.payload, headersToUse); @@ -165,6 +170,10 @@ public Message build() { * Create a builder for a new {@link Message} instance pre-populated with all of the * headers copied from the provided message. The payload of the provided Message will * also be used as the payload for the new message. + * + * If the provided message is an {@link ErrorMessage} - the + * {@link ErrorMessage#originalMessage} link will be provided to the new instance. + * * @param message the Message from which the payload and all headers will be copied */ public static MessageBuilder fromMessage(Message message) { diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java index e0a0b8ccb067..3e26ba42c2c9 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java @@ -16,6 +16,7 @@ package org.springframework.messaging.support; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -107,6 +108,20 @@ public void createFromMessage() { assertThat(message2.getHeaders().get("foo")).isEqualTo("bar"); } + @Test + public void createErrorMessageFromErrorMessage() { + Message originalMessage = MessageBuilder.withPayload("test") + .setHeader("foo", "bar").build(); + RuntimeException errorPayload = new RuntimeException(); + ErrorMessage errorMessage1 = new ErrorMessage(errorPayload, Collections.singletonMap("baz", "42"), originalMessage); + Message errorMessage2 = MessageBuilder.fromMessage(errorMessage1).build(); + assertThat(errorMessage2).isExactlyInstanceOf(ErrorMessage.class); + ErrorMessage actual = (ErrorMessage) errorMessage2; + assertThat(actual.getPayload()).isSameAs(errorPayload); + assertThat(actual.getHeaders().get("baz")).isEqualTo("42"); + assertThat(actual.getOriginalMessage()).isSameAs(originalMessage); + } + @Test public void createIdRegenerated() { Message message1 = MessageBuilder.withPayload("test") @@ -119,20 +134,20 @@ public void createIdRegenerated() { @Test public void testRemove() { Message message1 = MessageBuilder.withPayload(1) - .setHeader("foo", "bar").build(); + .setHeader("foo", "bar").build(); Message message2 = MessageBuilder.fromMessage(message1) - .removeHeader("foo") - .build(); + .removeHeader("foo") + .build(); assertThat(message2.getHeaders().containsKey("foo")).isFalse(); } @Test public void testSettingToNullRemoves() { Message message1 = MessageBuilder.withPayload(1) - .setHeader("foo", "bar").build(); + .setHeader("foo", "bar").build(); Message message2 = MessageBuilder.fromMessage(message1) - .setHeader("foo", null) - .build(); + .setHeader("foo", null) + .build(); assertThat(message2.getHeaders().containsKey("foo")).isFalse(); } @@ -192,7 +207,7 @@ public void testBuildMessageWithDefaultMutability() { assertThatIllegalStateException().isThrownBy(() -> accessor.setHeader("foo", "bar")) - .withMessageContaining("Already immutable"); + .withMessageContaining("Already immutable"); assertThat(MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class)).isSameAs(accessor); } From b2b02ad7a17752479ff9febe7b4ab15da3b81708 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 8 Nov 2019 15:03:12 +0000 Subject: [PATCH 0011/2315] Polishing --- .../messaging/support/MessageBuilder.java | 37 ++++++++++--------- .../support/MessageBuilderTests.java | 13 +++---- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java index cd909f4baf45..64d75f2d0f9e 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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,23 +41,23 @@ public final class MessageBuilder { private final T payload; @Nullable - private final Message originalMessage; + private final Message providedMessage; private MessageHeaderAccessor headerAccessor; - private MessageBuilder(Message originalMessage) { - Assert.notNull(originalMessage, "Message must not be null"); - this.payload = originalMessage.getPayload(); - this.originalMessage = originalMessage; - this.headerAccessor = new MessageHeaderAccessor(originalMessage); + private MessageBuilder(Message providedMessage) { + Assert.notNull(providedMessage, "Message must not be null"); + this.payload = providedMessage.getPayload(); + this.providedMessage = providedMessage; + this.headerAccessor = new MessageHeaderAccessor(providedMessage); } private MessageBuilder(T payload, MessageHeaderAccessor accessor) { Assert.notNull(payload, "Payload must not be null"); Assert.notNull(accessor, "MessageHeaderAccessor must not be null"); this.payload = payload; - this.originalMessage = null; + this.providedMessage = null; this.headerAccessor = accessor; } @@ -149,16 +149,18 @@ public MessageBuilder setErrorChannelName(String errorChannelName) { @SuppressWarnings("unchecked") public Message build() { - if (this.originalMessage != null && !this.headerAccessor.isModified()) { - return this.originalMessage; + if (this.providedMessage != null && !this.headerAccessor.isModified()) { + return this.providedMessage; } MessageHeaders headersToUse = this.headerAccessor.toMessageHeaders(); if (this.payload instanceof Throwable) { - Message originalMessage = null; - if (this.originalMessage != null && this.originalMessage instanceof ErrorMessage) { - originalMessage = ((ErrorMessage) this.originalMessage).getOriginalMessage(); + if (this.providedMessage != null && this.providedMessage instanceof ErrorMessage) { + Message message = ((ErrorMessage) this.providedMessage).getOriginalMessage(); + if (message != null) { + return (Message) new ErrorMessage((Throwable) this.payload, headersToUse, message); + } } - return (Message) new ErrorMessage((Throwable) this.payload, headersToUse, originalMessage); + return (Message) new ErrorMessage((Throwable) this.payload, headersToUse); } else { return new GenericMessage<>(this.payload, headersToUse); @@ -170,10 +172,9 @@ public Message build() { * Create a builder for a new {@link Message} instance pre-populated with all of the * headers copied from the provided message. The payload of the provided Message will * also be used as the payload for the new message. - * - * If the provided message is an {@link ErrorMessage} - the - * {@link ErrorMessage#originalMessage} link will be provided to the new instance. - * + *

If the provided message is an {@link ErrorMessage}, the + * {@link ErrorMessage#getOriginalMessage() originalMessage} it contains, will be + * passed on to new instance. * @param message the Message from which the payload and all headers will be copied */ public static MessageBuilder fromMessage(Message message) { diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java index 3e26ba42c2c9..c1e2df81ea2c 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java @@ -108,18 +108,17 @@ public void createFromMessage() { assertThat(message2.getHeaders().get("foo")).isEqualTo("bar"); } - @Test + @Test // gh-23417 public void createErrorMessageFromErrorMessage() { - Message originalMessage = MessageBuilder.withPayload("test") - .setHeader("foo", "bar").build(); - RuntimeException errorPayload = new RuntimeException(); - ErrorMessage errorMessage1 = new ErrorMessage(errorPayload, Collections.singletonMap("baz", "42"), originalMessage); + Message source = MessageBuilder.withPayload("test").setHeader("foo", "bar").build(); + RuntimeException ex = new RuntimeException(); + ErrorMessage errorMessage1 = new ErrorMessage(ex, Collections.singletonMap("baz", "42"), source); Message errorMessage2 = MessageBuilder.fromMessage(errorMessage1).build(); assertThat(errorMessage2).isExactlyInstanceOf(ErrorMessage.class); ErrorMessage actual = (ErrorMessage) errorMessage2; - assertThat(actual.getPayload()).isSameAs(errorPayload); + assertThat(actual.getPayload()).isSameAs(ex); assertThat(actual.getHeaders().get("baz")).isEqualTo("42"); - assertThat(actual.getOriginalMessage()).isSameAs(originalMessage); + assertThat(actual.getOriginalMessage()).isSameAs(source); } @Test From b0b6423714be38d5cf74bf658386faf62c300d41 Mon Sep 17 00:00:00 2001 From: denisgalaybo <57059361+denisgalaybo@users.noreply.github.com> Date: Fri, 8 Nov 2019 21:36:37 +0700 Subject: [PATCH 0012/2315] Fixed error in webflux.adoc Closes gh-23957 --- src/docs/asciidoc/web/webflux.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index b1ec0d8fcc7a..2bc94b17fa60 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -997,13 +997,13 @@ as the following example shows: .Java ---- ApplicationContext context = ... - HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context); + HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build(); ---- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin ---- val context: ApplicationContext = ... - val handler = WebHttpHandlerBuilder.applicationContext(context) + val handler = WebHttpHandlerBuilder.applicationContext(context).build() ---- The resulting `HttpHandler` is ready for use with a <>. From 08f1cb454a2d23a0c63cd846196b8d43205e7945 Mon Sep 17 00:00:00 2001 From: Ilja Date: Mon, 1 Apr 2019 10:14:53 +0200 Subject: [PATCH 0013/2315] Allow sending headers with the disconnect frame --- .../simp/stomp/DefaultStompSession.java | 8 +++++++ .../messaging/simp/stomp/StompSession.java | 6 ++++++ .../simp/stomp/DefaultStompSessionTests.java | 21 +++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java index 18687736cfc0..228abd915fb7 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java @@ -362,9 +362,17 @@ private void unsubscribe(String id, @Nullable StompHeaders headers) { @Override public void disconnect() { + disconnect(null); + } + + @Override + public void disconnect(@Nullable StompHeaders headers) { this.closing = true; try { StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.DISCONNECT); + if (headers != null) { + accessor.addNativeHeaders(headers); + } Message message = createMessage(accessor, EMPTY_PAYLOAD); execute(message); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompSession.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompSession.java index 703f4ee1c0c9..ca6d99a323f9 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompSession.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompSession.java @@ -116,6 +116,12 @@ public interface StompSession { */ void disconnect(); + /** + * Disconnect the session by sending a DISCONNECT frame. + * @param headers the headers for the disconnect message frame + */ + void disconnect(StompHeaders headers); + /** * A handle to use to track receipts. diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java index 1b744a278fde..5ef8482697b8 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java @@ -659,4 +659,25 @@ public void disconnect() { verifyNoMoreInteractions(this.sessionHandler); } + @Test + public void disconnectWithHeaders() { + this.session.afterConnected(this.connection); + assertTrue(this.session.isConnected()); + + StompHeaders headers = new StompHeaders(); + headers.add("foo", "bar"); + + this.session.disconnect(headers); + + Message message = this.messageCaptor.getValue(); + StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); + headers = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders()); + assertEquals(headers.toString(), 1, headers.size()); + assertEquals(headers.get("foo").size(), 1); + assertEquals(headers.get("foo").get(0), "bar"); + + assertFalse(this.session.isConnected()); + verifyNoMoreInteractions(this.sessionHandler); + } + } From 32f82c0ed01225b394dfccf72dd8020dced18efa Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 8 Nov 2019 17:47:59 +0000 Subject: [PATCH 0014/2315] Polishing --- .../messaging/simp/stomp/StompSession.java | 3 ++- .../messaging/simp/stomp/DefaultStompSessionTests.java | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompSession.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompSession.java index ca6d99a323f9..61e0b68489de 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompSession.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompSession.java @@ -117,8 +117,9 @@ public interface StompSession { void disconnect(); /** - * Disconnect the session by sending a DISCONNECT frame. + * Variant of {@link #disconnect()} with headers. * @param headers the headers for the disconnect message frame + * @since 5.2.2 */ void disconnect(StompHeaders headers); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java index 5ef8482697b8..7f979b54213e 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java @@ -662,7 +662,7 @@ public void disconnect() { @Test public void disconnectWithHeaders() { this.session.afterConnected(this.connection); - assertTrue(this.session.isConnected()); + assertThat(this.session.isConnected()).isTrue(); StompHeaders headers = new StompHeaders(); headers.add("foo", "bar"); @@ -672,11 +672,11 @@ public void disconnectWithHeaders() { Message message = this.messageCaptor.getValue(); StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); headers = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders()); - assertEquals(headers.toString(), 1, headers.size()); - assertEquals(headers.get("foo").size(), 1); - assertEquals(headers.get("foo").get(0), "bar"); + assertThat(headers.size()).as(headers.toString()).isEqualTo(1); + assertThat(headers.get("foo").size()).isEqualTo(1); + assertThat(headers.get("foo").get(0)).isEqualTo("bar"); - assertFalse(this.session.isConnected()); + assertThat(this.session.isConnected()).isFalse(); verifyNoMoreInteractions(this.sessionHandler); } From f638bfc6a9231591f4e605c4caced092cd7cd32f Mon Sep 17 00:00:00 2001 From: Muhammad Hewedy Date: Sun, 10 Feb 2019 14:22:43 +0300 Subject: [PATCH 0015/2315] Fix status code in webmvc.adoc Closes gh-22396 --- src/docs/asciidoc/web/webmvc.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index 86a9afdde3d8..7133ab1d7aa5 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -4818,7 +4818,7 @@ as the following example shows: There are three variants for checking conditional requests against `eTag` values, `lastModified` values, or both. For conditional `GET` and `HEAD` requests, you can set the response to 304 (NOT_MODIFIED). For conditional `POST`, `PUT`, and `DELETE`, you can instead set the response -to 409 (PRECONDITION_FAILED), to prevent concurrent modification. +to 412 (PRECONDITION_FAILED), to prevent concurrent modification. From cfb7777a070ca2d19c91b98bf39c42bdf8d7be72 Mon Sep 17 00:00:00 2001 From: Rob Tompkins Date: Sun, 9 Sep 2018 20:31:07 -0400 Subject: [PATCH 0016/2315] Exception response for MockRestServiceServer Closes gh-1954 --- .../client/response/MockRestResponseCreators.java | 12 ++++++++++++ .../web/client/response/ResponseCreatorsTests.java | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/spring-test/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java b/spring-test/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java index ceb7c028de5d..497f6b827676 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java @@ -16,6 +16,7 @@ package org.springframework.test.web.client.response; +import java.io.IOException; import java.net.URI; import org.springframework.core.io.Resource; @@ -116,4 +117,15 @@ public static DefaultResponseCreator withStatus(HttpStatus status) { return new DefaultResponseCreator(status); } + /** + * {@code ResponseCreator} with an internal application {@code IOException}. For example, + * one could use this to simulate a {@code SocketTimeoutException}. + * @param e the {@code Exception} to be thrown at HTTP call time. + */ + public static ResponseCreator withException(IOException e) { + return request -> { + throw e; + }; + } + } diff --git a/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java b/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java index 0465bdebd3db..00dcb1aa047d 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java @@ -16,6 +16,7 @@ package org.springframework.test.web.client.response; +import java.net.SocketTimeoutException; import java.net.URI; import org.junit.jupiter.api.Test; @@ -23,6 +24,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.mock.http.client.MockClientHttpResponse; +import org.springframework.test.web.client.ResponseCreator; import org.springframework.util.StreamUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -124,4 +126,10 @@ public void withStatus() throws Exception { assertThat(StreamUtils.copyToByteArray(response.getBody()).length).isEqualTo(0); } + @Test(expected = SocketTimeoutException.class) + public void withException() throws Exception { + ResponseCreator responseCreator = MockRestResponseCreators.withException(new SocketTimeoutException()); + responseCreator.createResponse(null); + } + } From cb9d27b9b88c282be8aa63085a4b1b6d04690cbf Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 9 Nov 2019 12:45:02 +0100 Subject: [PATCH 0017/2315] Polish contribution and fix build See gh-1954 --- .../response/MockRestResponseCreators.java | 13 +++++---- .../response/ResponseCreatorsTests.java | 28 ++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java b/spring-test/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java index 497f6b827676..cb9c9d84a642 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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,13 +118,14 @@ public static DefaultResponseCreator withStatus(HttpStatus status) { } /** - * {@code ResponseCreator} with an internal application {@code IOException}. For example, - * one could use this to simulate a {@code SocketTimeoutException}. - * @param e the {@code Exception} to be thrown at HTTP call time. + * {@code ResponseCreator} with an internal application {@code IOException}. + *

For example, one could use this to simulate a {@code SocketTimeoutException}. + * @param ex the {@code Exception} to be thrown at HTTP call time + * @since 5.2.2 */ - public static ResponseCreator withException(IOException e) { + public static ResponseCreator withException(IOException ex) { return request -> { - throw e; + throw ex; }; } diff --git a/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java b/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java index 00dcb1aa047d..b9e044824cb8 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java @@ -28,16 +28,17 @@ import org.springframework.util.StreamUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * Tests for the {@link MockRestResponseCreators} static factory methods. * * @author Rossen Stoyanchev */ -public class ResponseCreatorsTests { +class ResponseCreatorsTests { @Test - public void success() throws Exception { + void success() throws Exception { MockClientHttpResponse response = (MockClientHttpResponse) MockRestResponseCreators.withSuccess().createResponse(null); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); @@ -46,7 +47,7 @@ public void success() throws Exception { } @Test - public void successWithContent() throws Exception { + void successWithContent() throws Exception { DefaultResponseCreator responseCreator = MockRestResponseCreators.withSuccess("foo", MediaType.TEXT_PLAIN); MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); @@ -56,7 +57,7 @@ public void successWithContent() throws Exception { } @Test - public void successWithContentWithoutContentType() throws Exception { + void successWithContentWithoutContentType() throws Exception { DefaultResponseCreator responseCreator = MockRestResponseCreators.withSuccess("foo", null); MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); @@ -66,7 +67,7 @@ public void successWithContentWithoutContentType() throws Exception { } @Test - public void created() throws Exception { + void created() throws Exception { URI location = new URI("/foo"); DefaultResponseCreator responseCreator = MockRestResponseCreators.withCreatedEntity(location); MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); @@ -77,7 +78,7 @@ public void created() throws Exception { } @Test - public void noContent() throws Exception { + void noContent() throws Exception { DefaultResponseCreator responseCreator = MockRestResponseCreators.withNoContent(); MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); @@ -87,7 +88,7 @@ public void noContent() throws Exception { } @Test - public void badRequest() throws Exception { + void badRequest() throws Exception { DefaultResponseCreator responseCreator = MockRestResponseCreators.withBadRequest(); MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); @@ -97,7 +98,7 @@ public void badRequest() throws Exception { } @Test - public void unauthorized() throws Exception { + void unauthorized() throws Exception { DefaultResponseCreator responseCreator = MockRestResponseCreators.withUnauthorizedRequest(); MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); @@ -107,7 +108,7 @@ public void unauthorized() throws Exception { } @Test - public void serverError() throws Exception { + void serverError() throws Exception { DefaultResponseCreator responseCreator = MockRestResponseCreators.withServerError(); MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); @@ -117,7 +118,7 @@ public void serverError() throws Exception { } @Test - public void withStatus() throws Exception { + void withStatus() throws Exception { DefaultResponseCreator responseCreator = MockRestResponseCreators.withStatus(HttpStatus.FORBIDDEN); MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); @@ -126,10 +127,11 @@ public void withStatus() throws Exception { assertThat(StreamUtils.copyToByteArray(response.getBody()).length).isEqualTo(0); } - @Test(expected = SocketTimeoutException.class) - public void withException() throws Exception { + @Test + void withException() { ResponseCreator responseCreator = MockRestResponseCreators.withException(new SocketTimeoutException()); - responseCreator.createResponse(null); + assertThatExceptionOfType(SocketTimeoutException.class) + .isThrownBy(() -> responseCreator.createResponse(null)); } } From 29185505b1b81b713609b2748dc211b2f0d7c2e8 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 9 Nov 2019 13:51:28 +0100 Subject: [PATCH 0018/2315] Polishing --- src/docs/asciidoc/web/webflux.adoc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index 2bc94b17fa60..4a10ce87a806 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -586,7 +586,6 @@ Spring ApplicationContext, or that can be registered directly with it: suspend fun getFormData(): MultiValueMap ---- - The `DefaultServerWebExchange` uses the configured `HttpMessageReader` to parse form data (`application/x-www-form-urlencoded`) into a `MultiValueMap`. By default, `FormHttpMessageReader` is configured for use by the `ServerCodecConfigurer` bean @@ -803,7 +802,7 @@ consistently for access to the cached form data versus reading from the raw requ `MultipartHttpMessageReader` and `MultipartHttpMessageWriter` support decoding and encoding "multipart/form-data" content. In turn `MultipartHttpMessageReader` delegates to another `HttpMessageReader` for the actual parsing to a `Flux` and then simply -collects the parts into a `MultiValueMap`. At present the +collects the parts into a `MultiValueMap`. At present https://github.com/synchronoss/nio-multipart[Synchronoss NIO Multipart] is used for the actual parsing. @@ -824,10 +823,11 @@ for repeated, map-like access to parts, or otherwise rely on the `Decoder` and `HttpMessageReader` implementations that buffer some or all of the input stream can be configured with a limit on the maximum number of bytes to buffer in memory. In some cases buffering occurs because input is aggregated and represented as a single -object, e.g. controller method with `@RequestBody byte[]`, `x-www-form-urlencoded` data, -and so on. Buffering can also occurs with streaming, when splitting the input stream, -e.g. delimited text, a stream of JSON objects, and so on. For those streaming cases, the -limit applies to the number of bytes associted with one object in the stream. +object — for example, a controller method with `@RequestBody byte[]`, +`x-www-form-urlencoded` data, and so on. Buffering can also occur with streaming, when +splitting the input stream — for example, delimited text, a stream of JSON objects, and +so on. For those streaming cases, the limit applies to the number of bytes associated +with one object in the stream. To configure buffer sizes, you can check if a given `Decoder` or `HttpMessageReader` exposes a `maxInMemorySize` property and if so the Javadoc will have details about default @@ -851,7 +851,7 @@ To configure all 3 in WebFlux, you'll need to supply a pre-configured instance o When streaming to the HTTP response (for example, `text/event-stream`, `application/stream+json`), it is important to send data periodically, in order to -reliably detect a disconnected client sooner rather than later. Such a send could be an +reliably detect a disconnected client sooner rather than later. Such a send could be a comment-only, empty SSE event or any other "no-op" data that would effectively serve as a heartbeat. @@ -867,14 +867,12 @@ when consumed to avoid memory leaks. WebFlux applications generally do not need to be concerned with such issues, unless they consume or produce data buffers directly, as opposed to relying on codecs to convert to -and from higher level objects. Or unless they choose to create custom codecs. For such +and from higher level objects, or unless they choose to create custom codecs. For such cases please review the the information in <>, especially the section on <>. - - [[webflux-logging]] === Logging [.small]#<># @@ -1717,6 +1715,7 @@ under different URLs. The following example shows how to do so: <4> Add the registration. + [[webflux-ann-methods]] === Handler Methods [.small]#<># @@ -3477,6 +3476,7 @@ use case-oriented approach that focuses on the common scenarios, as the followin ---- + [[webflux-caching-etag-lastmodified]] === Controllers [.small]#<># From 64dfa462a6354bb0dc3240ca9be68ce37e695c17 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 9 Nov 2019 18:03:07 +0100 Subject: [PATCH 0019/2315] Fix Javadoc for SmartLifecycle.DEFAULT_PHASE regarding ordering Closes gh-23956 --- .../context/SmartLifecycle.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/SmartLifecycle.java b/spring-context/src/main/java/org/springframework/context/SmartLifecycle.java index 4ee111d3d858..06f98a4048ca 100644 --- a/spring-context/src/main/java/org/springframework/context/SmartLifecycle.java +++ b/spring-context/src/main/java/org/springframework/context/SmartLifecycle.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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,19 +17,21 @@ package org.springframework.context; /** - * An extension of the {@link Lifecycle} interface for those objects that require to - * be started upon ApplicationContext refresh and/or shutdown in a particular order. - * The {@link #isAutoStartup()} return value indicates whether this object should + * An extension of the {@link Lifecycle} interface for those objects that require + * to be started upon {@code ApplicationContext} refresh and/or shutdown in a + * particular order. + * + *

The {@link #isAutoStartup()} return value indicates whether this object should * be started at the time of a context refresh. The callback-accepting * {@link #stop(Runnable)} method is useful for objects that have an asynchronous * shutdown process. Any implementation of this interface must invoke the * callback's {@code run()} method upon shutdown completion to avoid unnecessary - * delays in the overall ApplicationContext shutdown. + * delays in the overall {@code ApplicationContext} shutdown. * *

This interface extends {@link Phased}, and the {@link #getPhase()} method's - * return value indicates the phase within which this Lifecycle component should - * be started and stopped. The startup process begins with the lowest phase - * value and ends with the highest phase value ({@code Integer.MIN_VALUE} + * return value indicates the phase within which this {@code Lifecycle} component + * should be started and stopped. The startup process begins with the lowest + * phase value and ends with the highest phase value ({@code Integer.MIN_VALUE} * is the lowest possible, and {@code Integer.MAX_VALUE} is the highest possible). * The shutdown process will apply the reverse order. Any components with the * same value will be arbitrarily ordered within the same phase. @@ -44,9 +46,11 @@ * *

Any {@code Lifecycle} components within the context that do not also * implement {@code SmartLifecycle} will be treated as if they have a phase - * value of 0. That way a {@code SmartLifecycle} implementation may start - * before those {@code Lifecycle} components if it has a negative phase value, - * or it may start after those components if it has a positive phase value. + * value of {@code 0}. This allows a {@code SmartLifecycle} component to start + * before those {@code Lifecycle} components if the {@code SmartLifecycle} + * component has a negative phase value, or the {@code SmartLifecycle} component + * may start after those {@code Lifecycle} components if the {@code SmartLifecycle} + * component has a positive phase value. * *

Note that, due to the auto-startup support in {@code SmartLifecycle}, a * {@code SmartLifecycle} bean instance will usually get initialized on startup @@ -55,6 +59,7 @@ * * @author Mark Fisher * @author Juergen Hoeller + * @author Sam Brannen * @since 3.0 * @see LifecycleProcessor * @see ConfigurableApplicationContext @@ -63,9 +68,10 @@ public interface SmartLifecycle extends Lifecycle, Phased { /** * The default phase for {@code SmartLifecycle}: {@code Integer.MAX_VALUE}. - *

This is different from the common phase 0 associated with regular + *

This is different from the common phase {@code 0} associated with regular * {@link Lifecycle} implementations, putting the typically auto-started - * {@code SmartLifecycle} beans into a separate later shutdown phase. + * {@code SmartLifecycle} beans into a later startup phase and an earlier + * shutdown phase. * @since 5.1 * @see #getPhase() * @see org.springframework.context.support.DefaultLifecycleProcessor#getPhase(Lifecycle) @@ -115,7 +121,8 @@ default void stop(Runnable callback) { /** * Return the phase that this lifecycle object is supposed to run in. *

The default implementation returns {@link #DEFAULT_PHASE} in order to - * let stop callbacks execute after regular {@code Lifecycle} implementations. + * let {@code stop()} callbacks execute after regular {@code Lifecycle} + * implementations. * @see #isAutoStartup() * @see #start() * @see #stop(Runnable) From 1403603b05e1efa558af60d36b6025324369cbd2 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 11 Nov 2019 11:44:44 +0000 Subject: [PATCH 0020/2315] Doc update for ForwardedHeaderFilter Closes gh-23954 --- src/docs/asciidoc/web/webmvc.adoc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index 7133ab1d7aa5..375d5a4dfd08 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -1280,14 +1280,17 @@ that proxies can use to provide information about the original request. There ar non-standard headers, too, including `X-Forwarded-Host`, `X-Forwarded-Port`, `X-Forwarded-Proto`, `X-Forwarded-Ssl`, and `X-Forwarded-Prefix`. -`ForwardedHeaderFilter` is a Servlet filter that modifies the host, port, and scheme of -the request, based on `Forwarded` headers, and then removes those headers. +`ForwardedHeaderFilter` is a Servlet filter that modifies the request in order to +a) change the host, port, and scheme based on `Forwarded` headers, and b) to remove those +headers to eliminate further impact. The filter relies on wrapping the request, and +therefore it must be ordered ahead of other filters, such as `RequestContextFilter`, that +should work with the modified and not the original request. There are security considerations for forwarded headers since an application cannot know if the headers were added by a proxy, as intended, or by a malicious client. This is why -a proxy at the boundary of trust should be configured to remove untrusted `Forwarded` headers that come -from the outside. You can also configure the `ForwardedHeaderFilter` with -`removeOnly=true`, in which case it removes but does not use the headers. +a proxy at the boundary of trust should be configured to remove untrusted `Forwarded` +headers that come from the outside. You can also configure the `ForwardedHeaderFilter` +with `removeOnly=true`, in which case it removes but does not use the headers. From ffe69a51e197152509458c0ed56bba1d83e87632 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 11 Nov 2019 12:04:28 +0000 Subject: [PATCH 0021/2315] Javadoc update for content negotiation Closes gh-23409 --- .../ContentNegotiationManagerFactoryBean.java | 44 +++++++++++-------- .../ContentNegotiationConfigurer.java | 43 +++++++++--------- 2 files changed, 48 insertions(+), 39 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java index fe00ab162ad9..f49cff639527 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -36,49 +36,55 @@ /** * Factory to create a {@code ContentNegotiationManager} and configure it with - * one or more {@link ContentNegotiationStrategy} instances. + * {@link ContentNegotiationStrategy} instances. * - *

As of 5.0 you can set the exact strategies to use via - * {@link #setStrategies(List)}. - * - *

As an alternative you can also rely on the set of defaults described below - * which can be turned on or off or customized through the methods of this - * builder: + *

This factory offers properties that in turn result in configuring the + * underlying strategies. The table below shows the property names, their + * default settings, as well as the strategies that they help to configure: * * * * + * * - * + * * * - * - * - * + * + * + * + * * * * - * + * + * * * * * - * - * + * + * + * * * * - * - * + * + * + * * * * + * * - * + * * *
Property SetterDefault ValueUnderlying StrategyDefault SettingEnabled Or Not
{@link #setFavorPathExtension}{@link PathExtensionContentNegotiationStrategy Path Extension strategy}On{@link #setFavorPathExtension favorPathExtension}true{@link PathExtensionContentNegotiationStrategy}Enabled
{@link #setFavorParameter favorParameter}{@link ParameterContentNegotiationStrategy Parameter strategy}false{@link ParameterContentNegotiationStrategy}Off
{@link #setIgnoreAcceptHeader ignoreAcceptHeader}{@link HeaderContentNegotiationStrategy Header strategy}Onfalse{@link HeaderContentNegotiationStrategy}Enabled
{@link #setDefaultContentType defaultContentType}{@link FixedContentNegotiationStrategy Fixed content strategy}Not setnull{@link FixedContentNegotiationStrategy}Off
{@link #setDefaultContentTypeStrategy defaultContentTypeStrategy}null{@link ContentNegotiationStrategy}Not setOff
* - * Note: if you must use URL-based content type resolution, + *

As of 5.0 you can set the exact strategies to use via + * {@link #setStrategies(List)}. + * + *

Note: if you must use URL-based content type resolution, * the use of a query parameter is simpler and preferable to the use of a path * extension since the latter can cause issues with URI variables, path * parameters, and URI decoding. Consider setting {@link #setFavorPathExtension} diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java index 58b100acaaf2..6b0c2522ea58 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -38,50 +38,53 @@ * Creates a {@code ContentNegotiationManager} and configures it with * one or more {@link ContentNegotiationStrategy} instances. * - *

As of 5.0 you can set the exact strategies to use via - * {@link #strategies(List)}. - * - *

As an alternative you can also rely on the set of defaults described below - * which can be turned on or off or customized through the methods of this - * builder: + *

This factory offers properties that in turn result in configuring the + * underlying strategies. The table below shows the property names, their + * default settings, as well as the strategies that they help to configure: * * * - * + * + * * - * + * * * * - * - * + * + * + * * * * - * + * + * * * * * - * - * + * + * + * * * * - * - * + * + * + * * * * + * * - * + * * *
Configurer PropertyProperty SetterDefault ValueUnderlying StrategyDefault SettingEnabled Or Not
{@link #favorPathExtension}{@link PathExtensionContentNegotiationStrategy Path Extension strategy}Ontrue{@link PathExtensionContentNegotiationStrategy}Enabled
{@link #favorParameter}{@link ParameterContentNegotiationStrategy Parameter strategy}false{@link ParameterContentNegotiationStrategy}Off
{@link #ignoreAcceptHeader}{@link HeaderContentNegotiationStrategy Header strategy}Onfalse{@link HeaderContentNegotiationStrategy}Enabled
{@link #defaultContentType}{@link FixedContentNegotiationStrategy Fixed content strategy}Not setnull{@link FixedContentNegotiationStrategy}Off
{@link #defaultContentTypeStrategy}null{@link ContentNegotiationStrategy}Not setOff
* - *

The order in which strategies are configured is fixed. You can only turn - * them on or off. + *

As of 5.0 you can set the exact strategies to use via + * {@link #strategies(List)}. * - * Note: if you must use URL-based content type resolution, + *

Note: if you must use URL-based content type resolution, * the use of a query parameter is simpler and preferable to the use of a path * extension since the latter can cause issues with URI variables, path * parameters, and URI decoding. Consider setting {@link #favorPathExtension} From b5fb28284e6e9dab9cb8747d1384d9620858fc4b Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 11 Nov 2019 13:56:40 +0000 Subject: [PATCH 0022/2315] Upgrade to Shadow Plugin 5.2.0 Closes gh-23971 --- spring-core/spring-core.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core/spring-core.gradle b/spring-core/spring-core.gradle index c8f7e4e2ba49..866b4e295c89 100644 --- a/spring-core/spring-core.gradle +++ b/spring-core/spring-core.gradle @@ -1,7 +1,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { - id "com.github.johnrengelman.shadow" version "5.1.0" + id "com.github.johnrengelman.shadow" version "5.2.0" } description = "Spring Core" From f7bc8c8268e3472911b7ebc67d3cb3d4f5e63ecc Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 11 Nov 2019 14:11:10 +0000 Subject: [PATCH 0023/2315] Tidy up classpath pollution caused by resource creation in the tests Previously, spring-webmvc and spring-webflux both contained tests that would create gzipped files, write them to the filesystem alongside the project's compiled test classes, and configure them to be deleted on JVM exit. The output location placed the files on the classpath, polluting it for every subsequent test that used the same ClassLoader. The test-sources plugin combined with Gradle's use of worker JVMs, broadens the scope of this pollution to other, downstream projects in the same build. For example, the tests for spring-websocket will have a different classpath depending on whether or not the tests for spring-webmvc have already been run on the same worker as part of the current build. This commit updates the spring-webmvc and spring-webflux modules to introduce a new JUnit Jupiter extension, GzipSupport. This extension allows gzipped files to be created via an injectable GzippedFiles class and automatically deletes each created file in an after-each callback. This ensures that a gzipped file only exists on the classpath for the duration of the test that needs it, avoiding the pollution of the classpath of any subsequent tests. Closes gh-23970 --- .../CachingResourceResolverTests.java | 7 +- .../CssLinkResourceTransformerTests.java | 8 +- .../EncodedResourceResolverTests.java | 43 ++------- .../web/reactive/resource/GzipSupport.java | 94 +++++++++++++++++++ .../CachingResourceResolverTests.java | 7 +- .../CssLinkResourceTransformerTests.java | 8 +- .../EncodedResourceResolverTests.java | 43 ++------- .../web/servlet/resource/GzipSupport.java | 94 +++++++++++++++++++ src/checkstyle/checkstyle-suppressions.xml | 6 +- 9 files changed, 231 insertions(+), 79 deletions(-) create mode 100644 spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java create mode 100644 spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipSupport.java diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java index 80c0b953b599..84d5c5a12cff 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java @@ -23,6 +23,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.springframework.cache.Cache; @@ -30,6 +31,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.mock.web.test.server.MockServerWebExchange; +import org.springframework.web.reactive.resource.GzipSupport.GzippedFiles; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; @@ -39,6 +41,7 @@ * * @author Rossen Stoyanchev */ +@ExtendWith(GzipSupport.class) public class CachingResourceResolverTests { private static final Duration TIMEOUT = Duration.ofSeconds(5); @@ -116,10 +119,10 @@ public void resolverUrlPathNoMatch() { } @Test - public void resolveResourceAcceptEncodingInCacheKey() throws IOException { + public void resolveResourceAcceptEncodingInCacheKey(GzippedFiles gzippedFiles) throws IOException { String file = "bar.css"; - EncodedResourceResolverTests.createGzippedFile(file); + gzippedFiles.create(file); // 1. Resolve plain resource diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java index ca008df98318..d35847754522 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java @@ -23,6 +23,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import reactor.test.StepVerifier; @@ -31,6 +32,7 @@ import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.StringUtils; import org.springframework.web.reactive.resource.EncodedResourceResolver.EncodedResource; +import org.springframework.web.reactive.resource.GzipSupport.GzippedFiles; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; @@ -41,6 +43,7 @@ * @author Rossen Stoyanchev * @author Sam Brannen */ +@ExtendWith(GzipSupport.class) public class CssLinkResourceTransformerTests { private ResourceTransformerChain transformerChain; @@ -147,9 +150,8 @@ public void transformSkippedForNonCssResource() { } @Test - public void transformSkippedForGzippedResource() throws Exception { - - EncodedResourceResolverTests.createGzippedFile("main.css"); + public void transformSkippedForGzippedResource(GzippedFiles gzippedFiles) throws Exception { + gzippedFiles.create("main.css"); MockServerWebExchange exchange = MockServerWebExchange.from(get("/static/main.css")); Resource resource = getResource("main.css"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java index 648b6f061452..24d680e6e9ba 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java @@ -16,31 +16,23 @@ package org.springframework.web.reactive.resource; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.time.Duration; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.zip.GZIPOutputStream; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.cache.Cache; import org.springframework.cache.concurrent.ConcurrentMapCache; import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; import org.springframework.http.HttpHeaders; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.web.test.server.MockServerWebExchange; -import org.springframework.util.FileCopyUtils; +import org.springframework.web.reactive.resource.GzipSupport.GzippedFiles; import static org.assertj.core.api.Assertions.assertThat; @@ -49,6 +41,7 @@ * * @author Rossen Stoyanchev */ +@ExtendWith(GzipSupport.class) public class EncodedResourceResolverTests { private static final Duration TIMEOUT = Duration.ofSeconds(5); @@ -59,26 +52,6 @@ public class EncodedResourceResolverTests { private List locations; - @BeforeAll - public static void createGzippedResources() throws IOException { - createGzippedFile("/js/foo.js"); - createGzippedFile("foo.css"); - } - - static void createGzippedFile(String filePath) throws IOException { - Resource location = new ClassPathResource("test/", EncodedResourceResolverTests.class); - Resource resource = new FileSystemResource(location.createRelative(filePath).getFile()); - - Path gzFilePath = Paths.get(resource.getFile().getAbsolutePath() + ".gz"); - Files.deleteIfExists(gzFilePath); - - File gzFile = Files.createFile(gzFilePath).toFile(); - GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(gzFile)); - FileCopyUtils.copy(resource.getInputStream(), out); - gzFile.deleteOnExit(); - } - - @BeforeEach public void setup() { Cache cache = new ConcurrentMapCache("resourceCache"); @@ -100,12 +73,13 @@ public void setup() { @Test - public void resolveGzipped() { + public void resolveGzipped(GzippedFiles gzippedFiles) { MockServerWebExchange exchange = MockServerWebExchange.from( MockServerHttpRequest.get("").header("Accept-Encoding", "gzip")); String file = "js/foo.js"; + gzippedFiles.create(file); Resource actual = this.resolver.resolveResource(exchange, file, this.locations).block(TIMEOUT); assertThat(actual.getDescription()).isEqualTo(getResource(file + ".gz").getDescription()); @@ -119,11 +93,11 @@ public void resolveGzipped() { } @Test - public void resolveGzippedWithVersion() { + public void resolveGzippedWithVersion(GzippedFiles gzippedFiles) { MockServerWebExchange exchange = MockServerWebExchange.from( MockServerHttpRequest.get("").header("Accept-Encoding", "gzip")); - + gzippedFiles.create("foo.css"); String file = "foo-e36d2e05253c6c7085a91522ce43a0b4.css"; Resource actual = this.resolver.resolveResource(exchange, file, this.locations).block(TIMEOUT); @@ -134,7 +108,7 @@ public void resolveGzippedWithVersion() { } @Test - public void resolveFromCacheWithEncodingVariants() { + public void resolveFromCacheWithEncodingVariants(GzippedFiles gzippedFiles) { // 1. Resolve, and cache .gz variant @@ -142,6 +116,7 @@ public void resolveFromCacheWithEncodingVariants() { MockServerHttpRequest.get("").header("Accept-Encoding", "gzip")); String file = "js/foo.js"; + gzippedFiles.create(file); Resource resolved = this.resolver.resolveResource(exchange, file, this.locations).block(TIMEOUT); assertThat(resolved.getDescription()).isEqualTo(getResource(file + ".gz").getDescription()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java new file mode 100644 index 000000000000..238c0a17e79d --- /dev/null +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java @@ -0,0 +1,94 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.web.reactive.resource; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.Set; +import java.util.zip.GZIPOutputStream; + +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.ExtensionContext.Namespace; +import org.junit.jupiter.api.extension.ExtensionContext.Store; +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.api.extension.ParameterResolutionException; +import org.junit.jupiter.api.extension.ParameterResolver; + +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.io.Resource; +import org.springframework.util.FileCopyUtils; + +class GzipSupport implements AfterEachCallback, ParameterResolver { + + @Override + public void afterEach(ExtensionContext context) throws Exception { + GzippedFiles gzippedFiles = getStore(context).get(GzippedFiles.class, GzippedFiles.class); + if (gzippedFiles != null) { + for (File gzippedFile: gzippedFiles.created) { + gzippedFile.delete(); + } + } + } + + @Override + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + throws ParameterResolutionException { + return parameterContext.getParameter().getType().equals(GzippedFiles.class); + } + + @Override + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + throws ParameterResolutionException { + return getStore(extensionContext).getOrComputeIfAbsent(GzippedFiles.class); + } + + private Store getStore(ExtensionContext extensionContext) { + return extensionContext.getStore(Namespace.create(getClass())); + } + + static class GzippedFiles { + + private final Set created = new HashSet<>(); + + void create(String filePath) { + try { + Resource location = new ClassPathResource("test/", EncodedResourceResolverTests.class); + Resource resource = new FileSystemResource(location.createRelative(filePath).getFile()); + + Path gzFilePath = Paths.get(resource.getFile().getAbsolutePath() + ".gz"); + Files.deleteIfExists(gzFilePath); + + File gzFile = Files.createFile(gzFilePath).toFile(); + GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(gzFile)); + FileCopyUtils.copy(resource.getInputStream(), out); + created.add(gzFile); + } + catch (IOException ex) { + throw new RuntimeException(ex); + } + } + + } + +} diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CachingResourceResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CachingResourceResolverTests.java index ba0d71087f6b..702256459adc 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CachingResourceResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CachingResourceResolverTests.java @@ -22,6 +22,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.springframework.cache.Cache; @@ -29,6 +30,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.mock.web.test.MockHttpServletRequest; +import org.springframework.web.servlet.resource.GzipSupport.GzippedFiles; import static org.assertj.core.api.Assertions.assertThat; @@ -38,6 +40,7 @@ * * @author Rossen Stoyanchev */ +@ExtendWith(GzipSupport.class) public class CachingResourceResolverTests { private Cache cache; @@ -108,10 +111,10 @@ public void resolverUrlPathNoMatch() { } @Test - public void resolveResourceAcceptEncodingInCacheKey() throws IOException { + public void resolveResourceAcceptEncodingInCacheKey(GzippedFiles gzippedFiles) throws IOException { String file = "bar.css"; - EncodedResourceResolverTests.createGzippedFile(file); + gzippedFiles.create(file); // 1. Resolve plain resource diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CssLinkResourceTransformerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CssLinkResourceTransformerTests.java index d49ddd229ee7..b318f50288b1 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CssLinkResourceTransformerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CssLinkResourceTransformerTests.java @@ -23,6 +23,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.springframework.core.io.ClassPathResource; @@ -30,6 +31,7 @@ import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.util.StringUtils; import org.springframework.web.servlet.resource.EncodedResourceResolver.EncodedResource; +import org.springframework.web.servlet.resource.GzipSupport.GzippedFiles; import static org.assertj.core.api.Assertions.assertThat; @@ -41,6 +43,7 @@ * @author Sam Brannen * @since 4.1 */ +@ExtendWith(GzipSupport.class) public class CssLinkResourceTransformerTests { private ResourceTransformerChain transformerChain; @@ -137,9 +140,8 @@ public void transformSkippedForNonCssResource() throws Exception { } @Test - public void transformSkippedForGzippedResource() throws Exception { - - EncodedResourceResolverTests.createGzippedFile("main.css"); + public void transformSkippedForGzippedResource(GzippedFiles gzippedFiles) throws Exception { + gzippedFiles.create("main.css"); this.request = new MockHttpServletRequest("GET", "/static/main.css"); Resource original = new ClassPathResource("test/main.css", getClass()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/EncodedResourceResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/EncodedResourceResolverTests.java index 8e258e13aa64..fdc914ae8583 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/EncodedResourceResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/EncodedResourceResolverTests.java @@ -16,29 +16,21 @@ package org.springframework.web.servlet.resource; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.zip.GZIPOutputStream; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.cache.Cache; import org.springframework.cache.concurrent.ConcurrentMapCache; import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; import org.springframework.http.HttpHeaders; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.util.FileCopyUtils; +import org.springframework.web.servlet.resource.GzipSupport.GzippedFiles; import static org.assertj.core.api.Assertions.assertThat; @@ -48,6 +40,7 @@ * @author Jeremy Grelle * @author Rossen Stoyanchev */ +@ExtendWith(GzipSupport.class) public class EncodedResourceResolverTests { private ResourceResolverChain resolver; @@ -56,27 +49,6 @@ public class EncodedResourceResolverTests { private Cache cache; - - @BeforeAll - public static void createGzippedResources() throws IOException { - createGzippedFile("/js/foo.js"); - createGzippedFile("foo.css"); - } - - static void createGzippedFile(String filePath) throws IOException { - Resource location = new ClassPathResource("test/", EncodedResourceResolverTests.class); - Resource resource = new FileSystemResource(location.createRelative(filePath).getFile()); - - Path gzFilePath = Paths.get(resource.getFile().getAbsolutePath() + ".gz"); - Files.deleteIfExists(gzFilePath); - - File gzFile = Files.createFile(gzFilePath).toFile(); - GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(gzFile)); - FileCopyUtils.copy(resource.getInputStream(), out); - gzFile.deleteOnExit(); - } - - @BeforeEach public void setup() { this.cache = new ConcurrentMapCache("resourceCache"); @@ -98,8 +70,9 @@ public void setup() { @Test - public void resolveGzipped() { + public void resolveGzipped(GzippedFiles gzippedFiles) { String file = "js/foo.js"; + gzippedFiles.create(file); MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Accept-Encoding", "gzip"); Resource actual = this.resolver.resolveResource(request, file, this.locations); @@ -115,7 +88,8 @@ public void resolveGzipped() { } @Test - public void resolveGzippedWithVersion() { + public void resolveGzippedWithVersion(GzippedFiles gzippedFiles) { + gzippedFiles.create("foo.css"); String file = "foo-e36d2e05253c6c7085a91522ce43a0b4.css"; MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Accept-Encoding", "gzip"); @@ -128,9 +102,10 @@ public void resolveGzippedWithVersion() { } @Test - public void resolveFromCacheWithEncodingVariants() { + public void resolveFromCacheWithEncodingVariants(GzippedFiles gzippedFiles) { // 1. Resolve, and cache .gz variant String file = "js/foo.js"; + gzippedFiles.create(file); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/js/foo.js"); request.addHeader("Accept-Encoding", "gzip"); Resource resolved = this.resolver.resolveResource(request, file, this.locations); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipSupport.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipSupport.java new file mode 100644 index 000000000000..598cd38cb4d4 --- /dev/null +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipSupport.java @@ -0,0 +1,94 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.web.servlet.resource; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.Set; +import java.util.zip.GZIPOutputStream; + +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.ExtensionContext.Namespace; +import org.junit.jupiter.api.extension.ExtensionContext.Store; +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.api.extension.ParameterResolutionException; +import org.junit.jupiter.api.extension.ParameterResolver; + +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.io.Resource; +import org.springframework.util.FileCopyUtils; + +class GzipSupport implements AfterEachCallback, ParameterResolver { + + @Override + public void afterEach(ExtensionContext context) throws Exception { + GzippedFiles gzippedFiles = getStore(context).get(GzippedFiles.class, GzippedFiles.class); + if (gzippedFiles != null) { + for (File gzippedFile: gzippedFiles.created) { + gzippedFile.delete(); + } + } + } + + @Override + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + throws ParameterResolutionException { + return parameterContext.getParameter().getType().equals(GzippedFiles.class); + } + + @Override + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + throws ParameterResolutionException { + return getStore(extensionContext).getOrComputeIfAbsent(GzippedFiles.class); + } + + private Store getStore(ExtensionContext extensionContext) { + return extensionContext.getStore(Namespace.create(getClass())); + } + + static class GzippedFiles { + + private final Set created = new HashSet<>(); + + void create(String filePath) { + try { + Resource location = new ClassPathResource("test/", EncodedResourceResolverTests.class); + Resource resource = new FileSystemResource(location.createRelative(filePath).getFile()); + + Path gzFilePath = Paths.get(resource.getFile().getAbsolutePath() + ".gz"); + Files.deleteIfExists(gzFilePath); + + File gzFile = Files.createFile(gzFilePath).toFile(); + GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(gzFile)); + FileCopyUtils.copy(resource.getInputStream(), out); + created.add(gzFile); + } + catch (IOException ex) { + throw new RuntimeException(ex); + } + } + + } + +} diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index cfc6066dc31c..bd0ffdcdb243 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -73,7 +73,7 @@ - + @@ -89,11 +89,15 @@ + + + + From d03ab7953114b39f56ead049d1f66c4f93fa9d0d Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 11 Nov 2019 15:16:07 +0100 Subject: [PATCH 0024/2315] Polish contribution See gh-23970 --- .../web/reactive/resource/GzipSupport.java | 17 ++++++++++------- .../web/servlet/resource/GzipSupport.java | 17 ++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java index 238c0a17e79d..76af75c05b52 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java @@ -31,7 +31,6 @@ import org.junit.jupiter.api.extension.ExtensionContext.Namespace; import org.junit.jupiter.api.extension.ExtensionContext.Store; import org.junit.jupiter.api.extension.ParameterContext; -import org.junit.jupiter.api.extension.ParameterResolutionException; import org.junit.jupiter.api.extension.ParameterResolver; import org.springframework.core.io.ClassPathResource; @@ -39,11 +38,17 @@ import org.springframework.core.io.Resource; import org.springframework.util.FileCopyUtils; +/** + * @author Andy Wilkinson + * @since 5.2.2 + */ class GzipSupport implements AfterEachCallback, ParameterResolver { + private static final Namespace namespace = Namespace.create(GzipSupport.class); + @Override public void afterEach(ExtensionContext context) throws Exception { - GzippedFiles gzippedFiles = getStore(context).get(GzippedFiles.class, GzippedFiles.class); + GzippedFiles gzippedFiles = getStore(context).remove(GzippedFiles.class, GzippedFiles.class); if (gzippedFiles != null) { for (File gzippedFile: gzippedFiles.created) { gzippedFile.delete(); @@ -52,19 +57,17 @@ public void afterEach(ExtensionContext context) throws Exception { } @Override - public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { return parameterContext.getParameter().getType().equals(GzippedFiles.class); } @Override - public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { return getStore(extensionContext).getOrComputeIfAbsent(GzippedFiles.class); } private Store getStore(ExtensionContext extensionContext) { - return extensionContext.getStore(Namespace.create(getClass())); + return extensionContext.getStore(namespace); } static class GzippedFiles { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipSupport.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipSupport.java index 598cd38cb4d4..8c1e7ea46ce1 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipSupport.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipSupport.java @@ -31,7 +31,6 @@ import org.junit.jupiter.api.extension.ExtensionContext.Namespace; import org.junit.jupiter.api.extension.ExtensionContext.Store; import org.junit.jupiter.api.extension.ParameterContext; -import org.junit.jupiter.api.extension.ParameterResolutionException; import org.junit.jupiter.api.extension.ParameterResolver; import org.springframework.core.io.ClassPathResource; @@ -39,11 +38,17 @@ import org.springframework.core.io.Resource; import org.springframework.util.FileCopyUtils; +/** + * @author Andy Wilkinson + * @since 5.2.2 + */ class GzipSupport implements AfterEachCallback, ParameterResolver { + private static final Namespace namespace = Namespace.create(GzipSupport.class); + @Override public void afterEach(ExtensionContext context) throws Exception { - GzippedFiles gzippedFiles = getStore(context).get(GzippedFiles.class, GzippedFiles.class); + GzippedFiles gzippedFiles = getStore(context).remove(GzippedFiles.class, GzippedFiles.class); if (gzippedFiles != null) { for (File gzippedFile: gzippedFiles.created) { gzippedFile.delete(); @@ -52,19 +57,17 @@ public void afterEach(ExtensionContext context) throws Exception { } @Override - public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { return parameterContext.getParameter().getType().equals(GzippedFiles.class); } @Override - public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { return getStore(extensionContext).getOrComputeIfAbsent(GzippedFiles.class); } private Store getStore(ExtensionContext extensionContext) { - return extensionContext.getStore(Namespace.create(getClass())); + return extensionContext.getStore(namespace); } static class GzippedFiles { From 51b43496f41c6fd5745e88b0edcba53a88e4bb84 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 11 Nov 2019 14:31:36 +0000 Subject: [PATCH 0025/2315] Update docs for ASYNC dispatch config Closes gh-23958 --- src/docs/asciidoc/web/webmvc.adoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index 375d5a4dfd08..59fbbc2dbb1a 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -1292,6 +1292,14 @@ a proxy at the boundary of trust should be configured to remove untrusted `Forwa headers that come from the outside. You can also configure the `ForwardedHeaderFilter` with `removeOnly=true`, in which case it removes but does not use the headers. +In order to support <> this filter must be mapped +with `DispatcherType.ASYNC` so that the filter can delay and successfully generate the an +ETag to the end of the last async dispatch. If using Spring Framework's +`AbstractAnnotationConfigDispatcherServletInitializer` (see <>) +all filters are automatically registered for all dispatch types. However if registering +the filter via web.xml or in Spring Boot via a `FilterRegistrationBean` be sure to include +`DispatcherType.ASYNC`. + [[filters-shallow-etag]] @@ -1310,6 +1318,14 @@ This filter has a `writeWeakETag` parameter that configures the filter to write similar to the following: `W/"02a2d595e6ed9a0b24f027f2b63b134d6"` (as defined in https://tools.ietf.org/html/rfc7232#section-2.3[RFC 7232 Section 2.3]). +In order to support <> this filter must be mapped +with `DispatcherType.ASYNC` so that the filter can delay and successfully generate the an +ETag to the end of the last async dispatch. If using Spring Framework's +`AbstractAnnotationConfigDispatcherServletInitializer` (see <>) +all filters are automatically registered for all dispatch types. However if registering +the filter via web.xml or in Spring Boot via a `FilterRegistrationBean` be sure to include +`DispatcherType.ASYNC`. + [[filters-cors]] From 92efe95069c4fc5969e8f4f4f84ee09c426fba5c Mon Sep 17 00:00:00 2001 From: stsypanov Date: Mon, 11 Nov 2019 11:59:50 +0200 Subject: [PATCH 0026/2315] Simplify ConstructorResolver: do not sort intermediate array --- .../beans/factory/support/AutowireUtils.java | 2 +- .../factory/support/ConstructorResolver.java | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java index 67f952567573..50adef4df217 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java @@ -51,7 +51,7 @@ */ abstract class AutowireUtils { - private static final Comparator EXECUTABLE_COMPARATOR = (e1, e2) -> { + public static final Comparator EXECUTABLE_COMPARATOR = (e1, e2) -> { int result = Boolean.compare(Modifier.isPublic(e2.getModifiers()), Modifier.isPublic(e1.getModifiers())); return result != 0 ? result : Integer.compare(e2.getParameterCount(), e1.getParameterCount()); }; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java index cf43c433a26c..d98b72efc732 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java @@ -453,27 +453,27 @@ public BeanWrapper instantiateUsingFactoryMethod( // Try all methods with this name to see if they match the given arguments. factoryClass = ClassUtils.getUserClass(factoryClass); - List candidateList = null; + List candidates = null; if (mbd.isFactoryMethodUnique) { if (factoryMethodToUse == null) { factoryMethodToUse = mbd.getResolvedFactoryMethod(); } if (factoryMethodToUse != null) { - candidateList = Collections.singletonList(factoryMethodToUse); + candidates = Collections.singletonList(factoryMethodToUse); } } - if (candidateList == null) { - candidateList = new ArrayList<>(); + if (candidates == null) { + candidates = new ArrayList<>(); Method[] rawCandidates = getCandidateMethods(factoryClass, mbd); for (Method candidate : rawCandidates) { if (Modifier.isStatic(candidate.getModifiers()) == isStatic && mbd.isFactoryMethod(candidate)) { - candidateList.add(candidate); + candidates.add(candidate); } } } - if (candidateList.size() == 1 && explicitArgs == null && !mbd.hasConstructorArgumentValues()) { - Method uniqueCandidate = candidateList.get(0); + if (candidates.size() == 1 && explicitArgs == null && !mbd.hasConstructorArgumentValues()) { + Method uniqueCandidate = candidates.get(0); if (uniqueCandidate.getParameterCount() == 0) { mbd.factoryMethodToIntrospect = uniqueCandidate; synchronized (mbd.constructorArgumentLock) { @@ -486,8 +486,7 @@ public BeanWrapper instantiateUsingFactoryMethod( } } - Method[] candidates = candidateList.toArray(new Method[0]); - AutowireUtils.sortFactoryMethods(candidates); + candidates.sort(AutowireUtils.EXECUTABLE_COMPARATOR); ConstructorArgumentValues resolvedValues = null; boolean autowiring = (mbd.getResolvedAutowireMode() == AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR); @@ -536,7 +535,7 @@ public BeanWrapper instantiateUsingFactoryMethod( paramNames = pnd.getParameterNames(candidate); } argsHolder = createArgumentArray(beanName, mbd, resolvedValues, bw, - paramTypes, paramNames, candidate, autowiring, candidates.length == 1); + paramTypes, paramNames, candidate, autowiring, candidates.size() == 1); } catch (UnsatisfiedDependencyException ex) { if (logger.isTraceEnabled()) { From d494621ee3d2e0d6c706f401028b0bbd62491495 Mon Sep 17 00:00:00 2001 From: GungnirLaevatain Date: Sun, 10 Nov 2019 22:25:54 +0800 Subject: [PATCH 0027/2315] avoid store all bean name --- .../context/support/ApplicationListenerDetector.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-context/src/main/java/org/springframework/context/support/ApplicationListenerDetector.java b/spring-context/src/main/java/org/springframework/context/support/ApplicationListenerDetector.java index d1ebe7b3d389..d519b98db4ff 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ApplicationListenerDetector.java +++ b/spring-context/src/main/java/org/springframework/context/support/ApplicationListenerDetector.java @@ -59,7 +59,9 @@ public ApplicationListenerDetector(AbstractApplicationContext applicationContext @Override public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) { - this.singletonNames.put(beanName, beanDefinition.isSingleton()); + if (ApplicationListener.class.isAssignableFrom(beanType)) { + this.singletonNames.put(beanName, beanDefinition.isSingleton()); + } } @Override From fc55e66d50041893def2490f8f97dbffc9066454 Mon Sep 17 00:00:00 2001 From: Steven Schlansker Date: Fri, 11 Oct 2019 13:55:50 -0700 Subject: [PATCH 0028/2315] ApplicationListenerMethodAdapter: gracefully handle beans which are actually NullBean Currently, if you have an optional event listener (via a @Bean method returning `null`) this causes the event multicaster to explode violently. Now, we just safely skip it. --- .../ApplicationListenerMethodAdapter.java | 3 ++ .../AnnotationDrivenEventListenerTests.java | 38 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java index e352d69ad348..9cef8e78d427 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java +++ b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java @@ -295,6 +295,9 @@ private boolean shouldHandle(ApplicationEvent event, @Nullable Object[] args) { @Nullable protected Object doInvoke(Object... args) { Object bean = getTargetBean(); + if (bean.equals(null)) { + return null; + } ReflectionUtils.makeAccessible(this.method); try { return this.method.invoke(bean, args); diff --git a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java index ae502c630307..fbe6a67d2e55 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java @@ -16,6 +16,8 @@ package org.springframework.context.event; +import java.io.Closeable; +import java.io.IOException; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -24,12 +26,14 @@ import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import javax.annotation.PostConstruct; +import javax.inject.Inject; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Disabled; @@ -622,6 +626,12 @@ public void listenersReceiveEarlyEvents() { assertThat(listener.order).contains("first", "second", "third"); } + @Test + public void missingBeanDoesntCrash() { + load(MissingEventListener.class); + context.getBean(UseMissingEventListener.class); + context.getBean(ApplicationEventMulticaster.class).multicastEvent(new TestEvent(this)); + } private void load(Class... classes) { List> allClasses = new ArrayList<>(); @@ -1076,4 +1086,32 @@ public String getConversationId() { } } + @Configuration + @Import({UseMissingEventListener.class}) + public static class MissingEventListener { + @Bean + public MyEventListener missing() { + return null; + } + } + + @Component + public static class MyEventListener implements Closeable { + @EventListener + public void hear(TestEvent e) { + throw new AssertionError(); + } + + @Override + public void close() throws IOException {} + } + + public static class UseMissingEventListener { + @Inject + public UseMissingEventListener(Optional notHere) { + if (notHere.isPresent()) { + throw new AssertionError(); + } + } + } } From 6d47e1e0a11a7dacffaaddc841b4f34f37b1e751 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 11 Nov 2019 15:55:06 +0100 Subject: [PATCH 0029/2315] Fix getHeaderPredicate visibility to be declared as protected Closes gh-23976 --- .../web/filter/AbstractRequestLoggingFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.java b/spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.java index 28e41c96e1a1..88f849333aca 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.java @@ -199,7 +199,7 @@ public void setHeaderPredicate(@Nullable Predicate headerPredicate) { * @since 5.2 */ @Nullable - public Predicate getHeaderPredicate() { + protected Predicate getHeaderPredicate() { return this.headerPredicate; } From 990bfd8772fe8261dc6b2e4abf53049bece34c0f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 11 Nov 2019 15:55:26 +0100 Subject: [PATCH 0030/2315] Support for new MySQL 8 error code 3572 Closes gh-23972 --- .../org/springframework/jdbc/support/sql-error-codes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-jdbc/src/main/resources/org/springframework/jdbc/support/sql-error-codes.xml b/spring-jdbc/src/main/resources/org/springframework/jdbc/support/sql-error-codes.xml index 1d0441c5a460..f0ed6570be37 100644 --- a/spring-jdbc/src/main/resources/org/springframework/jdbc/support/sql-error-codes.xml +++ b/spring-jdbc/src/main/resources/org/springframework/jdbc/support/sql-error-codes.xml @@ -205,7 +205,7 @@ 1 - 1205 + 1205,3572 1213 From 5ee990e0456d1d91c760a0c6afd8c6b2fe2e4de0 Mon Sep 17 00:00:00 2001 From: Biju Kunjummen Date: Wed, 21 Nov 2018 13:47:08 -0800 Subject: [PATCH 0031/2315] Use Function.identity Closes gh-2024 --- .../function/server/DefaultServerResponseBuilder.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java index d76651f93ef9..a87b37a5c97f 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java @@ -30,6 +30,7 @@ import java.util.Set; import java.util.function.BiFunction; import java.util.function.Consumer; +import java.util.function.Function; import org.reactivestreams.Publisher; import reactor.core.publisher.Mono; @@ -255,7 +256,7 @@ private Mono initBuilder(T entity, BodyInserter cookies.addAll(this.cookies)) .hints(hints -> hints.putAll(this.hints)) .build() - .map(entityResponse -> entityResponse); + .map(Function.identity()); } @Override @@ -278,7 +279,7 @@ public Mono render(String name, Object... modelAttributes) { .cookies(cookies -> cookies.addAll(this.cookies)) .modelAttributes(modelAttributes) .build() - .map(renderingResponse -> renderingResponse); + .map(Function.identity()); } @Override @@ -289,7 +290,7 @@ public Mono render(String name, Map model) { .cookies(cookies -> cookies.addAll(this.cookies)) .modelAttributes(model) .build() - .map(renderingResponse -> renderingResponse); + .map(Function.identity()); } From 6db8306e4642a0541774272080fad4c6f0baa5ad Mon Sep 17 00:00:00 2001 From: Pat Turner Date: Thu, 22 Nov 2018 19:26:09 +0000 Subject: [PATCH 0032/2315] XpathResultMatcher supports Hamcrest Matcher NodeList Use when xpath result is XPathConstants.NODESET --- .../test/util/XpathExpectationsHelper.java | 12 ++++++++++++ .../test/web/servlet/result/XpathResultMatchers.java | 12 ++++++++++++ .../web/servlet/result/XpathResultMatchersTests.java | 10 ++++++++++ 3 files changed, 34 insertions(+) diff --git a/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java b/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java index 6c5a61cd3f24..4f2e9ab9e469 100644 --- a/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java +++ b/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java @@ -103,6 +103,18 @@ public void assertNode(byte[] content, @Nullable String encoding, final Matcher< MatcherAssert.assertThat("XPath " + this.expression, node, matcher); } + /** + * Parse the content, evaluate the XPath expression as a {@link NodeList}, + * and assert it with the given {@code Matcher}. + */ + public void assertNodeList(byte[] content, @Nullable String encoding, final Matcher matcher) + throws Exception { + + Document document = parseXmlByteArray(content, encoding); + NodeList nodeList = evaluateXpath(document, XPathConstants.NODESET, NodeList.class); + MatcherAssert.assertThat("XPath " + this.getXpathExpression(), nodeList, matcher); + } + /** * Apply the XPath expression and assert the resulting content exists. * @throws Exception if content parsing or expression evaluation fails diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java index 15eebbfcae97..2f195f0b0026 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java @@ -22,6 +22,7 @@ import org.hamcrest.Matcher; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import org.springframework.lang.Nullable; import org.springframework.mock.web.MockHttpServletResponse; @@ -69,6 +70,17 @@ public ResultMatcher node(Matcher matcher) { }; } + /** + * Evaluate the XPath and assert the {@link NodeList} content found with the + * given Hamcrest {@link Matcher}. + */ + public ResultMatcher nodeList(final Matcher matcher) { + return result -> { + MockHttpServletResponse response = result.getResponse(); + this.xpathHelper.assertNodeList(response.getContentAsByteArray(), getDefinedEncoding(response), matcher); + }; + } + /** * Get the response encoding if explicitly defined in the response, {code null} otherwise. */ diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/XpathResultMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/XpathResultMatchersTests.java index f62ca5e4e2db..7cbff19f4095 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/XpathResultMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/XpathResultMatchersTests.java @@ -48,6 +48,16 @@ public void nodeNoMatch() throws Exception { new XpathResultMatchers("/foo/bar", null).node(Matchers.nullValue()).match(getStubMvcResult())); } + @Test + public void nodeList() throws Exception { + new XpathResultMatchers("/foo/bar", null).nodeList(Matchers.notNullValue()).match(getStubMvcResult()); + } + + @Test(expected = AssertionError.class) + public void nodeListNoMatch() throws Exception { + new XpathResultMatchers("/foo/bar", null).nodeList(Matchers.nullValue()).match(getStubMvcResult()); + } + @Test public void exists() throws Exception { new XpathResultMatchers("/foo/bar", null).exists().match(getStubMvcResult()); From 347f16c8ac82339cb4c8f4e30705a9a770c9f873 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 11 Nov 2019 15:03:52 +0000 Subject: [PATCH 0033/2315] Polishing See gh-2023 --- .../test/util/XpathExpectationsHelper.java | 25 ++++++++++--------- .../servlet/result/XpathResultMatchers.java | 21 ++++++++-------- .../result/XpathResultMatchersTests.java | 21 ++++++++-------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java b/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java index 4f2e9ab9e469..028d8b06c5ca 100644 --- a/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java +++ b/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -103,17 +103,18 @@ public void assertNode(byte[] content, @Nullable String encoding, final Matcher< MatcherAssert.assertThat("XPath " + this.expression, node, matcher); } - /** - * Parse the content, evaluate the XPath expression as a {@link NodeList}, - * and assert it with the given {@code Matcher}. - */ - public void assertNodeList(byte[] content, @Nullable String encoding, final Matcher matcher) - throws Exception { - - Document document = parseXmlByteArray(content, encoding); - NodeList nodeList = evaluateXpath(document, XPathConstants.NODESET, NodeList.class); - MatcherAssert.assertThat("XPath " + this.getXpathExpression(), nodeList, matcher); - } + /** + * Parse the content, evaluate the XPath expression as a {@link NodeList}, + * and assert it with the given {@code Matcher}. + * @since 5.2.2 + */ + public void assertNodeList(byte[] content, @Nullable String encoding, final Matcher matcher) + throws Exception { + + Document document = parseXmlByteArray(content, encoding); + NodeList nodeList = evaluateXpath(document, XPathConstants.NODESET, NodeList.class); + MatcherAssert.assertThat("XPath " + this.getXpathExpression(), nodeList, matcher); + } /** * Apply the XPath expression and assert the resulting content exists. diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java index 2f195f0b0026..0010ec9dabea 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java @@ -70,16 +70,17 @@ public ResultMatcher node(Matcher matcher) { }; } - /** - * Evaluate the XPath and assert the {@link NodeList} content found with the - * given Hamcrest {@link Matcher}. - */ - public ResultMatcher nodeList(final Matcher matcher) { - return result -> { - MockHttpServletResponse response = result.getResponse(); - this.xpathHelper.assertNodeList(response.getContentAsByteArray(), getDefinedEncoding(response), matcher); - }; - } + /** + * Evaluate the XPath and assert the {@link NodeList} content found with the + * given Hamcrest {@link Matcher}. + * @since 5.2.2 + */ + public ResultMatcher nodeList(final Matcher matcher) { + return result -> { + MockHttpServletResponse response = result.getResponse(); + this.xpathHelper.assertNodeList(response.getContentAsByteArray(), getDefinedEncoding(response), matcher); + }; + } /** * Get the response encoding if explicitly defined in the response, {code null} otherwise. diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/XpathResultMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/XpathResultMatchersTests.java index 7cbff19f4095..7a61272472ab 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/XpathResultMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/XpathResultMatchersTests.java @@ -43,7 +43,7 @@ public void node() throws Exception { } @Test - public void nodeNoMatch() throws Exception { + public void nodeNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathResultMatchers("/foo/bar", null).node(Matchers.nullValue()).match(getStubMvcResult())); } @@ -53,9 +53,10 @@ public void nodeList() throws Exception { new XpathResultMatchers("/foo/bar", null).nodeList(Matchers.notNullValue()).match(getStubMvcResult()); } - @Test(expected = AssertionError.class) - public void nodeListNoMatch() throws Exception { - new XpathResultMatchers("/foo/bar", null).nodeList(Matchers.nullValue()).match(getStubMvcResult()); + @Test + public void nodeListNoMatch() { + assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> + new XpathResultMatchers("/foo/bar", null).nodeList(Matchers.nullValue()).match(getStubMvcResult())); } @Test @@ -64,7 +65,7 @@ public void exists() throws Exception { } @Test - public void existsNoMatch() throws Exception { + public void existsNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathResultMatchers("/foo/Bar", null).exists().match(getStubMvcResult())); } @@ -75,7 +76,7 @@ public void doesNotExist() throws Exception { } @Test - public void doesNotExistNoMatch() throws Exception { + public void doesNotExistNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathResultMatchers("/foo/bar", null).doesNotExist().match(getStubMvcResult())); } @@ -86,7 +87,7 @@ public void nodeCount() throws Exception { } @Test - public void nodeCountNoMatch() throws Exception { + public void nodeCountNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathResultMatchers("/foo/bar", null).nodeCount(1).match(getStubMvcResult())); } @@ -97,7 +98,7 @@ public void string() throws Exception { } @Test - public void stringNoMatch() throws Exception { + public void stringNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathResultMatchers("/foo/bar[1]", null).string("112").match(getStubMvcResult())); } @@ -108,7 +109,7 @@ public void number() throws Exception { } @Test - public void numberNoMatch() throws Exception { + public void numberNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathResultMatchers("/foo/bar[1]", null).number(111.1).match(getStubMvcResult())); } @@ -119,7 +120,7 @@ public void booleanValue() throws Exception { } @Test - public void booleanValueNoMatch() throws Exception { + public void booleanValueNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathResultMatchers("/foo/bar[2]", null).booleanValue(false).match(getStubMvcResult())); } From 789f6fc188482f0c68180c30422fd00052175ab8 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 11 Nov 2019 16:40:56 +0100 Subject: [PATCH 0034/2315] Add @Nullable annotation to decode method taking DataBuffer Javadoc indicates the returned value can be null. --- .../src/main/java/org/springframework/core/codec/Decoder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/codec/Decoder.java b/spring-core/src/main/java/org/springframework/core/codec/Decoder.java index c4e84383f62c..219e813f028e 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/Decoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/Decoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 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. @@ -88,7 +88,7 @@ Mono decodeToMono(Publisher inputStream, ResolvableType elementTy * @return the decoded value, possibly {@code null} * @since 5.2 */ - @SuppressWarnings("ConstantConditions") + @Nullable default T decode(DataBuffer buffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable Map hints) throws DecodingException { From a7a88371e7906a1c0ab618158fd2b7ec77f31f03 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Thu, 7 Nov 2019 16:10:53 +0100 Subject: [PATCH 0035/2315] Allow for decode method to return null in AbstractJackson2Decoder Prior to this commit, the decoder did not allow for a null value returned from the Jackson object reader. Closes: gh-23935 --- .../codec/json/AbstractJackson2Decoder.java | 2 +- .../client/WebClientIntegrationTests.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java index bf7f68d8b822..8a38d77d4bf4 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java @@ -130,7 +130,7 @@ public Mono decodeToMono(Publisher input, ResolvableType ele @Nullable MimeType mimeType, @Nullable Map hints) { return DataBufferUtils.join(input, this.maxInMemorySize) - .map(dataBuffer -> decode(dataBuffer, elementType, mimeType, hints)); + .flatMap(dataBuffer -> Mono.justOrEmpty(decode(dataBuffer, elementType, mimeType, hints))); } @Override diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java index cb44ad3cd64f..2cbe2f2e3587 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java @@ -29,6 +29,7 @@ import java.time.Duration; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.function.Consumer; import java.util.stream.Stream; @@ -1080,6 +1081,24 @@ void shouldFailWithRelativeUrls(ClientHttpConnector connector) { .verify(Duration.ofSeconds(5)); } + @ParameterizedWebClientTest + void nullJsonResponseShouldBeReadAsEmpty(ClientHttpConnector connector) { + startServer(connector); + + prepareResponse(response -> response + .setResponseCode(200) + .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .setBody("null")); + + Mono result = this.webClient.get() + .uri("/null") + .retrieve() + .bodyToMono(Map.class); + + StepVerifier.create(result) + .verifyComplete(); + } + private void prepareResponse(Consumer consumer) { MockResponse response = new MockResponse(); From c4ec6aea6825011fd0f400d58b3c1fdf5d4fe002 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 11 Nov 2019 17:18:52 +0100 Subject: [PATCH 0036/2315] Fix Checkstyle violations See gh-23784 --- .../ApplicationListenerMethodAdapter.java | 4 +- .../AnnotationDrivenEventListenerTests.java | 48 +++++++++---------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java index 9cef8e78d427..9b6a0619a1a6 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java +++ b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java @@ -295,9 +295,11 @@ private boolean shouldHandle(ApplicationEvent event, @Nullable Object[] args) { @Nullable protected Object doInvoke(Object... args) { Object bean = getTargetBean(); + // Detect package-protected NullBean instance through equals(null) check if (bean.equals(null)) { - return null; + return null; } + ReflectionUtils.makeAccessible(this.method); try { return this.method.invoke(bean, args); diff --git a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java index fbe6a67d2e55..1462146b9bc7 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java @@ -16,8 +16,6 @@ package org.springframework.context.event; -import java.io.Closeable; -import java.io.IOException; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -627,12 +625,13 @@ public void listenersReceiveEarlyEvents() { } @Test - public void missingBeanDoesntCrash() { - load(MissingEventListener.class); - context.getBean(UseMissingEventListener.class); - context.getBean(ApplicationEventMulticaster.class).multicastEvent(new TestEvent(this)); + public void missingListenerBeanIgnored() { + load(MissingEventListener.class); + context.getBean(UseMissingEventListener.class); + context.getBean(ApplicationEventMulticaster.class).multicastEvent(new TestEvent(this)); } + private void load(Class... classes) { List> allClasses = new ArrayList<>(); allClasses.add(BasicConfiguration.class); @@ -1087,31 +1086,32 @@ public String getConversationId() { } @Configuration - @Import({UseMissingEventListener.class}) + @Import(UseMissingEventListener.class) public static class MissingEventListener { - @Bean - public MyEventListener missing() { - return null; - } + + @Bean + public MyEventListener missing() { + return null; + } } @Component - public static class MyEventListener implements Closeable { - @EventListener - public void hear(TestEvent e) { - throw new AssertionError(); - } + public static class MyEventListener { - @Override - public void close() throws IOException {} + @EventListener + public void hear(TestEvent e) { + throw new AssertionError(); + } } public static class UseMissingEventListener { - @Inject - public UseMissingEventListener(Optional notHere) { - if (notHere.isPresent()) { - throw new AssertionError(); - } - } + + @Inject + public UseMissingEventListener(Optional notHere) { + if (notHere.isPresent()) { + throw new AssertionError(); + } + } } + } From fac9ca891a3c4b56c1b2ae9e173a2096de56d6a2 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 11 Nov 2019 17:31:34 +0000 Subject: [PATCH 0037/2315] Fix copy-and-paste error in docs --- src/docs/asciidoc/web/webmvc.adoc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index 59fbbc2dbb1a..4c95a04ba9f1 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -1292,13 +1292,13 @@ a proxy at the boundary of trust should be configured to remove untrusted `Forwa headers that come from the outside. You can also configure the `ForwardedHeaderFilter` with `removeOnly=true`, in which case it removes but does not use the headers. -In order to support <> this filter must be mapped -with `DispatcherType.ASYNC` so that the filter can delay and successfully generate the an -ETag to the end of the last async dispatch. If using Spring Framework's -`AbstractAnnotationConfigDispatcherServletInitializer` (see <>) -all filters are automatically registered for all dispatch types. However if registering -the filter via web.xml or in Spring Boot via a `FilterRegistrationBean` be sure to include -`DispatcherType.ASYNC`. +In order to support <> and error dispatches this +filter should be mapped with `DispatcherType.ASYNC` and also `DispatcherType.ERROR`. +If using Spring Framework's `AbstractAnnotationConfigDispatcherServletInitializer` +(see <>) all filters are automatically registered for all dispatch +types. However if registering the filter via web.xml or in Spring Boot via a +`FilterRegistrationBean` be sure to include `DispatcherType.ASYNC` and +`DispatcherType.ERROR` in addition to `DispatcherType.REQUEST`. From 9cc06454aa2257d693b9488ce2b32d01e708c504 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 12 Nov 2019 11:51:44 +0100 Subject: [PATCH 0038/2315] Restore findAnnotation superclass traversal for java.lang annotations Closes gh-23929 --- .../core/annotation/AnnotationUtils.java | 20 ++++++++++++- .../core/annotation/AnnotationUtilsTests.java | 28 +++++++++++++++---- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index ea41cc80b591..f27e81ac802d 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -374,6 +374,7 @@ public static Set getRepeatableAnnotations(AnnotatedEl RepeatableContainers repeatableContainers = (containerAnnotationType != null ? RepeatableContainers.of(annotationType, containerAnnotationType) : RepeatableContainers.standardRepeatables()); + return MergedAnnotations.from(annotatedElement, SearchStrategy.SUPERCLASS, repeatableContainers) .stream(annotationType) .filter(MergedAnnotationPredicates.firstRunOf(MergedAnnotation::getAggregateIndex)) @@ -455,6 +456,7 @@ public static Set getDeclaredRepeatableAnnotations(Ann RepeatableContainers repeatableContainers = containerAnnotationType != null ? RepeatableContainers.of(annotationType, containerAnnotationType) : RepeatableContainers.standardRepeatables(); + return MergedAnnotations.from(annotatedElement, SearchStrategy.DIRECT, repeatableContainers) .stream(annotationType) .map(MergedAnnotation::withNonMergedAttributes) @@ -484,11 +486,13 @@ public static A findAnnotation( if (annotationType == null) { return null; } + // Shortcut: directly present on the element, with no merging needed? if (AnnotationFilter.PLAIN.matches(annotationType) || AnnotationsScanner.hasPlainJavaAnnotationsOnly(annotatedElement)) { return annotatedElement.getDeclaredAnnotation(annotationType); } + // Exhaustive retrieval of merged annotations... return MergedAnnotations.from(annotatedElement, SearchStrategy.INHERITED_ANNOTATIONS, RepeatableContainers.none()) .get(annotationType).withNonMergedAttributes() @@ -515,11 +519,13 @@ public static A findAnnotation(Method method, @Nullable C if (annotationType == null) { return null; } + // Shortcut: directly present on the element, with no merging needed? if (AnnotationFilter.PLAIN.matches(annotationType) || AnnotationsScanner.hasPlainJavaAnnotationsOnly(method)) { return method.getDeclaredAnnotation(annotationType); } + // Exhaustive retrieval of merged annotations... return MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY, RepeatableContainers.none()) .get(annotationType).withNonMergedAttributes() @@ -553,11 +559,23 @@ public static A findAnnotation(Class clazz, @Nullable if (annotationType == null) { return null; } + // Shortcut: directly present on the element, with no merging needed? if (AnnotationFilter.PLAIN.matches(annotationType) || AnnotationsScanner.hasPlainJavaAnnotationsOnly(clazz)) { - return clazz.getDeclaredAnnotation(annotationType); + A annotation = clazz.getDeclaredAnnotation(annotationType); + if (annotation != null) { + return annotation; + } + // For backwards compatibility, perform a superclass search with plain annotations + // even if not marked as @Inherited: e.g. a findAnnotation search for @Deprecated + Class superclass = clazz.getSuperclass(); + if (superclass == null || superclass == Object.class) { + return null; + } + return findAnnotation(superclass, annotationType); } + // Exhaustive retrieval of merged annotations... return MergedAnnotations.from(clazz, SearchStrategy.TYPE_HIERARCHY, RepeatableContainers.none()) .get(annotationType).withNonMergedAttributes() diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index f0edf9c47400..63c46631bdb7 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -946,24 +946,24 @@ void synthesizeAnnotationFromAnnotationAttributesWithoutAttributeAliases() throw assertThat(synthesizedComponent.value()).as("value from synthesized component: ").isEqualTo("webController"); } - @Test // gh-22702 - void findAnnotationWithRepeatablesElements() { + @Test // gh-22702 + void findAnnotationWithRepeatablesElements() throws Exception { assertThat(AnnotationUtils.findAnnotation(TestRepeatablesClass.class, TestRepeatable.class)).isNull(); assertThat(AnnotationUtils.findAnnotation(TestRepeatablesClass.class, TestRepeatableContainer.class)).isNotNull(); } - @Test // gh-23856 - void findAnnotationFindsRepeatableContainerOnComposedAnnotationMetaAnnotatedWithRepeatableAnnotations() { + @Test // gh-23856 + void findAnnotationFindsRepeatableContainerOnComposedAnnotationMetaAnnotatedWithRepeatableAnnotations() throws Exception { MyRepeatableContainer annotation = AnnotationUtils.findAnnotation(MyRepeatableMeta1And2.class, MyRepeatableContainer.class); assertThat(annotation).isNotNull(); assertThat(annotation.value()).extracting(MyRepeatable::value).containsExactly("meta1", "meta2"); } - @Test // gh-23856 - void findAnnotationFindsRepeatableContainerOnComposedAnnotationMetaAnnotatedWithRepeatableAnnotationsOnMethod() throws NoSuchMethodException { + @Test // gh-23856 + void findAnnotationFindsRepeatableContainerOnComposedAnnotationMetaAnnotatedWithRepeatableAnnotationsOnMethod() throws Exception { Method method = getClass().getDeclaredMethod("methodWithComposedAnnotationMetaAnnotatedWithRepeatableAnnotations"); MyRepeatableContainer annotation = AnnotationUtils.findAnnotation(method, MyRepeatableContainer.class); @@ -971,6 +971,14 @@ void findAnnotationFindsRepeatableContainerOnComposedAnnotationMetaAnnotatedWith assertThat(annotation.value()).extracting(MyRepeatable::value).containsExactly("meta1", "meta2"); } + @Test // gh-23929 + void findDeprecatedAnnotation() throws Exception { + assertThat(getAnnotation(DeprecatedClass.class, Deprecated.class)).isNotNull(); + assertThat(getAnnotation(SubclassOfDeprecatedClass.class, Deprecated.class)).isNull(); + assertThat(findAnnotation(DeprecatedClass.class, Deprecated.class)).isNotNull(); + assertThat(findAnnotation(SubclassOfDeprecatedClass.class, Deprecated.class)).isNotNull(); + } + @SafeVarargs static T[] asArray(T... arr) { @@ -1810,4 +1818,12 @@ interface ContextConfigMismatch { @TestRepeatable("b") static class TestRepeatablesClass { } + + @Deprecated + static class DeprecatedClass { + } + + static class SubclassOfDeprecatedClass extends DeprecatedClass { + } + } From a276c667d1b3a9356bde4b823d289e3678018edf Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 12 Nov 2019 13:48:48 +0100 Subject: [PATCH 0039/2315] Polishing --- src/docs/asciidoc/web/webmvc.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index 4c95a04ba9f1..14e7d8aa7d43 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -1296,7 +1296,7 @@ In order to support <> and error dispatches filter should be mapped with `DispatcherType.ASYNC` and also `DispatcherType.ERROR`. If using Spring Framework's `AbstractAnnotationConfigDispatcherServletInitializer` (see <>) all filters are automatically registered for all dispatch -types. However if registering the filter via web.xml or in Spring Boot via a +types. However if registering the filter via `web.xml` or in Spring Boot via a `FilterRegistrationBean` be sure to include `DispatcherType.ASYNC` and `DispatcherType.ERROR` in addition to `DispatcherType.REQUEST`. @@ -1319,11 +1319,11 @@ similar to the following: `W/"02a2d595e6ed9a0b24f027f2b63b134d6"` (as defined in https://tools.ietf.org/html/rfc7232#section-2.3[RFC 7232 Section 2.3]). In order to support <> this filter must be mapped -with `DispatcherType.ASYNC` so that the filter can delay and successfully generate the an +with `DispatcherType.ASYNC` so that the filter can delay and successfully generate an ETag to the end of the last async dispatch. If using Spring Framework's `AbstractAnnotationConfigDispatcherServletInitializer` (see <>) all filters are automatically registered for all dispatch types. However if registering -the filter via web.xml or in Spring Boot via a `FilterRegistrationBean` be sure to include +the filter via `web.xml` or in Spring Boot via a `FilterRegistrationBean` be sure to include `DispatcherType.ASYNC`. From a26d37b4076715e60833109afb3026eebba9a317 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 12 Nov 2019 14:01:13 +0100 Subject: [PATCH 0040/2315] Polishing --- .../test/util/XpathExpectationsHelper.java | 9 ++++----- .../test/web/servlet/result/XpathResultMatchers.java | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java b/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java index 028d8b06c5ca..bea2c6d87ff3 100644 --- a/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java +++ b/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java @@ -41,7 +41,6 @@ import org.springframework.util.StringUtils; import org.springframework.util.xml.SimpleNamespaceContext; - /** * A helper class for applying assertions via XPath expressions. * @@ -96,7 +95,7 @@ protected XPathExpression getXpathExpression() { * Parse the content, evaluate the XPath expression as a {@link Node}, * and assert it with the given {@code Matcher}. */ - public void assertNode(byte[] content, @Nullable String encoding, final Matcher matcher) + public void assertNode(byte[] content, @Nullable String encoding, Matcher matcher) throws Exception { Node node = evaluateXpath(content, encoding, Node.class); @@ -108,7 +107,7 @@ public void assertNode(byte[] content, @Nullable String encoding, final Matcher< * and assert it with the given {@code Matcher}. * @since 5.2.2 */ - public void assertNodeList(byte[] content, @Nullable String encoding, final Matcher matcher) + public void assertNodeList(byte[] content, @Nullable String encoding, Matcher matcher) throws Exception { Document document = parseXmlByteArray(content, encoding); @@ -122,7 +121,7 @@ public void assertNodeList(byte[] content, @Nullable String encoding, final Matc */ public void exists(byte[] content, @Nullable String encoding) throws Exception { Node node = evaluateXpath(content, encoding, Node.class); - AssertionErrors.assertTrue("XPath " + this.expression + " does not exist", node != null); + AssertionErrors.assertNotNull("XPath " + this.expression + " does not exist", node); } /** @@ -131,7 +130,7 @@ public void exists(byte[] content, @Nullable String encoding) throws Exception { */ public void doesNotExist(byte[] content, @Nullable String encoding) throws Exception { Node node = evaluateXpath(content, encoding, Node.class); - AssertionErrors.assertTrue("XPath " + this.expression + " exists", node == null); + AssertionErrors.assertNull("XPath " + this.expression + " exists", node); } /** diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java index 0010ec9dabea..e6025e1b3c07 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java @@ -75,7 +75,7 @@ public ResultMatcher node(Matcher matcher) { * given Hamcrest {@link Matcher}. * @since 5.2.2 */ - public ResultMatcher nodeList(final Matcher matcher) { + public ResultMatcher nodeList(Matcher matcher) { return result -> { MockHttpServletResponse response = result.getResponse(); this.xpathHelper.assertNodeList(response.getContentAsByteArray(), getDefinedEncoding(response), matcher); From 879b2df052d64eb552fccbf9c82195fb134c7783 Mon Sep 17 00:00:00 2001 From: Johannes Teklote Date: Tue, 12 Nov 2019 14:31:42 +0100 Subject: [PATCH 0041/2315] queryParam options for MockMVC requeusts See gh-23296 --- .../MockHttpServletRequestBuilder.java | 51 ++++++++++++++++++- .../MockHttpServletRequestBuilderTests.java | 42 +++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java index 9b6cf1c8fdea..d88acf31f2df 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.stream.Collectors; import javax.servlet.ServletContext; import javax.servlet.ServletRequest; @@ -100,6 +101,9 @@ public class MockHttpServletRequestBuilder @Nullable private Boolean secure; + @Nullable + private String queryString = ""; + @Nullable private Principal principal; @@ -354,6 +358,40 @@ public MockHttpServletRequestBuilder params(MultiValueMap params return this; } + /** + * Add a query parameter to the {@link MockHttpServletRequest}. + *

If called more than once, new values get added to existing ones. + * @param name the parameter name + * @param values one or more values + */ + public MockHttpServletRequestBuilder queryParam(String name, String... values) { + param(name, values); + String builder = Arrays.stream(values).map(value -> UriUtils.encode(name, StandardCharsets.UTF_8) + + ((value != null) ? ("=" + UriUtils.encode(value, StandardCharsets.UTF_8)) : "") + "&" + ).collect(Collectors.joining()); + queryString += builder; + return this; + } + + /** + * Add a map of query parameters to the {@link MockHttpServletRequest}, + * for example when testing a form submission. + *

If called more than once, new values get added to existing ones. + * @param params the parameters to add + * @since 4.2.4 + */ + public MockHttpServletRequestBuilder queryParams(MultiValueMap params) { + params(params); + StringBuilder builder = new StringBuilder(); + params.forEach((key, values) -> values.forEach(value -> { + builder.append(UriUtils.encode(key, StandardCharsets.UTF_8)) + .append(((value != null) ? ("=" + UriUtils.encode(value, StandardCharsets.UTF_8)) : "")) + .append("&"); + })); + queryString += builder.toString(); + return this; + } + /** * Add the given cookies to the request. Cookies are always added. * @param cookies the cookies to add @@ -636,13 +674,24 @@ public final MockHttpServletRequest buildRequest(ServletContext servletContext) request.setQueryString(this.url.getRawQuery()); } addRequestParams(request, UriComponentsBuilder.fromUri(this.url).build().getQueryParams()); - this.parameters.forEach((name, values) -> { for (String value : values) { request.addParameter(name, value); } }); + StringBuilder queryBuilder = new StringBuilder(); + if (request.getQueryString() != null) { + queryBuilder.append(request.getQueryString()); + } + if (this.queryString != null && !"".equals(this.queryString)) { + if (queryBuilder.length() > 0) { + queryBuilder.append("&"); + } + queryBuilder.append(this.queryString, 0, this.queryString.length() - 1); + request.setQueryString(queryBuilder.toString()); + } + if (this.content != null && this.content.length > 0) { String requestContentType = request.getContentType(); if (requestContentType != null) { diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java index 22362a33d167..34c29ce4b3c6 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java @@ -21,6 +21,7 @@ import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.security.Principal; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -234,6 +235,47 @@ public void requestParameterFromQueryList() { assertThat(request.getParameter("foo[1]")).isEqualTo("baz"); } + @Test + public void requestParameterToQuery() { + this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/"); + this.builder.queryParam("foo", "bar"); + this.builder.queryParam("foo", "baz"); + + MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); + + assertThat(request.getParameterMap().get("foo")).isEqualTo(new String[] {"bar", "baz"}); + assertThat(request.getQueryString()).isEqualTo("foo=bar&foo=baz"); + } + + @Test + public void requestParameterMapToQuery() { + this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/"); + MultiValueMap queryParams = new LinkedMultiValueMap<>(); + List values = new ArrayList<>(); + values.add("bar"); + values.add("baz"); + queryParams.put("foo", values); + this.builder.queryParams(queryParams); + + MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); + + assertThat(request.getParameterMap().get("foo")).isEqualTo(new String[] {"bar", "baz"}); + assertThat(request.getQueryString()).isEqualTo("foo=bar&foo=baz"); + } + + @Test + public void requestParameterToQueryList() { + this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/"); + this.builder.queryParam("foo[0]", "bar"); + this.builder.queryParam("foo[1]", "baz"); + + MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); + + assertThat(request.getQueryString()).isEqualTo("foo%5B0%5D=bar&foo%5B1%5D=baz"); + assertThat(request.getParameter("foo[0]")).isEqualTo("bar"); + assertThat(request.getParameter("foo[1]")).isEqualTo("baz"); + } + @Test public void requestParameterFromQueryWithEncoding() { this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/?foo={value}", "bar=baz"); From 16c7a40c5399ca282f0255282c7bb5d3df027dec Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 12 Nov 2019 16:12:30 +0000 Subject: [PATCH 0042/2315] Minor refactoring See gh-23296 --- .../MockHttpServletRequestBuilder.java | 91 +++++++++++-------- .../MockHttpServletRequestBuilderTests.java | 6 +- 2 files changed, 54 insertions(+), 43 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java index d88acf31f2df..6c681e547996 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.stream.Collectors; import javax.servlet.ServletContext; import javax.servlet.ServletRequest; @@ -101,9 +100,6 @@ public class MockHttpServletRequestBuilder @Nullable private Boolean secure; - @Nullable - private String queryString = ""; - @Nullable private Principal principal; @@ -123,6 +119,8 @@ public class MockHttpServletRequestBuilder private final MultiValueMap parameters = new LinkedMultiValueMap<>(); + private final MultiValueMap queryParams = new LinkedMultiValueMap<>(); + private final List cookies = new ArrayList<>(); private final List locales = new ArrayList<>(); @@ -252,6 +250,10 @@ public MockHttpServletRequestBuilder characterEncoding(String encoding) { /** * Set the request body. + *

If content is provided and {@link #contentType(MediaType)} is set to + * {@code application/x-www-form-urlencoded}, the content will be parsed + * and used to populate the {@link #param(String, String...) request + * parameters} map. * @param content the body content */ public MockHttpServletRequestBuilder content(byte[] content) { @@ -261,6 +263,10 @@ public MockHttpServletRequestBuilder content(byte[] content) { /** * Set the request body as a UTF-8 String. + *

If content is provided and {@link #contentType(MediaType)} is set to + * {@code application/x-www-form-urlencoded}, the content will be parsed + * and used to populate the {@link #param(String, String...) request + * parameters} map. * @param content the body content */ public MockHttpServletRequestBuilder content(String content) { @@ -270,6 +276,10 @@ public MockHttpServletRequestBuilder content(String content) { /** * Set the 'Content-Type' header of the request. + *

If content is provided and {@code contentType} is set to + * {@code application/x-www-form-urlencoded}, the content will be parsed + * and used to populate the {@link #param(String, String...) request + * parameters} map. * @param contentType the content type */ public MockHttpServletRequestBuilder contentType(MediaType contentType) { @@ -332,8 +342,18 @@ public MockHttpServletRequestBuilder headers(HttpHeaders httpHeaders) { } /** - * Add a request parameter to the {@link MockHttpServletRequest}. - *

If called more than once, new values get added to existing ones. + * Add a request parameter to {@link MockHttpServletRequest#getParameterMap()}. + *

In the Servlet API, a request parameter may be parsed from the query + * string and/or from the body of an {@code application/x-www-form-urlencoded} + * request. This method simply adds to the request parameter map. You may + * also use add Servlet request parameters by specifying the query or form + * data through one of the following: + *

    + *
  • Supply a URL with a query to {@link MockMvcRequestBuilders}. + *
  • Add query params via {@link #queryParam} or {@link #queryParams}. + *
  • Provide {@link #content} with {@link #contentType} + * {@code application/x-www-form-urlencoded}. + *
* @param name the parameter name * @param values one or more values */ @@ -343,9 +363,7 @@ public MockHttpServletRequestBuilder param(String name, String... values) { } /** - * Add a map of request parameters to the {@link MockHttpServletRequest}, - * for example when testing a form submission. - *

If called more than once, new values get added to existing ones. + * Variant of {@link #param(String, String...)} with a {@link MultiValueMap}. * @param params the parameters to add * @since 4.2.4 */ @@ -359,36 +377,29 @@ public MockHttpServletRequestBuilder params(MultiValueMap params } /** - * Add a query parameter to the {@link MockHttpServletRequest}. - *

If called more than once, new values get added to existing ones. + * Append to the query string and also add to the + * {@link #param(String, String...) request parameters} map. The parameter + * name and value are encoded when they are added to the query string. * @param name the parameter name * @param values one or more values + * @since 5.2.2 */ public MockHttpServletRequestBuilder queryParam(String name, String... values) { param(name, values); - String builder = Arrays.stream(values).map(value -> UriUtils.encode(name, StandardCharsets.UTF_8) + - ((value != null) ? ("=" + UriUtils.encode(value, StandardCharsets.UTF_8)) : "") + "&" - ).collect(Collectors.joining()); - queryString += builder; + this.queryParams.addAll(name, Arrays.asList(values)); return this; } /** - * Add a map of query parameters to the {@link MockHttpServletRequest}, - * for example when testing a form submission. - *

If called more than once, new values get added to existing ones. + * Append to the query string and also add to the + * {@link #params(MultiValueMap)} request parameters} map. The parameter + * name and value are encoded when they are added to the query string. * @param params the parameters to add - * @since 4.2.4 + * @since 5.2.2 */ public MockHttpServletRequestBuilder queryParams(MultiValueMap params) { params(params); - StringBuilder builder = new StringBuilder(); - params.forEach((key, values) -> values.forEach(value -> { - builder.append(UriUtils.encode(key, StandardCharsets.UTF_8)) - .append(((value != null) ? ("=" + UriUtils.encode(value, StandardCharsets.UTF_8)) : "")) - .append("&"); - })); - queryString += builder.toString(); + this.queryParams.addAll(params); return this; } @@ -581,6 +592,12 @@ public Object merge(@Nullable Object parent) { this.parameters.put(paramName, entry.getValue()); } } + for (Map.Entry> entry : parentBuilder.queryParams.entrySet()) { + String paramName = entry.getKey(); + if (!this.queryParams.containsKey(paramName)) { + this.queryParams.put(paramName, entry.getValue()); + } + } for (Cookie cookie : parentBuilder.cookies) { if (!containsCookie(cookie)) { this.cookies.add(cookie); @@ -670,28 +687,22 @@ public final MockHttpServletRequest buildRequest(ServletContext servletContext) } }); - if (this.url.getRawQuery() != null) { - request.setQueryString(this.url.getRawQuery()); + String query = this.url.getRawQuery(); + if (!this.queryParams.isEmpty()) { + String s = UriComponentsBuilder.newInstance().queryParams(this.queryParams).build().encode().getQuery(); + query = StringUtils.isEmpty(query) ? s : query + "&" + s; + } + if (query != null) { + request.setQueryString(query); } addRequestParams(request, UriComponentsBuilder.fromUri(this.url).build().getQueryParams()); + this.parameters.forEach((name, values) -> { for (String value : values) { request.addParameter(name, value); } }); - StringBuilder queryBuilder = new StringBuilder(); - if (request.getQueryString() != null) { - queryBuilder.append(request.getQueryString()); - } - if (this.queryString != null && !"".equals(this.queryString)) { - if (queryBuilder.length() > 0) { - queryBuilder.append("&"); - } - queryBuilder.append(this.queryString, 0, this.queryString.length() - 1); - request.setQueryString(queryBuilder.toString()); - } - if (this.content != null && this.content.length > 0) { String requestContentType = request.getContentType(); if (requestContentType != null) { diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java index 34c29ce4b3c6..405bfdb46d72 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java @@ -236,7 +236,7 @@ public void requestParameterFromQueryList() { } @Test - public void requestParameterToQuery() { + public void queryParameter() { this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/"); this.builder.queryParam("foo", "bar"); this.builder.queryParam("foo", "baz"); @@ -248,7 +248,7 @@ public void requestParameterToQuery() { } @Test - public void requestParameterMapToQuery() { + public void queryParameterMap() { this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/"); MultiValueMap queryParams = new LinkedMultiValueMap<>(); List values = new ArrayList<>(); @@ -264,7 +264,7 @@ public void requestParameterMapToQuery() { } @Test - public void requestParameterToQueryList() { + public void queryParameterList() { this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/"); this.builder.queryParam("foo[0]", "bar"); this.builder.queryParam("foo[1]", "baz"); From 4bbf2d5785a3b81e7d0de536a819e2774f2b41c2 Mon Sep 17 00:00:00 2001 From: GungnirLaevatain Date: Tue, 12 Nov 2019 23:34:53 +0800 Subject: [PATCH 0043/2315] polish --- .../support/AbstractAutowireCapableBeanFactory.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index 35d0df235c27..4990f4fdd591 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -1381,24 +1381,17 @@ protected void populateBean(String beanName, RootBeanDefinition mbd, @Nullable B // Give any InstantiationAwareBeanPostProcessors the opportunity to modify the // state of the bean before properties are set. This can be used, for example, // to support styles of field injection. - boolean continueWithPropertyPopulation = true; - if (!mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) { for (BeanPostProcessor bp : getBeanPostProcessors()) { if (bp instanceof InstantiationAwareBeanPostProcessor) { InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor) bp; if (!ibp.postProcessAfterInstantiation(bw.getWrappedInstance(), beanName)) { - continueWithPropertyPopulation = false; - break; + return; } } } } - if (!continueWithPropertyPopulation) { - return; - } - PropertyValues pvs = (mbd.hasPropertyValues() ? mbd.getPropertyValues() : null); int resolvedAutowireMode = mbd.getResolvedAutowireMode(); @@ -1513,7 +1506,7 @@ protected void autowireByType( if (Object.class != pd.getPropertyType()) { MethodParameter methodParam = BeanUtils.getWriteMethodParameter(pd); // Do not allow eager init for type matching in case of a prioritized post-processor. - boolean eager = !PriorityOrdered.class.isInstance(bw.getWrappedInstance()); + boolean eager = !(bw.getWrappedInstance() instanceof PriorityOrdered); DependencyDescriptor desc = new AutowireByTypeDependencyDescriptor(methodParam, eager); Object autowiredArgument = resolveDependency(desc, beanName, autowiredBeanNames, converter); if (autowiredArgument != null) { From f4c847b7231b349749794833b15ff9b4b6ae6fed Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 12 Nov 2019 17:32:40 +0000 Subject: [PATCH 0044/2315] MockHttpServletRequestBuilder sets content-length Closes gh-23978 --- .../web/servlet/request/MockHttpServletRequestBuilder.java | 7 +++++++ .../request/MockHttpServletRequestBuilderTests.java | 1 + 2 files changed, 8 insertions(+) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java index 6c681e547996..c5b527b4adab 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java @@ -687,6 +687,13 @@ public final MockHttpServletRequest buildRequest(ServletContext servletContext) } }); + if (!ObjectUtils.isEmpty(this.content) && + !this.headers.containsKey(HttpHeaders.CONTENT_LENGTH) && + !this.headers.containsKey(HttpHeaders.TRANSFER_ENCODING)) { + + request.addHeader(HttpHeaders.CONTENT_LENGTH, this.content.length); + } + String query = this.url.getRawQuery(); if (!this.queryParams.isEmpty()) { String s = UriComponentsBuilder.newInstance().queryParams(this.queryParams).build().encode().getQuery(); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java index 405bfdb46d72..ae111d7877b6 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java @@ -389,6 +389,7 @@ public void body() throws IOException { byte[] result = FileCopyUtils.copyToByteArray(request.getInputStream()); assertThat(result).isEqualTo(body); + assertThat(request.getContentLength()).isEqualTo(body.length); } @Test From f61d728db9437cf689f942e624a47b4c4c256db0 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 13 Nov 2019 13:48:08 +0100 Subject: [PATCH 0045/2315] Fallback Locale other than the system Locale through setDefaultLocale Closes gh-23977 --- .../AbstractResourceBasedMessageSource.java | 42 ++++++++++++++++++- ...ReloadableResourceBundleMessageSource.java | 16 +++++-- .../support/ResourceBundleMessageSource.java | 3 +- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java index d9b09d50cf95..ee0eb6cde85a 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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,6 +17,7 @@ package org.springframework.context.support; import java.util.LinkedHashSet; +import java.util.Locale; import java.util.Set; import org.springframework.lang.Nullable; @@ -43,6 +44,9 @@ public abstract class AbstractResourceBasedMessageSource extends AbstractMessage private boolean fallbackToSystemLocale = true; + @Nullable + private Locale defaultLocale; + private long cacheMillis = -1; @@ -143,6 +147,7 @@ protected String getDefaultEncoding() { * {@code java.util.ResourceBundle}. However, this is often not desirable * in an application server environment, where the system Locale is not relevant * to the application at all: set this flag to "false" in such a scenario. + * @see #setDefaultLocale */ public void setFallbackToSystemLocale(boolean fallbackToSystemLocale) { this.fallbackToSystemLocale = fallbackToSystemLocale; @@ -152,11 +157,46 @@ public void setFallbackToSystemLocale(boolean fallbackToSystemLocale) { * Return whether to fall back to the system Locale if no files for a specific * Locale have been found. * @since 4.3 + * @deprecated as of 5.2.2, in favor of {@link #getDefaultLocale()} */ + @Deprecated protected boolean isFallbackToSystemLocale() { return this.fallbackToSystemLocale; } + /** + * Specify a default Locale to fall back to, as an alternative to falling back + * to the system Locale. + *

Default is to fall back to the system Locale. You may override this with + * a locally specified default Locale here, or enforce no fallback locale at all + * through disabling {@link #setFallbackToSystemLocale "fallbackToSystemLocale"}. + * @since 5.2.2 + * @see #setFallbackToSystemLocale + * @see #getDefaultLocale() + */ + public void setDefaultLocale(@Nullable Locale defaultLocale) { + this.defaultLocale = defaultLocale; + } + + /** + * Determine a default Locale to fall back to: either a locally specified default + * Locale or the system Locale, or {@code null} for no fallback locale at all. + * @since 5.2.2 + * @see #setDefaultLocale + * @see #setFallbackToSystemLocale + * @see Locale#getDefault() + */ + @Nullable + protected Locale getDefaultLocale() { + if (this.defaultLocale != null) { + return this.defaultLocale; + } + if (this.fallbackToSystemLocale) { + return Locale.getDefault(); + } + return null; + } + /** * Set the number of seconds to cache loaded properties files. *

    diff --git a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java index d65869b14f65..eb8438793b11 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -237,6 +237,7 @@ protected PropertiesHolder getMergedProperties(Locale locale) { if (mergedHolder != null) { return mergedHolder; } + Properties mergedProps = newProperties(); long latestTimestamp = -1; String[] basenames = StringUtils.toStringArray(getBasenameSet()); @@ -253,6 +254,7 @@ protected PropertiesHolder getMergedProperties(Locale locale) { } } } + mergedHolder = new PropertiesHolder(mergedProps, latestTimestamp); PropertiesHolder existing = this.cachedMergedProperties.putIfAbsent(locale, mergedHolder); if (existing != null) { @@ -279,10 +281,15 @@ protected List calculateAllFilenames(String basename, Locale locale) { return filenames; } } + + // Filenames for given Locale List filenames = new ArrayList<>(7); filenames.addAll(calculateFilenamesForLocale(basename, locale)); - if (isFallbackToSystemLocale() && !locale.equals(Locale.getDefault())) { - List fallbackFilenames = calculateFilenamesForLocale(basename, Locale.getDefault()); + + // Filenames for default Locale, if any + Locale defaultLocale = getDefaultLocale(); + if (defaultLocale != null && !defaultLocale.equals(locale)) { + List fallbackFilenames = calculateFilenamesForLocale(basename, defaultLocale); for (String fallbackFilename : fallbackFilenames) { if (!filenames.contains(fallbackFilename)) { // Entry for fallback locale that isn't already in filenames list. @@ -290,7 +297,10 @@ protected List calculateAllFilenames(String basename, Locale locale) { } } } + + // Filename for default bundle file filenames.add(basename); + if (localeMap == null) { localeMap = new ConcurrentHashMap<>(); Map> existing = this.cachedFilenames.putIfAbsent(basename, localeMap); diff --git a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java index af5a1f071ab1..6df9cdbf9980 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java @@ -461,7 +461,8 @@ public ResourceBundle newBundle(String baseName, Locale locale, String format, C @Override @Nullable public Locale getFallbackLocale(String baseName, Locale locale) { - return (isFallbackToSystemLocale() ? super.getFallbackLocale(baseName, locale) : null); + Locale defaultLocale = getDefaultLocale(); + return (defaultLocale != null && !defaultLocale.equals(locale) ? defaultLocale : null); } @Override From f2b3953d765782f5bc8bc0027634a32bd2aab5c8 Mon Sep 17 00:00:00 2001 From: stsypanov Date: Mon, 11 Nov 2019 18:52:56 +0200 Subject: [PATCH 0046/2315] Use array.clone() instead of manual array creation --- .../aop/framework/ReflectiveMethodInvocation.java | 3 +-- .../main/java/org/springframework/mail/SimpleMailMessage.java | 4 +--- .../java/org/springframework/cache/interceptor/SimpleKey.java | 3 +-- .../org/springframework/util/FastByteArrayOutputStream.java | 4 +--- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java b/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java index 0eef701a932f..1db34223cb41 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java @@ -212,8 +212,7 @@ public MethodInvocation invocableClone() { Object[] cloneArguments = this.arguments; if (this.arguments.length > 0) { // Build an independent copy of the arguments array. - cloneArguments = new Object[this.arguments.length]; - System.arraycopy(this.arguments, 0, cloneArguments, 0, this.arguments.length); + cloneArguments = this.arguments.clone(); } return invocableClone(cloneArguments); } diff --git a/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java b/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java index 303836769542..95268a2993e0 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java +++ b/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java @@ -276,9 +276,7 @@ private static String[] copyOrNull(@Nullable String[] state) { } private static String[] copy(String[] state) { - String[] copy = new String[state.length]; - System.arraycopy(state, 0, copy, 0, state.length); - return copy; + return state.clone(); } } diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/SimpleKey.java b/spring-context/src/main/java/org/springframework/cache/interceptor/SimpleKey.java index 3cc0474db74c..da97487d4a4d 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/SimpleKey.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/SimpleKey.java @@ -48,8 +48,7 @@ public class SimpleKey implements Serializable { */ public SimpleKey(Object... elements) { Assert.notNull(elements, "Elements must not be null"); - this.params = new Object[elements.length]; - System.arraycopy(elements, 0, this.params, 0, elements.length); + this.params = elements.clone(); this.hashCode = Arrays.deepHashCode(this.params); } diff --git a/spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java b/spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java index 9507fb3ed021..f8e484fae718 100644 --- a/spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java +++ b/spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java @@ -206,9 +206,7 @@ public byte[] toByteArrayUnsafe() { */ public byte[] toByteArray() { byte[] bytesUnsafe = toByteArrayUnsafe(); - byte[] ret = new byte[bytesUnsafe.length]; - System.arraycopy(bytesUnsafe, 0, ret, 0, bytesUnsafe.length); - return ret; + return bytesUnsafe.clone(); } /** From 7646895fd471601c364ab5bdcad17484d90a46b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Wed, 13 Nov 2019 14:22:11 +0100 Subject: [PATCH 0047/2315] Support Kotlin synthetic classes in MethodParameter and SpEL Closes gh-23812 --- .../springframework/core/MethodParameter.java | 24 +++++++++++----- spring-expression/spring-expression.gradle | 4 +++ .../expression/spel/KotlinSpelReproTests.kt | 28 +++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 spring-expression/src/test/kotlin/org/springframework/expression/spel/KotlinSpelReproTests.kt diff --git a/spring-core/src/main/java/org/springframework/core/MethodParameter.java b/spring-core/src/main/java/org/springframework/core/MethodParameter.java index f01250022460..040819bea667 100644 --- a/spring-core/src/main/java/org/springframework/core/MethodParameter.java +++ b/spring-core/src/main/java/org/springframework/core/MethodParameter.java @@ -908,9 +908,14 @@ else if (ctor != null) { * functions via Kotlin reflection. */ static private Type getGenericReturnType(Method method) { - KFunction function = ReflectJvmMapping.getKotlinFunction(method); - if (function != null && function.isSuspend()) { - return ReflectJvmMapping.getJavaType(function.getReturnType()); + try { + KFunction function = ReflectJvmMapping.getKotlinFunction(method); + if (function != null && function.isSuspend()) { + return ReflectJvmMapping.getJavaType(function.getReturnType()); + } + } + catch (UnsupportedOperationException ex) { + // probably a synthetic class - let's use java reflection instead } return method.getGenericReturnType(); } @@ -920,10 +925,15 @@ static private Type getGenericReturnType(Method method) { * functions via Kotlin reflection. */ static private Class getReturnType(Method method) { - KFunction function = ReflectJvmMapping.getKotlinFunction(method); - if (function != null && function.isSuspend()) { - Type paramType = ReflectJvmMapping.getJavaType(function.getReturnType()); - return ResolvableType.forType(paramType).resolve(method.getReturnType()); + try { + KFunction function = ReflectJvmMapping.getKotlinFunction(method); + if (function != null && function.isSuspend()) { + Type paramType = ReflectJvmMapping.getJavaType(function.getReturnType()); + return ResolvableType.forType(paramType).resolve(method.getReturnType()); + } + } + catch (UnsupportedOperationException ex) { + // probably a synthetic class - let's use java reflection instead } return method.getReturnType(); } diff --git a/spring-expression/spring-expression.gradle b/spring-expression/spring-expression.gradle index 5dbf54e594d0..432179877a9d 100644 --- a/spring-expression/spring-expression.gradle +++ b/spring-expression/spring-expression.gradle @@ -1,5 +1,9 @@ description = "Spring Expression Language (SpEL)" +apply plugin: "kotlin" + dependencies { compile(project(":spring-core")) + testCompile("org.jetbrains.kotlin:kotlin-reflect") + testCompile("org.jetbrains.kotlin:kotlin-stdlib") } diff --git a/spring-expression/src/test/kotlin/org/springframework/expression/spel/KotlinSpelReproTests.kt b/spring-expression/src/test/kotlin/org/springframework/expression/spel/KotlinSpelReproTests.kt new file mode 100644 index 000000000000..12a01978ac73 --- /dev/null +++ b/spring-expression/src/test/kotlin/org/springframework/expression/spel/KotlinSpelReproTests.kt @@ -0,0 +1,28 @@ +package org.springframework.expression.spel + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.springframework.expression.ExpressionParser +import org.springframework.expression.spel.standard.SpelExpressionParser + +class KotlinSpelReproTests { + + private val parser: ExpressionParser = SpelExpressionParser() + + private val context = TestScenarioCreator.getTestEvaluationContext() + + + @Test + fun `gh-23812 SpEL cannot invoke Kotlin synthetic classes`() { + val expr = parser.parseExpression("new org.springframework.expression.spel.KotlinSpelReproTests\$Config().kotlinSupplier().invoke()") + assertThat(expr.getValue(context)).isEqualTo("test") + } + + class Config { + + fun kotlinSupplier(): () -> String { + return { "test" } + } + + } +} From 4e5ae54417bbdf1e2e0f37ae3663151df39a70f4 Mon Sep 17 00:00:00 2001 From: YuDongYing <987425112@qq.com> Date: Tue, 5 Nov 2019 16:44:23 +0800 Subject: [PATCH 0048/2315] Fix schemaZip Gradle task on MS Windows Prior to this commit, the schemaZip Gradle task failed to find Spring schema files on MS Windows due to path separators hard coded to forward slashes that are not compatible with the Windows operating system. Consequently, a full build failed on Windows since the distZip task was not able to locate the zipped schema archive that the schemaZip task failed to create. This commit fixes this by updating the schemaZip task to search for schema files using backslashes as well as forward slashes. Closes gh-23933 --- gradle/docs.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/docs.gradle b/gradle/docs.gradle index 51b51252e860..fd83d77f5f1c 100644 --- a/gradle/docs.gradle +++ b/gradle/docs.gradle @@ -175,14 +175,14 @@ task schemaZip(type: Zip) { def Properties schemas = new Properties(); module.sourceSets.main.resources.find { - it.path.endsWith("META-INF/spring.schemas") + (it.path.endsWith("META-INF/spring.schemas") || it.path.endsWith("META-INF\\spring.schemas")) }?.withInputStream { schemas.load(it) } for (def key : schemas.keySet()) { def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, '$1') assert shortName != key File xsdFile = module.sourceSets.main.resources.find { - it.path.endsWith(schemas.get(key)) + (it.path.endsWith(schemas.get(key)) || it.path.endsWith(schemas.get(key).replaceAll('\\/','\\\\'))) } assert xsdFile != null into (shortName) { From 8bb165e55c68a50997bb1d5edc5822e82de5c94f Mon Sep 17 00:00:00 2001 From: JohnGrib Date: Wed, 13 Nov 2019 14:57:23 +0900 Subject: [PATCH 0049/2315] Fix typo in EventSourceTransportHandler Closes gh-23984 * https://github.com/spring-projects/spring-framework/blob/3a0f309e2c9fdbbf7fb2d348be861528177f8555/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java#L24 * https://github.com/spring-projects/spring-framework/blob/3a0f309e2c9fdbbf7fb2d348be861528177f8555/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java#L88 * https://github.com/spring-projects/spring-framework/blob/ef14d76d3637abeb31edd8a22031c21f9445efef/spring-web/src/main/java/org/springframework/http/codec/ServerCodecConfigurer.java#L94 * https://github.com/spring-projects/spring-framework/blob/3a0f309e2c9fdbbf7fb2d348be861528177f8555/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java#L33 --- .../sockjs/transport/handler/EventSourceTransportHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java index 4cc8da5d2e61..b4ee97198a25 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java @@ -30,7 +30,7 @@ import org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession; /** - * A TransportHandler for sending messages via Server-Sent events: + * A TransportHandler for sending messages via Server-Sent Events: * https://dev.w3.org/html5/eventsource/. * * @author Rossen Stoyanchev From 91ec274b10aedd54eb63e3c67e0978c56cc81e28 Mon Sep 17 00:00:00 2001 From: jerzykrlk Date: Mon, 20 Aug 2018 21:15:02 +0200 Subject: [PATCH 0050/2315] SPR-17130 http error details in the exception message --- .../DefaultHttpErrorDetailsExtractor.java | 138 ++++++++++++++++++ .../client/DefaultResponseErrorHandler.java | 59 +++++++- .../web/client/HttpClientErrorException.java | 104 ++++++++----- .../web/client/HttpErrorDetailsExtractor.java | 33 +++++ .../web/client/HttpServerErrorException.java | 55 ++++--- .../web/client/HttpStatusCodeException.java | 26 +++- .../client/RestClientResponseException.java | 40 +++++ .../UnknownHttpStatusCodeException.java | 22 ++- ...DefaultHttpErrorDetailsExtractorTests.java | 97 ++++++++++++ .../client/RestTemplateIntegrationTests.java | 3 +- 10 files changed, 512 insertions(+), 65 deletions(-) create mode 100644 spring-web/src/main/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractor.java create mode 100644 spring-web/src/main/java/org/springframework/web/client/HttpErrorDetailsExtractor.java create mode 100644 spring-web/src/test/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractorTests.java diff --git a/spring-web/src/main/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractor.java b/spring-web/src/main/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractor.java new file mode 100644 index 000000000000..a1aefcabd315 --- /dev/null +++ b/spring-web/src/main/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractor.java @@ -0,0 +1,138 @@ +package org.springframework.web.client; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URI; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +import org.jetbrains.annotations.NotNull; +import org.springframework.http.HttpMethod; +import org.springframework.lang.Nullable; + +/** + * Spring's default implementation of the {@link HttpErrorDetailsExtractor} interface. + * + *

    This extractor will compose a short summary of the http error response, including: + *

      + *
    • request URI + *
    • request method + *
    • a 200-character preview of the response body, unformatted + *
    + * + * An example: + *
    + * 404 Not Found after GET http://example.com:8080/my-endpoint : [{'id': 123, 'message': 'my very long... (500 bytes)]
    + * 
    + * + * @author Jerzy Krolak + * @since 5.1 + * @see DefaultResponseErrorHandler#setHttpErrorDetailsExtractor(HttpErrorDetailsExtractor) + */ +public class DefaultHttpErrorDetailsExtractor implements HttpErrorDetailsExtractor { + + private static final int MAX_BODY_BYTES_LENGTH = 400; + + private static final int MAX_BODY_CHARS_LENGTH = 200; + + /** + * Assemble a short summary of the HTTP error response. + * @param rawStatusCode HTTP status code + * @param statusText HTTP status text + * @param responseBody response body + * @param responseCharset response charset + * @param url request URI + * @param method request method + * @return error details string. Example:
    404 Not Found after GET http://example.com:8080/my-endpoint : [{'id': 123, 'message': 'my very long... (500 bytes)]
    + */ + @Override + @NotNull + public String getErrorDetails(int rawStatusCode, String statusText, @Nullable byte[] responseBody, + @Nullable Charset responseCharset, @Nullable URI url, @Nullable HttpMethod method) { + + if (url == null || method == null) { + return getSimpleErrorDetails(rawStatusCode, statusText); + } + + return getCompleteErrorDetails(rawStatusCode, statusText, responseBody, responseCharset, url, method); + } + + @NotNull + private String getCompleteErrorDetails(int rawStatusCode, String statusText, @Nullable byte[] responseBody, + @Nullable Charset responseCharset, @Nullable URI url, @Nullable HttpMethod method) { + + StringBuilder result = new StringBuilder(); + + result.append(getSimpleErrorDetails(rawStatusCode, statusText)) + .append(" after ") + .append(method) + .append(" ") + .append(url) + .append(" : "); + + if (responseBody == null || responseBody.length == 0) { + result.append("[no body]"); + } + else { + result + .append("[") + .append(getResponseBody(responseBody, responseCharset)) + .append("]"); + } + + return result.toString(); + } + + @NotNull + private String getSimpleErrorDetails(int rawStatusCode, String statusText) { + return rawStatusCode + " " + statusText; + } + + private String getResponseBody(byte[] responseBody, @Nullable Charset responseCharset) { + Charset charset = getCharsetOrDefault(responseCharset); + if (responseBody.length < MAX_BODY_BYTES_LENGTH) { + return getCompleteResponseBody(responseBody, charset); + } + return getResponseBodyPreview(responseBody, charset); + } + + @NotNull + private String getCompleteResponseBody(byte[] responseBody, Charset responseCharset) { + return new String(responseBody, responseCharset); + } + + private String getResponseBodyPreview(byte[] responseBody, Charset responseCharset) { + try { + String bodyPreview = readBodyAsString(responseBody, responseCharset); + return bodyPreview + "... (" + responseBody.length + " bytes)"; + } + catch (IOException e) { + // should never happen + throw new IllegalStateException(e); + } + } + + @NotNull + private String readBodyAsString(byte[] responseBody, Charset responseCharset) throws IOException { + + Reader reader = new InputStreamReader(new ByteArrayInputStream(responseBody), responseCharset); + CharBuffer result = CharBuffer.allocate(MAX_BODY_CHARS_LENGTH); + + reader.read(result); + reader.close(); + result.flip(); + + return result.toString(); + } + + private Charset getCharsetOrDefault(@Nullable Charset responseCharset) { + if (responseCharset == null) { + return StandardCharsets.ISO_8859_1; + } + return responseCharset; + } + +} diff --git a/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java b/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java index 520965640c74..8a9ebdeb1d59 100644 --- a/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java +++ b/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java @@ -17,13 +17,16 @@ package org.springframework.web.client; import java.io.IOException; +import java.net.URI; import java.nio.charset.Charset; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.client.ClientHttpResponse; import org.springframework.lang.Nullable; +import org.springframework.util.Assert; import org.springframework.util.FileCopyUtils; /** @@ -43,6 +46,17 @@ */ public class DefaultResponseErrorHandler implements ResponseErrorHandler { + private HttpErrorDetailsExtractor httpErrorDetailsExtractor = new DefaultHttpErrorDetailsExtractor(); + + /** + * Set the error summary extractor. + *

    By default, DefaultResponseErrorHandler uses a {@link DefaultHttpErrorDetailsExtractor}. + */ + public void setHttpErrorDetailsExtractor(HttpErrorDetailsExtractor httpErrorDetailsExtractor) { + Assert.notNull(httpErrorDetailsExtractor, "HttpErrorDetailsExtractor must not be null"); + this.httpErrorDetailsExtractor = httpErrorDetailsExtractor; + } + /** * Delegates to {@link #hasError(HttpStatus)} (for a standard status enum value) or * {@link #hasError(int)} (for an unknown status code) with the response status code. @@ -87,19 +101,31 @@ protected boolean hasError(int unknownStatusCode) { } /** - * Delegates to {@link #handleError(ClientHttpResponse, HttpStatus)} with the + * Delegates to {@link #handleError(URI, HttpMethod, ClientHttpResponse, HttpStatus)} with the * response status code. * @throws UnknownHttpStatusCodeException in case of an unresolvable status code - * @see #handleError(ClientHttpResponse, HttpStatus) + * @see #handleError(URI, HttpMethod, ClientHttpResponse, HttpStatus) */ @Override public void handleError(ClientHttpResponse response) throws IOException { + handleError(null, null, response); + } + + /** + * Delegates to {@link #handleError(URI, HttpMethod, ClientHttpResponse, HttpStatus)} with the + * response status code. + * @throws UnknownHttpStatusCodeException in case of an unresolvable status code + * @see #handleError(URI, HttpMethod, ClientHttpResponse, HttpStatus) + */ + @Override + public void handleError(URI url, HttpMethod method, ClientHttpResponse response) throws IOException { HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); if (statusCode == null) { - throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), - response.getHeaders(), getResponseBody(response), getCharset(response)); + String message = httpErrorDetailsExtractor.getErrorDetails(response.getRawStatusCode(), response.getStatusText(), getResponseBody(response), getCharset(response), url, method); + throw new UnknownHttpStatusCodeException(message, response.getRawStatusCode(), response.getStatusText(), + response.getHeaders(), getResponseBody(response), getCharset(response), url, method); } - handleError(response, statusCode); + handleError(url, method, response, statusCode); } /** @@ -114,17 +140,34 @@ public void handleError(ClientHttpResponse response) throws IOException { * @see HttpServerErrorException#create */ protected void handleError(ClientHttpResponse response, HttpStatus statusCode) throws IOException { + handleError(null, null, response, statusCode); + } + + /** + * Handle the error in the given response with the given resolved status code. + *

    This default implementation throws a {@link HttpClientErrorException} if the response status code + * is {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}, a {@link HttpServerErrorException} + * if it is {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}, + * and a {@link RestClientException} in other cases. + * @since 5.0 + */ + protected void handleError(@Nullable URI url, @Nullable HttpMethod method, ClientHttpResponse response, + HttpStatus statusCode) throws IOException { + String statusText = response.getStatusText(); HttpHeaders headers = response.getHeaders(); byte[] body = getResponseBody(response); Charset charset = getCharset(response); + String message = httpErrorDetailsExtractor.getErrorDetails(statusCode.value(), statusText, body, charset, url, method); + switch (statusCode.series()) { case CLIENT_ERROR: - throw HttpClientErrorException.create(statusCode, statusText, headers, body, charset); + throw HttpClientErrorException.create(message, statusCode, statusText, headers, body, charset, url, method); case SERVER_ERROR: - throw HttpServerErrorException.create(statusCode, statusText, headers, body, charset); + throw HttpServerErrorException.create(message, statusCode, statusText, headers, body, charset, url, method); default: - throw new UnknownHttpStatusCodeException(statusCode.value(), statusText, headers, body, charset); + throw new UnknownHttpStatusCodeException(message, statusCode.value(), statusText, headers, body, + charset, url, method); } } diff --git a/spring-web/src/main/java/org/springframework/web/client/HttpClientErrorException.java b/spring-web/src/main/java/org/springframework/web/client/HttpClientErrorException.java index a8f3328af2a8..70c92265a3c6 100644 --- a/spring-web/src/main/java/org/springframework/web/client/HttpClientErrorException.java +++ b/spring-web/src/main/java/org/springframework/web/client/HttpClientErrorException.java @@ -16,9 +16,11 @@ package org.springframework.web.client; +import java.net.URI; import java.nio.charset.Charset; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.lang.Nullable; @@ -66,39 +68,49 @@ public HttpClientErrorException(HttpStatus statusCode, String statusText, super(statusCode, statusText, headers, body, responseCharset); } + /** + * Constructor with a status code and status text, headers, content, request URL and method. + */ + public HttpClientErrorException(String message, HttpStatus statusCode, String statusText, + @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset responseCharset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, statusCode, statusText, headers, body, responseCharset, url, method); + } /** * Create {@code HttpClientErrorException} or an HTTP status specific sub-class. * @since 5.1 */ public static HttpClientErrorException create( - HttpStatus statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + String message, HttpStatus statusCode, String statusText, HttpHeaders headers, byte[] body, + @Nullable Charset charset, @Nullable URI url, @Nullable HttpMethod method) { switch (statusCode) { case BAD_REQUEST: - return new HttpClientErrorException.BadRequest(statusText, headers, body, charset); + return new HttpClientErrorException.BadRequest(message, statusText, headers, body, charset, url, method); case UNAUTHORIZED: - return new HttpClientErrorException.Unauthorized(statusText, headers, body, charset); + return new HttpClientErrorException.Unauthorized(message, statusText, headers, body, charset, url, method); case FORBIDDEN: - return new HttpClientErrorException.Forbidden(statusText, headers, body, charset); + return new HttpClientErrorException.Forbidden(message, statusText, headers, body, charset, url, method); case NOT_FOUND: - return new HttpClientErrorException.NotFound(statusText, headers, body, charset); + return new HttpClientErrorException.NotFound(message, statusText, headers, body, charset, url, method); case METHOD_NOT_ALLOWED: - return new HttpClientErrorException.MethodNotAllowed(statusText, headers, body, charset); + return new HttpClientErrorException.MethodNotAllowed(message, statusText, headers, body, charset, url, method); case NOT_ACCEPTABLE: - return new HttpClientErrorException.NotAcceptable(statusText, headers, body, charset); + return new HttpClientErrorException.NotAcceptable(message, statusText, headers, body, charset, url, method); case CONFLICT: - return new HttpClientErrorException.Conflict(statusText, headers, body, charset); + return new HttpClientErrorException.Conflict(message, statusText, headers, body, charset, url, method); case GONE: - return new HttpClientErrorException.Gone(statusText, headers, body, charset); + return new HttpClientErrorException.Gone(message, statusText, headers, body, charset, url, method); case UNSUPPORTED_MEDIA_TYPE: - return new HttpClientErrorException.UnsupportedMediaType(statusText, headers, body, charset); + return new HttpClientErrorException.UnsupportedMediaType(message, statusText, headers, body, charset, url, method); case TOO_MANY_REQUESTS: - return new HttpClientErrorException.TooManyRequests(statusText, headers, body, charset); + return new HttpClientErrorException.TooManyRequests(message, statusText, headers, body, charset, url, method); case UNPROCESSABLE_ENTITY: - return new HttpClientErrorException.UnprocessableEntity(statusText, headers, body, charset); + return new HttpClientErrorException.UnprocessableEntity(message, statusText, headers, body, charset, url, method); default: - return new HttpClientErrorException(statusCode, statusText, headers, body, charset); + return new HttpClientErrorException(message, statusCode, statusText, headers, body, charset, url, method); } } @@ -112,8 +124,10 @@ public static HttpClientErrorException create( @SuppressWarnings("serial") public static class BadRequest extends HttpClientErrorException { - BadRequest(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.BAD_REQUEST, statusText, headers, body, charset); + BadRequest(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.BAD_REQUEST, statusText, headers, body, charset, url, method); } } @@ -124,8 +138,10 @@ public static class BadRequest extends HttpClientErrorException { @SuppressWarnings("serial") public static class Unauthorized extends HttpClientErrorException { - Unauthorized(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.UNAUTHORIZED, statusText, headers, body, charset); + Unauthorized(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.UNAUTHORIZED, statusText, headers, body, charset, url, method); } } @@ -136,8 +152,10 @@ public static class Unauthorized extends HttpClientErrorException { @SuppressWarnings("serial") public static class Forbidden extends HttpClientErrorException { - Forbidden(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.FORBIDDEN, statusText, headers, body, charset); + Forbidden(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.FORBIDDEN, statusText, headers, body, charset, url, method); } } @@ -148,8 +166,10 @@ public static class Forbidden extends HttpClientErrorException { @SuppressWarnings("serial") public static class NotFound extends HttpClientErrorException { - NotFound(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.NOT_FOUND, statusText, headers, body, charset); + NotFound(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.NOT_FOUND, statusText, headers, body, charset, url, method); } } @@ -160,8 +180,10 @@ public static class NotFound extends HttpClientErrorException { @SuppressWarnings("serial") public static class MethodNotAllowed extends HttpClientErrorException { - MethodNotAllowed(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.METHOD_NOT_ALLOWED, statusText, headers, body, charset); + MethodNotAllowed(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.METHOD_NOT_ALLOWED, statusText, headers, body, charset, url, method); } } @@ -172,8 +194,10 @@ public static class MethodNotAllowed extends HttpClientErrorException { @SuppressWarnings("serial") public static class NotAcceptable extends HttpClientErrorException { - NotAcceptable(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.NOT_ACCEPTABLE, statusText, headers, body, charset); + NotAcceptable(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.NOT_ACCEPTABLE, statusText, headers, body, charset, url, method); } } @@ -184,8 +208,10 @@ public static class NotAcceptable extends HttpClientErrorException { @SuppressWarnings("serial") public static class Conflict extends HttpClientErrorException { - Conflict(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.CONFLICT, statusText, headers, body, charset); + Conflict(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.CONFLICT, statusText, headers, body, charset, url, method); } } @@ -196,8 +222,10 @@ public static class Conflict extends HttpClientErrorException { @SuppressWarnings("serial") public static class Gone extends HttpClientErrorException { - Gone(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.GONE, statusText, headers, body, charset); + Gone(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.GONE, statusText, headers, body, charset, url, method); } } @@ -208,8 +236,10 @@ public static class Gone extends HttpClientErrorException { @SuppressWarnings("serial") public static class UnsupportedMediaType extends HttpClientErrorException { - UnsupportedMediaType(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, statusText, headers, body, charset); + UnsupportedMediaType(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.UNSUPPORTED_MEDIA_TYPE, statusText, headers, body, charset, url, method); } } @@ -220,8 +250,10 @@ public static class UnsupportedMediaType extends HttpClientErrorException { @SuppressWarnings("serial") public static class UnprocessableEntity extends HttpClientErrorException { - UnprocessableEntity(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.UNPROCESSABLE_ENTITY, statusText, headers, body, charset); + UnprocessableEntity(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.UNPROCESSABLE_ENTITY, statusText, headers, body, charset, url, method); } } @@ -232,8 +264,10 @@ public static class UnprocessableEntity extends HttpClientErrorException { @SuppressWarnings("serial") public static class TooManyRequests extends HttpClientErrorException { - TooManyRequests(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.TOO_MANY_REQUESTS, statusText, headers, body, charset); + TooManyRequests(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.TOO_MANY_REQUESTS, statusText, headers, body, charset, url, method); } } diff --git a/spring-web/src/main/java/org/springframework/web/client/HttpErrorDetailsExtractor.java b/spring-web/src/main/java/org/springframework/web/client/HttpErrorDetailsExtractor.java new file mode 100644 index 000000000000..d141549c8569 --- /dev/null +++ b/spring-web/src/main/java/org/springframework/web/client/HttpErrorDetailsExtractor.java @@ -0,0 +1,33 @@ +package org.springframework.web.client; + +import java.net.URI; +import java.nio.charset.Charset; + +import org.jetbrains.annotations.NotNull; +import org.springframework.http.HttpMethod; +import org.springframework.lang.Nullable; + +/** + * Strategy interface used by the {@link DefaultResponseErrorHandler} to compose + * a summary of the http error. + * + * @author Jerzy Krolak + * @since 5.1 + */ +public interface HttpErrorDetailsExtractor { + + /** + * Assemble HTTP error response details string, based on the provided response details. + * @param rawStatusCode HTTP status code + * @param statusText HTTP status text + * @param responseBody response body + * @param responseCharset response charset + * @param url request URI + * @param method request method + * @return error details string + */ + @NotNull + String getErrorDetails(int rawStatusCode, String statusText, @Nullable byte[] responseBody, + @Nullable Charset responseCharset, @Nullable URI url, @Nullable HttpMethod method); + +} diff --git a/spring-web/src/main/java/org/springframework/web/client/HttpServerErrorException.java b/spring-web/src/main/java/org/springframework/web/client/HttpServerErrorException.java index b0f7cc85f3f5..4a63be5cf160 100644 --- a/spring-web/src/main/java/org/springframework/web/client/HttpServerErrorException.java +++ b/spring-web/src/main/java/org/springframework/web/client/HttpServerErrorException.java @@ -16,9 +16,11 @@ package org.springframework.web.client; +import java.net.URI; import java.nio.charset.Charset; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.lang.Nullable; @@ -66,27 +68,36 @@ public HttpServerErrorException(HttpStatus statusCode, String statusText, super(statusCode, statusText, headers, body, charset); } + /** + * Constructor with a status code and status text, headers, content, request URL, and method. + */ + public HttpServerErrorException(String message, HttpStatus statusCode, String statusText, + @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + super(message, statusCode, statusText, headers, body, charset, url, method); + } /** * Create an {@code HttpServerErrorException} or an HTTP status specific sub-class. * @since 5.1 */ public static HttpServerErrorException create( - HttpStatus statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + String message, HttpStatus statusCode, String statusText, HttpHeaders headers, byte[] body, + @Nullable Charset charset, @Nullable URI url, @Nullable HttpMethod method) { switch (statusCode) { case INTERNAL_SERVER_ERROR: - return new HttpServerErrorException.InternalServerError(statusText, headers, body, charset); + return new HttpServerErrorException.InternalServerError(message, statusText, headers, body, charset, url, method); case NOT_IMPLEMENTED: - return new HttpServerErrorException.NotImplemented(statusText, headers, body, charset); + return new HttpServerErrorException.NotImplemented(message, statusText, headers, body, charset, url, method); case BAD_GATEWAY: - return new HttpServerErrorException.BadGateway(statusText, headers, body, charset); + return new HttpServerErrorException.BadGateway(message, statusText, headers, body, charset, url, method); case SERVICE_UNAVAILABLE: - return new HttpServerErrorException.ServiceUnavailable(statusText, headers, body, charset); + return new HttpServerErrorException.ServiceUnavailable(message, statusText, headers, body, charset, url, method); case GATEWAY_TIMEOUT: - return new HttpServerErrorException.GatewayTimeout(statusText, headers, body, charset); + return new HttpServerErrorException.GatewayTimeout(message, statusText, headers, body, charset, url, method); default: - return new HttpServerErrorException(statusCode, statusText, headers, body, charset); + return new HttpServerErrorException(message, statusCode, statusText, headers, body, charset, url, method); } } @@ -100,8 +111,10 @@ public static HttpServerErrorException create( @SuppressWarnings("serial") public static class InternalServerError extends HttpServerErrorException { - InternalServerError(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.INTERNAL_SERVER_ERROR, statusText, headers, body, charset); + InternalServerError(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.INTERNAL_SERVER_ERROR, statusText, headers, body, charset, url, method); } } @@ -112,8 +125,10 @@ public static class InternalServerError extends HttpServerErrorException { @SuppressWarnings("serial") public static class NotImplemented extends HttpServerErrorException { - NotImplemented(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.NOT_IMPLEMENTED, statusText, headers, body, charset); + NotImplemented(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.NOT_IMPLEMENTED, statusText, headers, body, charset, url, method); } } @@ -124,8 +139,10 @@ public static class NotImplemented extends HttpServerErrorException { @SuppressWarnings("serial") public static class BadGateway extends HttpServerErrorException { - BadGateway(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.BAD_GATEWAY, statusText, headers, body, charset); + BadGateway(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.BAD_GATEWAY, statusText, headers, body, charset, url, method); } } @@ -136,8 +153,10 @@ public static class BadGateway extends HttpServerErrorException { @SuppressWarnings("serial") public static class ServiceUnavailable extends HttpServerErrorException { - ServiceUnavailable(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.SERVICE_UNAVAILABLE, statusText, headers, body, charset); + ServiceUnavailable(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.SERVICE_UNAVAILABLE, statusText, headers, body, charset, url, method); } } @@ -148,8 +167,10 @@ public static class ServiceUnavailable extends HttpServerErrorException { @SuppressWarnings("serial") public static class GatewayTimeout extends HttpServerErrorException { - GatewayTimeout(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(HttpStatus.GATEWAY_TIMEOUT, statusText, headers, body, charset); + GatewayTimeout(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, HttpStatus.GATEWAY_TIMEOUT, statusText, headers, body, charset, url, method); } } diff --git a/spring-web/src/main/java/org/springframework/web/client/HttpStatusCodeException.java b/spring-web/src/main/java/org/springframework/web/client/HttpStatusCodeException.java index 16715ef81151..726e77558737 100644 --- a/spring-web/src/main/java/org/springframework/web/client/HttpStatusCodeException.java +++ b/spring-web/src/main/java/org/springframework/web/client/HttpStatusCodeException.java @@ -16,9 +16,11 @@ package org.springframework.web.client; +import java.net.URI; import java.nio.charset.Charset; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.lang.Nullable; import org.springframework.util.StringUtils; @@ -83,8 +85,28 @@ protected HttpStatusCodeException(HttpStatus statusCode, String statusText, protected HttpStatusCodeException(HttpStatus statusCode, String statusText, @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset) { - super(getMessage(statusCode, statusText), statusCode.value(), statusText, - responseHeaders, responseBody, responseCharset); + this(getMessage(statusCode, statusText), statusCode, statusText, + responseHeaders, responseBody, responseCharset, null, null); + } + + /** + * Construct instance with an {@link HttpStatus}, status text, content, and + * a response charset. + * @param message the exception message + * @param statusCode the status code + * @param statusText the status text + * @param responseHeaders the response headers, may be {@code null} + * @param responseBody the response body content, may be {@code null} + * @param responseCharset the response body charset, may be {@code null} + * @param url the request URL, may be {@code null} + * @param method the request method, may be {@code null} + */ + protected HttpStatusCodeException(String message, HttpStatus statusCode, String statusText, + @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset, + @Nullable URI url, @Nullable HttpMethod method) { + + super(message, statusCode.value(), statusText, responseHeaders, responseBody, + responseCharset, url, method); this.statusCode = statusCode; } diff --git a/spring-web/src/main/java/org/springframework/web/client/RestClientResponseException.java b/spring-web/src/main/java/org/springframework/web/client/RestClientResponseException.java index 2a927f376905..5410096477a4 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestClientResponseException.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestClientResponseException.java @@ -17,10 +17,12 @@ package org.springframework.web.client; import java.io.UnsupportedEncodingException; +import java.net.URI; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; import org.springframework.lang.Nullable; /** @@ -48,6 +50,12 @@ public class RestClientResponseException extends RestClientException { @Nullable private final String responseCharset; + @Nullable + private final HttpMethod method; + + @Nullable + private final URI url; + /** * Construct a new instance of with the given response data. @@ -59,6 +67,22 @@ public class RestClientResponseException extends RestClientException { */ public RestClientResponseException(String message, int statusCode, String statusText, @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset) { + this(message, statusCode, statusText, responseHeaders, responseBody, responseCharset, null, null); + } + + /** + * Construct a new instance of with the given response data. + * @param statusCode the raw status code value + * @param statusText the status text + * @param responseHeaders the response headers (may be {@code null}) + * @param responseBody the response body content (may be {@code null}) + * @param responseCharset the response body charset (may be {@code null}) + * @param url the request URL (may be {@code null}) + * @param method the request method (may be {@code null}) + */ + public RestClientResponseException(String message, int statusCode, String statusText, + @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset, + @Nullable URI url, @Nullable HttpMethod method) { super(message); this.rawStatusCode = statusCode; @@ -66,6 +90,8 @@ public RestClientResponseException(String message, int statusCode, String status this.responseHeaders = responseHeaders; this.responseBody = (responseBody != null ? responseBody : new byte[0]); this.responseCharset = (responseCharset != null ? responseCharset.name() : null); + this.method = method; + this.url = url; } @@ -98,6 +124,20 @@ public byte[] getResponseBodyAsByteArray() { return this.responseBody; } + /** + * Return the HTTP request method. + */ + public HttpMethod getMethod() { + return method; + } + + /** + * Return the HTTP request url. + */ + public URI getUrl() { + return url; + } + /** * Return the response body converted to String. The charset used is that * of the response "Content-Type" or otherwise {@code "UTF-8"}. diff --git a/spring-web/src/main/java/org/springframework/web/client/UnknownHttpStatusCodeException.java b/spring-web/src/main/java/org/springframework/web/client/UnknownHttpStatusCodeException.java index ac239513ae90..79d5544ad022 100644 --- a/spring-web/src/main/java/org/springframework/web/client/UnknownHttpStatusCodeException.java +++ b/spring-web/src/main/java/org/springframework/web/client/UnknownHttpStatusCodeException.java @@ -16,9 +16,11 @@ package org.springframework.web.client; +import java.net.URI; import java.nio.charset.Charset; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.lang.Nullable; @@ -45,8 +47,24 @@ public class UnknownHttpStatusCodeException extends RestClientResponseException public UnknownHttpStatusCodeException(int rawStatusCode, String statusText, @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset) { - super("Unknown status code [" + rawStatusCode + "]" + " " + statusText, - rawStatusCode, statusText, responseHeaders, responseBody, responseCharset); + this("Unknown status code [" + rawStatusCode + "]" + " " + statusText, + rawStatusCode, statusText, responseHeaders, responseBody, responseCharset, null, null); } + /** + * Construct a new instance of {@code HttpStatusCodeException} based on an + * {@link HttpStatus}, status text, and response body content. + * @param rawStatusCode the raw status code value + * @param statusText the status text + * @param responseHeaders the response headers (may be {@code null}) + * @param responseBody the response body content (may be {@code null}) + * @param responseCharset the response body charset (may be {@code null}) + * @param url the request URI (may be {@code null}) + * @param method the request HTTP method (may be {@code null}) + */ + public UnknownHttpStatusCodeException(String message, int rawStatusCode, String statusText, @Nullable HttpHeaders responseHeaders, + @Nullable byte[] responseBody, @Nullable Charset responseCharset, @Nullable URI url, @Nullable HttpMethod method) { + + super(message, rawStatusCode, statusText, responseHeaders, responseBody, responseCharset, url, method); + } } diff --git a/spring-web/src/test/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractorTests.java b/spring-web/src/test/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractorTests.java new file mode 100644 index 000000000000..94804ac69f8a --- /dev/null +++ b/spring-web/src/test/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractorTests.java @@ -0,0 +1,97 @@ +package org.springframework.web.client; + +import java.net.URI; + +import com.google.common.base.Strings; +import org.junit.Test; + +import static java.nio.charset.StandardCharsets.*; +import static org.junit.Assert.*; +import static org.springframework.http.HttpMethod.*; +import static org.springframework.http.HttpStatus.*; + +public class DefaultHttpErrorDetailsExtractorTests { + + private final DefaultHttpErrorDetailsExtractor extractor = new DefaultHttpErrorDetailsExtractor(); + + @Test + public void shouldGetSimpleExceptionMessage() { + String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", null, null, null, null); + + assertEquals("Should get a simple message", "404 Not Found", actual); + } + + @Test + public void shouldGetCompleteMessageWithoutBody() { + String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", null, null, URI.create("http://localhost:8080/my-endpoint"), GET); + + assertEquals("Should get a complete message without body", "404 Not Found after GET http://localhost:8080/my-endpoint : [no body]", actual); + } + + @Test + public void shouldGetCompleteMessageWithShortAsciiBodyNoCharset() { + String responseBody = "my short response body"; + + String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(), null, URI.create("http://localhost:8080/my-endpoint"), GET); + + assertEquals("Should get a simple message", "404 Not Found after GET http://localhost:8080/my-endpoint : [my short response body]", actual); + } + + @Test + public void shouldGetCompleteMessageWithShortAsciiBodyUtfCharset() { + String responseBody = "my short response body"; + + String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(), UTF_8, URI.create("http://localhost:8080/my-endpoint"), GET); + + assertEquals("Should get a simple message", "404 Not Found after GET http://localhost:8080/my-endpoint : [my short response body]", actual); + } + + @Test + public void shouldGetCompleteMessageWithShortUtfBodyUtfCharset() { + String responseBody = "my short response body \u0105\u0119"; + + String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(), UTF_8, URI.create("http://localhost:8080/my-endpoint"), GET); + + assertEquals("Should get a simple message", "404 Not Found after GET http://localhost:8080/my-endpoint : [my short response body \u0105\u0119]", actual); + } + + @Test + public void shouldGetCompleteMessageWithShortUtfBodyNoCharset() { + String responseBody = "my short response body \u0105\u0119"; + + String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(UTF_8), null, URI.create("http://localhost:8080/my-endpoint"), GET); + + assertEquals("Should get a simple message", "404 Not Found after GET http://localhost:8080/my-endpoint : [my short response body \u00c4\u0085\u00c4\u0099]", actual); + } + + @Test + public void shouldGetCompleteMessageWithLongAsciiBodyNoCharset() { + String responseBody = Strings.repeat("asdfg", 100); + String expectedMessage = "404 Not Found after GET http://localhost:8080/my-endpoint : [" + Strings.repeat("asdfg", 40) + "... (500 bytes)]"; + + String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(UTF_8), null, URI.create("http://localhost:8080/my-endpoint"), GET); + + assertEquals("Should get a simple message", expectedMessage, actual); + } + + @Test + public void shouldGetCompleteMessageWithLongUtfBodyNoCharset() { + String responseBody = Strings.repeat("asd\u0105\u0119", 100); + String expectedMessage = "404 Not Found after GET http://localhost:8080/my-endpoint : [" + Strings.repeat("asd\u00c4\u0085\u00c4\u0099", 28) + "asd\u00c4... (700 bytes)]"; + + String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(UTF_8), null, URI.create("http://localhost:8080/my-endpoint"), GET); + + assertEquals("Should get a simple message", expectedMessage, actual); + } + + @Test + public void shouldGetCompleteMessageWithLongUtfBodyUtfCharset() { + String responseBody = Strings.repeat("asd\u0105\u0119", 100); + String expectedMessage = "404 Not Found after GET http://localhost:8080/my-endpoint : [" + Strings.repeat("asd\u0105\u0119", 40) + "... (700 bytes)]"; + + String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(UTF_8), UTF_8, URI.create("http://localhost:8080/my-endpoint"), GET); + + assertEquals("Should get a simple message", expectedMessage, actual); + } + +} \ No newline at end of file diff --git a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java index d74c4c767765..631725b6bd29 100644 --- a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java @@ -254,7 +254,8 @@ void badRequest(ClientHttpRequestFactory clientHttpRequestFactory) { template.execute(baseUrl + "/status/badrequest", HttpMethod.GET, null, null)) .satisfies(ex -> { assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); - assertThat(ex.getMessage()).isEqualTo("400 Client Error"); + assertThat(ex.getMessage()).isEqualTo( + "400 Client Error after GET http://localhost:" + port + "/status/badrequest : [no body]"); }); } From 04aa3d05dace092a675609425e9ee9274d5882be Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 13 Nov 2019 14:18:30 +0000 Subject: [PATCH 0051/2315] Refactor solution for respones error details See gh-1956 --- .../DefaultHttpErrorDetailsExtractor.java | 138 ------------ .../client/DefaultResponseErrorHandler.java | 100 ++++----- .../web/client/HttpClientErrorException.java | 204 ++++++++++++------ .../web/client/HttpErrorDetailsExtractor.java | 33 --- .../web/client/HttpServerErrorException.java | 114 ++++++---- .../web/client/HttpStatusCodeException.java | 15 +- .../client/RestClientResponseException.java | 40 ---- .../UnknownHttpStatusCodeException.java | 15 +- ...DefaultHttpErrorDetailsExtractorTests.java | 97 --------- .../DefaultResponseErrorHandlerTests.java | 30 ++- .../client/RestTemplateIntegrationTests.java | 3 +- 11 files changed, 306 insertions(+), 483 deletions(-) delete mode 100644 spring-web/src/main/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractor.java delete mode 100644 spring-web/src/main/java/org/springframework/web/client/HttpErrorDetailsExtractor.java delete mode 100644 spring-web/src/test/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractorTests.java diff --git a/spring-web/src/main/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractor.java b/spring-web/src/main/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractor.java deleted file mode 100644 index a1aefcabd315..000000000000 --- a/spring-web/src/main/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractor.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.springframework.web.client; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.net.URI; -import java.nio.CharBuffer; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; - -import org.jetbrains.annotations.NotNull; -import org.springframework.http.HttpMethod; -import org.springframework.lang.Nullable; - -/** - * Spring's default implementation of the {@link HttpErrorDetailsExtractor} interface. - * - *

    This extractor will compose a short summary of the http error response, including: - *

      - *
    • request URI - *
    • request method - *
    • a 200-character preview of the response body, unformatted - *
    - * - * An example: - *
    - * 404 Not Found after GET http://example.com:8080/my-endpoint : [{'id': 123, 'message': 'my very long... (500 bytes)]
    - * 
    - * - * @author Jerzy Krolak - * @since 5.1 - * @see DefaultResponseErrorHandler#setHttpErrorDetailsExtractor(HttpErrorDetailsExtractor) - */ -public class DefaultHttpErrorDetailsExtractor implements HttpErrorDetailsExtractor { - - private static final int MAX_BODY_BYTES_LENGTH = 400; - - private static final int MAX_BODY_CHARS_LENGTH = 200; - - /** - * Assemble a short summary of the HTTP error response. - * @param rawStatusCode HTTP status code - * @param statusText HTTP status text - * @param responseBody response body - * @param responseCharset response charset - * @param url request URI - * @param method request method - * @return error details string. Example:
    404 Not Found after GET http://example.com:8080/my-endpoint : [{'id': 123, 'message': 'my very long... (500 bytes)]
    - */ - @Override - @NotNull - public String getErrorDetails(int rawStatusCode, String statusText, @Nullable byte[] responseBody, - @Nullable Charset responseCharset, @Nullable URI url, @Nullable HttpMethod method) { - - if (url == null || method == null) { - return getSimpleErrorDetails(rawStatusCode, statusText); - } - - return getCompleteErrorDetails(rawStatusCode, statusText, responseBody, responseCharset, url, method); - } - - @NotNull - private String getCompleteErrorDetails(int rawStatusCode, String statusText, @Nullable byte[] responseBody, - @Nullable Charset responseCharset, @Nullable URI url, @Nullable HttpMethod method) { - - StringBuilder result = new StringBuilder(); - - result.append(getSimpleErrorDetails(rawStatusCode, statusText)) - .append(" after ") - .append(method) - .append(" ") - .append(url) - .append(" : "); - - if (responseBody == null || responseBody.length == 0) { - result.append("[no body]"); - } - else { - result - .append("[") - .append(getResponseBody(responseBody, responseCharset)) - .append("]"); - } - - return result.toString(); - } - - @NotNull - private String getSimpleErrorDetails(int rawStatusCode, String statusText) { - return rawStatusCode + " " + statusText; - } - - private String getResponseBody(byte[] responseBody, @Nullable Charset responseCharset) { - Charset charset = getCharsetOrDefault(responseCharset); - if (responseBody.length < MAX_BODY_BYTES_LENGTH) { - return getCompleteResponseBody(responseBody, charset); - } - return getResponseBodyPreview(responseBody, charset); - } - - @NotNull - private String getCompleteResponseBody(byte[] responseBody, Charset responseCharset) { - return new String(responseBody, responseCharset); - } - - private String getResponseBodyPreview(byte[] responseBody, Charset responseCharset) { - try { - String bodyPreview = readBodyAsString(responseBody, responseCharset); - return bodyPreview + "... (" + responseBody.length + " bytes)"; - } - catch (IOException e) { - // should never happen - throw new IllegalStateException(e); - } - } - - @NotNull - private String readBodyAsString(byte[] responseBody, Charset responseCharset) throws IOException { - - Reader reader = new InputStreamReader(new ByteArrayInputStream(responseBody), responseCharset); - CharBuffer result = CharBuffer.allocate(MAX_BODY_CHARS_LENGTH); - - reader.read(result); - reader.close(); - result.flip(); - - return result.toString(); - } - - private Charset getCharsetOrDefault(@Nullable Charset responseCharset) { - if (responseCharset == null) { - return StandardCharsets.ISO_8859_1; - } - return responseCharset; - } - -} diff --git a/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java b/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java index 8a9ebdeb1d59..ff72eb1e465d 100644 --- a/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java +++ b/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java @@ -16,18 +16,21 @@ package org.springframework.web.client; +import java.io.ByteArrayInputStream; import java.io.IOException; -import java.net.URI; +import java.io.InputStreamReader; +import java.io.Reader; +import java.nio.CharBuffer; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.client.ClientHttpResponse; import org.springframework.lang.Nullable; -import org.springframework.util.Assert; import org.springframework.util.FileCopyUtils; +import org.springframework.util.ObjectUtils; /** * Spring's default implementation of the {@link ResponseErrorHandler} interface. @@ -46,17 +49,6 @@ */ public class DefaultResponseErrorHandler implements ResponseErrorHandler { - private HttpErrorDetailsExtractor httpErrorDetailsExtractor = new DefaultHttpErrorDetailsExtractor(); - - /** - * Set the error summary extractor. - *

    By default, DefaultResponseErrorHandler uses a {@link DefaultHttpErrorDetailsExtractor}. - */ - public void setHttpErrorDetailsExtractor(HttpErrorDetailsExtractor httpErrorDetailsExtractor) { - Assert.notNull(httpErrorDetailsExtractor, "HttpErrorDetailsExtractor must not be null"); - this.httpErrorDetailsExtractor = httpErrorDetailsExtractor; - } - /** * Delegates to {@link #hasError(HttpStatus)} (for a standard status enum value) or * {@link #hasError(int)} (for an unknown status code) with the response status code. @@ -101,31 +93,58 @@ protected boolean hasError(int unknownStatusCode) { } /** - * Delegates to {@link #handleError(URI, HttpMethod, ClientHttpResponse, HttpStatus)} with the + * Delegates to {@link #handleError(ClientHttpResponse, HttpStatus)} with the * response status code. * @throws UnknownHttpStatusCodeException in case of an unresolvable status code - * @see #handleError(URI, HttpMethod, ClientHttpResponse, HttpStatus) + * @see #handleError(ClientHttpResponse, HttpStatus) */ @Override public void handleError(ClientHttpResponse response) throws IOException { - handleError(null, null, response); + HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); + if (statusCode == null) { + String message = getErrorMessage( + response.getRawStatusCode(), response.getStatusText(), + getResponseBody(response), getCharset(response)); + throw new UnknownHttpStatusCodeException(message, + response.getRawStatusCode(), response.getStatusText(), + response.getHeaders(), getResponseBody(response), getCharset(response)); + } + handleError(response, statusCode); } /** - * Delegates to {@link #handleError(URI, HttpMethod, ClientHttpResponse, HttpStatus)} with the - * response status code. - * @throws UnknownHttpStatusCodeException in case of an unresolvable status code - * @see #handleError(URI, HttpMethod, ClientHttpResponse, HttpStatus) + * Return error message with details from the response body, possibly truncated: + *

    +	 * 404 Not Found: [{'id': 123, 'message': 'my very long... (500 bytes)]
    +	 * 
    */ - @Override - public void handleError(URI url, HttpMethod method, ClientHttpResponse response) throws IOException { - HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); - if (statusCode == null) { - String message = httpErrorDetailsExtractor.getErrorDetails(response.getRawStatusCode(), response.getStatusText(), getResponseBody(response), getCharset(response), url, method); - throw new UnknownHttpStatusCodeException(message, response.getRawStatusCode(), response.getStatusText(), - response.getHeaders(), getResponseBody(response), getCharset(response), url, method); + private String getErrorMessage( + int rawStatusCode, String statusText, @Nullable byte[] responseBody, @Nullable Charset charset) { + + String preface = rawStatusCode + " " + statusText + ": "; + if (ObjectUtils.isEmpty(responseBody)) { + return preface + "[no body]"; + } + + charset = charset == null ? StandardCharsets.UTF_8 : charset; + int maxChars = 200; + + if (responseBody.length < maxChars * 2) { + return preface + "[" + new String(responseBody, charset) + "]"; + } + + try { + Reader reader = new InputStreamReader(new ByteArrayInputStream(responseBody), charset); + CharBuffer buffer = CharBuffer.allocate(maxChars); + reader.read(buffer); + reader.close(); + buffer.flip(); + return preface + "[" + buffer.toString() + "... (" + responseBody.length + " bytes)]"; + } + catch (IOException ex) { + // should never happen + throw new IllegalStateException(ex); } - handleError(url, method, response, statusCode); } /** @@ -140,34 +159,19 @@ public void handleError(URI url, HttpMethod method, ClientHttpResponse response) * @see HttpServerErrorException#create */ protected void handleError(ClientHttpResponse response, HttpStatus statusCode) throws IOException { - handleError(null, null, response, statusCode); - } - - /** - * Handle the error in the given response with the given resolved status code. - *

    This default implementation throws a {@link HttpClientErrorException} if the response status code - * is {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}, a {@link HttpServerErrorException} - * if it is {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}, - * and a {@link RestClientException} in other cases. - * @since 5.0 - */ - protected void handleError(@Nullable URI url, @Nullable HttpMethod method, ClientHttpResponse response, - HttpStatus statusCode) throws IOException { - String statusText = response.getStatusText(); HttpHeaders headers = response.getHeaders(); byte[] body = getResponseBody(response); Charset charset = getCharset(response); - String message = httpErrorDetailsExtractor.getErrorDetails(statusCode.value(), statusText, body, charset, url, method); + String message = getErrorMessage(statusCode.value(), statusText, body, charset); switch (statusCode.series()) { case CLIENT_ERROR: - throw HttpClientErrorException.create(message, statusCode, statusText, headers, body, charset, url, method); + throw HttpClientErrorException.create(message, statusCode, statusText, headers, body, charset); case SERVER_ERROR: - throw HttpServerErrorException.create(message, statusCode, statusText, headers, body, charset, url, method); + throw HttpServerErrorException.create(message, statusCode, statusText, headers, body, charset); default: - throw new UnknownHttpStatusCodeException(message, statusCode.value(), statusText, headers, body, - charset, url, method); + throw new UnknownHttpStatusCodeException(message, statusCode.value(), statusText, headers, body, charset); } } diff --git a/spring-web/src/main/java/org/springframework/web/client/HttpClientErrorException.java b/spring-web/src/main/java/org/springframework/web/client/HttpClientErrorException.java index 70c92265a3c6..ff6e3f83085a 100644 --- a/spring-web/src/main/java/org/springframework/web/client/HttpClientErrorException.java +++ b/spring-web/src/main/java/org/springframework/web/client/HttpClientErrorException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -16,11 +16,9 @@ package org.springframework.web.client; -import java.net.URI; import java.nio.charset.Charset; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.lang.Nullable; @@ -69,48 +67,84 @@ public HttpClientErrorException(HttpStatus statusCode, String statusText, } /** - * Constructor with a status code and status text, headers, content, request URL and method. + * Constructor with a status code and status text, headers, and content, + * and an prepared message. + * @since 5.2.2 */ public HttpClientErrorException(String message, HttpStatus statusCode, String statusText, - @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset responseCharset, - @Nullable URI url, @Nullable HttpMethod method) { + @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset responseCharset) { - super(message, statusCode, statusText, headers, body, responseCharset, url, method); + super(message, statusCode, statusText, headers, body, responseCharset); } + /** * Create {@code HttpClientErrorException} or an HTTP status specific sub-class. * @since 5.1 */ public static HttpClientErrorException create( - String message, HttpStatus statusCode, String statusText, HttpHeaders headers, byte[] body, - @Nullable Charset charset, @Nullable URI url, @Nullable HttpMethod method) { + HttpStatus statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + + return create(null, statusCode, statusText, headers, body, charset); + } + + /** + * Variant of {@link #create(HttpStatus, String, HttpHeaders, byte[], Charset)} + * with an optional prepared message. + * @since 5.2.2 + */ + public static HttpClientErrorException create(@Nullable String message, HttpStatus statusCode, + String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { switch (statusCode) { case BAD_REQUEST: - return new HttpClientErrorException.BadRequest(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException.BadRequest(message, statusText, headers, body, charset) : + new HttpClientErrorException.BadRequest(statusText, headers, body, charset); case UNAUTHORIZED: - return new HttpClientErrorException.Unauthorized(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException.Unauthorized(message, statusText, headers, body, charset) : + new HttpClientErrorException.Unauthorized(statusText, headers, body, charset); case FORBIDDEN: - return new HttpClientErrorException.Forbidden(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException.Forbidden(message, statusText, headers, body, charset) : + new HttpClientErrorException.Forbidden(statusText, headers, body, charset); case NOT_FOUND: - return new HttpClientErrorException.NotFound(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException.NotFound(message, statusText, headers, body, charset) : + new HttpClientErrorException.NotFound(statusText, headers, body, charset); case METHOD_NOT_ALLOWED: - return new HttpClientErrorException.MethodNotAllowed(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException.MethodNotAllowed(message, statusText, headers, body, charset) : + new HttpClientErrorException.MethodNotAllowed(statusText, headers, body, charset); case NOT_ACCEPTABLE: - return new HttpClientErrorException.NotAcceptable(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException.NotAcceptable(message, statusText, headers, body, charset) : + new HttpClientErrorException.NotAcceptable(statusText, headers, body, charset); case CONFLICT: - return new HttpClientErrorException.Conflict(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException.Conflict(message, statusText, headers, body, charset) : + new HttpClientErrorException.Conflict(statusText, headers, body, charset); case GONE: - return new HttpClientErrorException.Gone(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException.Gone(message, statusText, headers, body, charset) : + new HttpClientErrorException.Gone(statusText, headers, body, charset); case UNSUPPORTED_MEDIA_TYPE: - return new HttpClientErrorException.UnsupportedMediaType(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException.UnsupportedMediaType(message, statusText, headers, body, charset) : + new HttpClientErrorException.UnsupportedMediaType(statusText, headers, body, charset); case TOO_MANY_REQUESTS: - return new HttpClientErrorException.TooManyRequests(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException.TooManyRequests(message, statusText, headers, body, charset) : + new HttpClientErrorException.TooManyRequests(statusText, headers, body, charset); case UNPROCESSABLE_ENTITY: - return new HttpClientErrorException.UnprocessableEntity(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException.UnprocessableEntity(message, statusText, headers, body, charset) : + new HttpClientErrorException.UnprocessableEntity(statusText, headers, body, charset); default: - return new HttpClientErrorException(message, statusCode, statusText, headers, body, charset, url, method); + return message != null ? + new HttpClientErrorException(message, statusCode, statusText, headers, body, charset) : + new HttpClientErrorException(statusCode, statusText, headers, body, charset); } } @@ -122,12 +156,16 @@ public static HttpClientErrorException create( * @since 5.1 */ @SuppressWarnings("serial") - public static class BadRequest extends HttpClientErrorException { + public static final class BadRequest extends HttpClientErrorException { - BadRequest(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private BadRequest(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.BAD_REQUEST, statusText, headers, body, charset); + } + + private BadRequest(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.BAD_REQUEST, statusText, headers, body, charset, url, method); + super(message, HttpStatus.BAD_REQUEST, statusText, headers, body, charset); } } @@ -136,12 +174,16 @@ public static class BadRequest extends HttpClientErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class Unauthorized extends HttpClientErrorException { + public static final class Unauthorized extends HttpClientErrorException { + + private Unauthorized(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.UNAUTHORIZED, statusText, headers, body, charset); + } - Unauthorized(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private Unauthorized(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.UNAUTHORIZED, statusText, headers, body, charset, url, method); + super(message, HttpStatus.UNAUTHORIZED, statusText, headers, body, charset); } } @@ -150,12 +192,16 @@ public static class Unauthorized extends HttpClientErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class Forbidden extends HttpClientErrorException { + public static final class Forbidden extends HttpClientErrorException { - Forbidden(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private Forbidden(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.FORBIDDEN, statusText, headers, body, charset); + } + + private Forbidden(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.FORBIDDEN, statusText, headers, body, charset, url, method); + super(message, HttpStatus.FORBIDDEN, statusText, headers, body, charset); } } @@ -164,12 +210,16 @@ public static class Forbidden extends HttpClientErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class NotFound extends HttpClientErrorException { + public static final class NotFound extends HttpClientErrorException { - NotFound(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private NotFound(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.NOT_FOUND, statusText, headers, body, charset); + } - super(message, HttpStatus.NOT_FOUND, statusText, headers, body, charset, url, method); + private NotFound(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { + + super(message, HttpStatus.NOT_FOUND, statusText, headers, body, charset); } } @@ -178,12 +228,16 @@ public static class NotFound extends HttpClientErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class MethodNotAllowed extends HttpClientErrorException { + public static final class MethodNotAllowed extends HttpClientErrorException { + + private MethodNotAllowed(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.METHOD_NOT_ALLOWED, statusText, headers, body, charset); + } - MethodNotAllowed(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private MethodNotAllowed(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.METHOD_NOT_ALLOWED, statusText, headers, body, charset, url, method); + super(message, HttpStatus.METHOD_NOT_ALLOWED, statusText, headers, body, charset); } } @@ -192,12 +246,16 @@ public static class MethodNotAllowed extends HttpClientErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class NotAcceptable extends HttpClientErrorException { + public static final class NotAcceptable extends HttpClientErrorException { - NotAcceptable(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private NotAcceptable(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.NOT_ACCEPTABLE, statusText, headers, body, charset); + } - super(message, HttpStatus.NOT_ACCEPTABLE, statusText, headers, body, charset, url, method); + private NotAcceptable(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { + + super(message, HttpStatus.NOT_ACCEPTABLE, statusText, headers, body, charset); } } @@ -206,12 +264,14 @@ public static class NotAcceptable extends HttpClientErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class Conflict extends HttpClientErrorException { + public static final class Conflict extends HttpClientErrorException { - Conflict(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private Conflict(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.CONFLICT, statusText, headers, body, charset); + } - super(message, HttpStatus.CONFLICT, statusText, headers, body, charset, url, method); + private Conflict(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(message, HttpStatus.CONFLICT, statusText, headers, body, charset); } } @@ -220,12 +280,14 @@ public static class Conflict extends HttpClientErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class Gone extends HttpClientErrorException { + public static final class Gone extends HttpClientErrorException { - Gone(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private Gone(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.GONE, statusText, headers, body, charset); + } - super(message, HttpStatus.GONE, statusText, headers, body, charset, url, method); + private Gone(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(message, HttpStatus.GONE, statusText, headers, body, charset); } } @@ -234,12 +296,16 @@ public static class Gone extends HttpClientErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class UnsupportedMediaType extends HttpClientErrorException { + public static final class UnsupportedMediaType extends HttpClientErrorException { - UnsupportedMediaType(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private UnsupportedMediaType(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, statusText, headers, body, charset); + } + + private UnsupportedMediaType(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.UNSUPPORTED_MEDIA_TYPE, statusText, headers, body, charset, url, method); + super(message, HttpStatus.UNSUPPORTED_MEDIA_TYPE, statusText, headers, body, charset); } } @@ -248,12 +314,16 @@ public static class UnsupportedMediaType extends HttpClientErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class UnprocessableEntity extends HttpClientErrorException { + public static final class UnprocessableEntity extends HttpClientErrorException { + + private UnprocessableEntity(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.UNPROCESSABLE_ENTITY, statusText, headers, body, charset); + } - UnprocessableEntity(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private UnprocessableEntity(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.UNPROCESSABLE_ENTITY, statusText, headers, body, charset, url, method); + super(message, HttpStatus.UNPROCESSABLE_ENTITY, statusText, headers, body, charset); } } @@ -262,12 +332,16 @@ public static class UnprocessableEntity extends HttpClientErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class TooManyRequests extends HttpClientErrorException { + public static final class TooManyRequests extends HttpClientErrorException { + + private TooManyRequests(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.TOO_MANY_REQUESTS, statusText, headers, body, charset); + } - TooManyRequests(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private TooManyRequests(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.TOO_MANY_REQUESTS, statusText, headers, body, charset, url, method); + super(message, HttpStatus.TOO_MANY_REQUESTS, statusText, headers, body, charset); } } diff --git a/spring-web/src/main/java/org/springframework/web/client/HttpErrorDetailsExtractor.java b/spring-web/src/main/java/org/springframework/web/client/HttpErrorDetailsExtractor.java deleted file mode 100644 index d141549c8569..000000000000 --- a/spring-web/src/main/java/org/springframework/web/client/HttpErrorDetailsExtractor.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.springframework.web.client; - -import java.net.URI; -import java.nio.charset.Charset; - -import org.jetbrains.annotations.NotNull; -import org.springframework.http.HttpMethod; -import org.springframework.lang.Nullable; - -/** - * Strategy interface used by the {@link DefaultResponseErrorHandler} to compose - * a summary of the http error. - * - * @author Jerzy Krolak - * @since 5.1 - */ -public interface HttpErrorDetailsExtractor { - - /** - * Assemble HTTP error response details string, based on the provided response details. - * @param rawStatusCode HTTP status code - * @param statusText HTTP status text - * @param responseBody response body - * @param responseCharset response charset - * @param url request URI - * @param method request method - * @return error details string - */ - @NotNull - String getErrorDetails(int rawStatusCode, String statusText, @Nullable byte[] responseBody, - @Nullable Charset responseCharset, @Nullable URI url, @Nullable HttpMethod method); - -} diff --git a/spring-web/src/main/java/org/springframework/web/client/HttpServerErrorException.java b/spring-web/src/main/java/org/springframework/web/client/HttpServerErrorException.java index 4a63be5cf160..d45eb16da9ce 100644 --- a/spring-web/src/main/java/org/springframework/web/client/HttpServerErrorException.java +++ b/spring-web/src/main/java/org/springframework/web/client/HttpServerErrorException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -16,11 +16,9 @@ package org.springframework.web.client; -import java.net.URI; import java.nio.charset.Charset; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.lang.Nullable; @@ -69,35 +67,59 @@ public HttpServerErrorException(HttpStatus statusCode, String statusText, } /** - * Constructor with a status code and status text, headers, content, request URL, and method. + * Constructor with a status code and status text, headers, content, and an + * prepared message. + * @since 5.2.2 */ public HttpServerErrorException(String message, HttpStatus statusCode, String statusText, - @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { - super(message, statusCode, statusText, headers, body, charset, url, method); + @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset charset) { + + super(message, statusCode, statusText, headers, body, charset); } /** * Create an {@code HttpServerErrorException} or an HTTP status specific sub-class. * @since 5.1 */ - public static HttpServerErrorException create( - String message, HttpStatus statusCode, String statusText, HttpHeaders headers, byte[] body, - @Nullable Charset charset, @Nullable URI url, @Nullable HttpMethod method) { + public static HttpServerErrorException create(HttpStatus statusCode, + String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + + return create(null, statusCode, statusText, headers, body, charset); + } + + /** + * Variant of {@link #create(String, HttpStatus, String, HttpHeaders, byte[], Charset)} + * with an optional prepared message. + * @since 5.2.2. + */ + public static HttpServerErrorException create(@Nullable String message, HttpStatus statusCode, + String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { switch (statusCode) { case INTERNAL_SERVER_ERROR: - return new HttpServerErrorException.InternalServerError(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpServerErrorException.InternalServerError(message, statusText, headers, body, charset) : + new HttpServerErrorException.InternalServerError(statusText, headers, body, charset); case NOT_IMPLEMENTED: - return new HttpServerErrorException.NotImplemented(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpServerErrorException.NotImplemented(message, statusText, headers, body, charset) : + new HttpServerErrorException.NotImplemented(statusText, headers, body, charset); case BAD_GATEWAY: - return new HttpServerErrorException.BadGateway(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpServerErrorException.BadGateway(message, statusText, headers, body, charset) : + new HttpServerErrorException.BadGateway(statusText, headers, body, charset); case SERVICE_UNAVAILABLE: - return new HttpServerErrorException.ServiceUnavailable(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpServerErrorException.ServiceUnavailable(message, statusText, headers, body, charset) : + new HttpServerErrorException.ServiceUnavailable(statusText, headers, body, charset); case GATEWAY_TIMEOUT: - return new HttpServerErrorException.GatewayTimeout(message, statusText, headers, body, charset, url, method); + return message != null ? + new HttpServerErrorException.GatewayTimeout(message, statusText, headers, body, charset) : + new HttpServerErrorException.GatewayTimeout(statusText, headers, body, charset); default: - return new HttpServerErrorException(message, statusCode, statusText, headers, body, charset, url, method); + return message != null ? + new HttpServerErrorException(message, statusCode, statusText, headers, body, charset) : + new HttpServerErrorException(statusCode, statusText, headers, body, charset); } } @@ -109,12 +131,16 @@ public static HttpServerErrorException create( * @since 5.1 */ @SuppressWarnings("serial") - public static class InternalServerError extends HttpServerErrorException { + public static final class InternalServerError extends HttpServerErrorException { + + private InternalServerError(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.INTERNAL_SERVER_ERROR, statusText, headers, body, charset); + } - InternalServerError(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private InternalServerError(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.INTERNAL_SERVER_ERROR, statusText, headers, body, charset, url, method); + super(message, HttpStatus.INTERNAL_SERVER_ERROR, statusText, headers, body, charset); } } @@ -123,12 +149,16 @@ public static class InternalServerError extends HttpServerErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class NotImplemented extends HttpServerErrorException { + public static final class NotImplemented extends HttpServerErrorException { - NotImplemented(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private NotImplemented(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.NOT_IMPLEMENTED, statusText, headers, body, charset); + } + + private NotImplemented(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.NOT_IMPLEMENTED, statusText, headers, body, charset, url, method); + super(message, HttpStatus.NOT_IMPLEMENTED, statusText, headers, body, charset); } } @@ -137,12 +167,16 @@ public static class NotImplemented extends HttpServerErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class BadGateway extends HttpServerErrorException { + public static final class BadGateway extends HttpServerErrorException { + + private BadGateway(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.BAD_GATEWAY, statusText, headers, body, charset); + } - BadGateway(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private BadGateway(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.BAD_GATEWAY, statusText, headers, body, charset, url, method); + super(message, HttpStatus.BAD_GATEWAY, statusText, headers, body, charset); } } @@ -151,12 +185,16 @@ public static class BadGateway extends HttpServerErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class ServiceUnavailable extends HttpServerErrorException { + public static final class ServiceUnavailable extends HttpServerErrorException { - ServiceUnavailable(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private ServiceUnavailable(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.SERVICE_UNAVAILABLE, statusText, headers, body, charset); + } + + private ServiceUnavailable(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.SERVICE_UNAVAILABLE, statusText, headers, body, charset, url, method); + super(message, HttpStatus.SERVICE_UNAVAILABLE, statusText, headers, body, charset); } } @@ -165,12 +203,16 @@ public static class ServiceUnavailable extends HttpServerErrorException { * @since 5.1 */ @SuppressWarnings("serial") - public static class GatewayTimeout extends HttpServerErrorException { + public static final class GatewayTimeout extends HttpServerErrorException { + + private GatewayTimeout(String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) { + super(HttpStatus.GATEWAY_TIMEOUT, statusText, headers, body, charset); + } - GatewayTimeout(String message, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, - @Nullable URI url, @Nullable HttpMethod method) { + private GatewayTimeout(String message, String statusText, + HttpHeaders headers, byte[] body, @Nullable Charset charset) { - super(message, HttpStatus.GATEWAY_TIMEOUT, statusText, headers, body, charset, url, method); + super(message, HttpStatus.GATEWAY_TIMEOUT, statusText, headers, body, charset); } } diff --git a/spring-web/src/main/java/org/springframework/web/client/HttpStatusCodeException.java b/spring-web/src/main/java/org/springframework/web/client/HttpStatusCodeException.java index 726e77558737..b660f15be870 100644 --- a/spring-web/src/main/java/org/springframework/web/client/HttpStatusCodeException.java +++ b/spring-web/src/main/java/org/springframework/web/client/HttpStatusCodeException.java @@ -16,11 +16,9 @@ package org.springframework.web.client; -import java.net.URI; import java.nio.charset.Charset; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.lang.Nullable; import org.springframework.util.StringUtils; @@ -85,8 +83,8 @@ protected HttpStatusCodeException(HttpStatus statusCode, String statusText, protected HttpStatusCodeException(HttpStatus statusCode, String statusText, @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset) { - this(getMessage(statusCode, statusText), statusCode, statusText, - responseHeaders, responseBody, responseCharset, null, null); + this(getMessage(statusCode, statusText), + statusCode, statusText, responseHeaders, responseBody, responseCharset); } /** @@ -98,15 +96,12 @@ protected HttpStatusCodeException(HttpStatus statusCode, String statusText, * @param responseHeaders the response headers, may be {@code null} * @param responseBody the response body content, may be {@code null} * @param responseCharset the response body charset, may be {@code null} - * @param url the request URL, may be {@code null} - * @param method the request method, may be {@code null} + * @since 5.2.2 */ protected HttpStatusCodeException(String message, HttpStatus statusCode, String statusText, - @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset, - @Nullable URI url, @Nullable HttpMethod method) { + @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset) { - super(message, statusCode.value(), statusText, responseHeaders, responseBody, - responseCharset, url, method); + super(message, statusCode.value(), statusText, responseHeaders, responseBody, responseCharset); this.statusCode = statusCode; } diff --git a/spring-web/src/main/java/org/springframework/web/client/RestClientResponseException.java b/spring-web/src/main/java/org/springframework/web/client/RestClientResponseException.java index 5410096477a4..2a927f376905 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestClientResponseException.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestClientResponseException.java @@ -17,12 +17,10 @@ package org.springframework.web.client; import java.io.UnsupportedEncodingException; -import java.net.URI; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; import org.springframework.lang.Nullable; /** @@ -50,12 +48,6 @@ public class RestClientResponseException extends RestClientException { @Nullable private final String responseCharset; - @Nullable - private final HttpMethod method; - - @Nullable - private final URI url; - /** * Construct a new instance of with the given response data. @@ -67,22 +59,6 @@ public class RestClientResponseException extends RestClientException { */ public RestClientResponseException(String message, int statusCode, String statusText, @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset) { - this(message, statusCode, statusText, responseHeaders, responseBody, responseCharset, null, null); - } - - /** - * Construct a new instance of with the given response data. - * @param statusCode the raw status code value - * @param statusText the status text - * @param responseHeaders the response headers (may be {@code null}) - * @param responseBody the response body content (may be {@code null}) - * @param responseCharset the response body charset (may be {@code null}) - * @param url the request URL (may be {@code null}) - * @param method the request method (may be {@code null}) - */ - public RestClientResponseException(String message, int statusCode, String statusText, - @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset, - @Nullable URI url, @Nullable HttpMethod method) { super(message); this.rawStatusCode = statusCode; @@ -90,8 +66,6 @@ public RestClientResponseException(String message, int statusCode, String status this.responseHeaders = responseHeaders; this.responseBody = (responseBody != null ? responseBody : new byte[0]); this.responseCharset = (responseCharset != null ? responseCharset.name() : null); - this.method = method; - this.url = url; } @@ -124,20 +98,6 @@ public byte[] getResponseBodyAsByteArray() { return this.responseBody; } - /** - * Return the HTTP request method. - */ - public HttpMethod getMethod() { - return method; - } - - /** - * Return the HTTP request url. - */ - public URI getUrl() { - return url; - } - /** * Return the response body converted to String. The charset used is that * of the response "Content-Type" or otherwise {@code "UTF-8"}. diff --git a/spring-web/src/main/java/org/springframework/web/client/UnknownHttpStatusCodeException.java b/spring-web/src/main/java/org/springframework/web/client/UnknownHttpStatusCodeException.java index 79d5544ad022..c7b0319018d4 100644 --- a/spring-web/src/main/java/org/springframework/web/client/UnknownHttpStatusCodeException.java +++ b/spring-web/src/main/java/org/springframework/web/client/UnknownHttpStatusCodeException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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. @@ -16,11 +16,9 @@ package org.springframework.web.client; -import java.net.URI; import java.nio.charset.Charset; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.lang.Nullable; @@ -48,7 +46,7 @@ public UnknownHttpStatusCodeException(int rawStatusCode, String statusText, @Nul @Nullable byte[] responseBody, @Nullable Charset responseCharset) { this("Unknown status code [" + rawStatusCode + "]" + " " + statusText, - rawStatusCode, statusText, responseHeaders, responseBody, responseCharset, null, null); + rawStatusCode, statusText, responseHeaders, responseBody, responseCharset); } /** @@ -59,12 +57,11 @@ public UnknownHttpStatusCodeException(int rawStatusCode, String statusText, @Nul * @param responseHeaders the response headers (may be {@code null}) * @param responseBody the response body content (may be {@code null}) * @param responseCharset the response body charset (may be {@code null}) - * @param url the request URI (may be {@code null}) - * @param method the request HTTP method (may be {@code null}) + * @since 5.2.2 */ - public UnknownHttpStatusCodeException(String message, int rawStatusCode, String statusText, @Nullable HttpHeaders responseHeaders, - @Nullable byte[] responseBody, @Nullable Charset responseCharset, @Nullable URI url, @Nullable HttpMethod method) { + public UnknownHttpStatusCodeException(String message, int rawStatusCode, String statusText, + @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset) { - super(message, rawStatusCode, statusText, responseHeaders, responseBody, responseCharset, url, method); + super(message, rawStatusCode, statusText, responseHeaders, responseBody, responseCharset); } } diff --git a/spring-web/src/test/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractorTests.java b/spring-web/src/test/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractorTests.java deleted file mode 100644 index 94804ac69f8a..000000000000 --- a/spring-web/src/test/java/org/springframework/web/client/DefaultHttpErrorDetailsExtractorTests.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.springframework.web.client; - -import java.net.URI; - -import com.google.common.base.Strings; -import org.junit.Test; - -import static java.nio.charset.StandardCharsets.*; -import static org.junit.Assert.*; -import static org.springframework.http.HttpMethod.*; -import static org.springframework.http.HttpStatus.*; - -public class DefaultHttpErrorDetailsExtractorTests { - - private final DefaultHttpErrorDetailsExtractor extractor = new DefaultHttpErrorDetailsExtractor(); - - @Test - public void shouldGetSimpleExceptionMessage() { - String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", null, null, null, null); - - assertEquals("Should get a simple message", "404 Not Found", actual); - } - - @Test - public void shouldGetCompleteMessageWithoutBody() { - String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", null, null, URI.create("http://localhost:8080/my-endpoint"), GET); - - assertEquals("Should get a complete message without body", "404 Not Found after GET http://localhost:8080/my-endpoint : [no body]", actual); - } - - @Test - public void shouldGetCompleteMessageWithShortAsciiBodyNoCharset() { - String responseBody = "my short response body"; - - String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(), null, URI.create("http://localhost:8080/my-endpoint"), GET); - - assertEquals("Should get a simple message", "404 Not Found after GET http://localhost:8080/my-endpoint : [my short response body]", actual); - } - - @Test - public void shouldGetCompleteMessageWithShortAsciiBodyUtfCharset() { - String responseBody = "my short response body"; - - String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(), UTF_8, URI.create("http://localhost:8080/my-endpoint"), GET); - - assertEquals("Should get a simple message", "404 Not Found after GET http://localhost:8080/my-endpoint : [my short response body]", actual); - } - - @Test - public void shouldGetCompleteMessageWithShortUtfBodyUtfCharset() { - String responseBody = "my short response body \u0105\u0119"; - - String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(), UTF_8, URI.create("http://localhost:8080/my-endpoint"), GET); - - assertEquals("Should get a simple message", "404 Not Found after GET http://localhost:8080/my-endpoint : [my short response body \u0105\u0119]", actual); - } - - @Test - public void shouldGetCompleteMessageWithShortUtfBodyNoCharset() { - String responseBody = "my short response body \u0105\u0119"; - - String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(UTF_8), null, URI.create("http://localhost:8080/my-endpoint"), GET); - - assertEquals("Should get a simple message", "404 Not Found after GET http://localhost:8080/my-endpoint : [my short response body \u00c4\u0085\u00c4\u0099]", actual); - } - - @Test - public void shouldGetCompleteMessageWithLongAsciiBodyNoCharset() { - String responseBody = Strings.repeat("asdfg", 100); - String expectedMessage = "404 Not Found after GET http://localhost:8080/my-endpoint : [" + Strings.repeat("asdfg", 40) + "... (500 bytes)]"; - - String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(UTF_8), null, URI.create("http://localhost:8080/my-endpoint"), GET); - - assertEquals("Should get a simple message", expectedMessage, actual); - } - - @Test - public void shouldGetCompleteMessageWithLongUtfBodyNoCharset() { - String responseBody = Strings.repeat("asd\u0105\u0119", 100); - String expectedMessage = "404 Not Found after GET http://localhost:8080/my-endpoint : [" + Strings.repeat("asd\u00c4\u0085\u00c4\u0099", 28) + "asd\u00c4... (700 bytes)]"; - - String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(UTF_8), null, URI.create("http://localhost:8080/my-endpoint"), GET); - - assertEquals("Should get a simple message", expectedMessage, actual); - } - - @Test - public void shouldGetCompleteMessageWithLongUtfBodyUtfCharset() { - String responseBody = Strings.repeat("asd\u0105\u0119", 100); - String expectedMessage = "404 Not Found after GET http://localhost:8080/my-endpoint : [" + Strings.repeat("asd\u0105\u0119", 40) + "... (700 bytes)]"; - - String actual = extractor.getErrorDetails(NOT_FOUND.value(), "Not Found", responseBody.getBytes(UTF_8), UTF_8, URI.create("http://localhost:8080/my-endpoint"), GET); - - assertEquals("Should get a simple message", expectedMessage, actual); - } - -} \ No newline at end of file diff --git a/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerTests.java b/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerTests.java index e9f782609378..c5c05c48e426 100644 --- a/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerTests.java @@ -19,8 +19,10 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.util.function.Function; import org.junit.jupiter.api.Test; +import reactor.core.publisher.Flux; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -69,9 +71,28 @@ public void handleError() throws Exception { given(response.getHeaders()).willReturn(headers); given(response.getBody()).willReturn(new ByteArrayInputStream("Hello World".getBytes(StandardCharsets.UTF_8))); - assertThatExceptionOfType(HttpClientErrorException.class).isThrownBy(() -> - handler.handleError(response)) - .satisfies(ex -> assertThat(ex.getResponseHeaders()).isSameAs(headers)); + assertThatExceptionOfType(HttpClientErrorException.class) + .isThrownBy(() -> handler.handleError(response)) + .satisfies(ex -> assertThat(ex.getResponseHeaders()).isSameAs(headers)) + .satisfies(ex -> assertThat(ex.getMessage()).isEqualTo("404 Not Found: [Hello World]")); + } + + @Test + public void handleErrorWithLongBody() throws Exception { + + Function bodyGenerator = + size -> Flux.just("a").repeat(size-1).reduce((s, s2) -> s + s2).block(); + + given(response.getRawStatusCode()).willReturn(HttpStatus.NOT_FOUND.value()); + given(response.getStatusText()).willReturn("Not Found"); + given(response.getHeaders()).willReturn(new HttpHeaders()); + given(response.getBody()).willReturn( + new ByteArrayInputStream(bodyGenerator.apply(500).getBytes(StandardCharsets.UTF_8))); + + assertThatExceptionOfType(HttpClientErrorException.class) + .isThrownBy(() -> handler.handleError(response)) + .satisfies(ex -> assertThat(ex.getMessage()).isEqualTo( + "404 Not Found: [" + bodyGenerator.apply(200) + "... (500 bytes)]")); } @Test @@ -84,8 +105,7 @@ public void handleErrorIOException() throws Exception { given(response.getHeaders()).willReturn(headers); given(response.getBody()).willThrow(new IOException()); - assertThatExceptionOfType(HttpClientErrorException.class).isThrownBy(() -> - handler.handleError(response)); + assertThatExceptionOfType(HttpClientErrorException.class).isThrownBy(() -> handler.handleError(response)); } @Test diff --git a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java index 631725b6bd29..f53cf890c79b 100644 --- a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java @@ -254,8 +254,7 @@ void badRequest(ClientHttpRequestFactory clientHttpRequestFactory) { template.execute(baseUrl + "/status/badrequest", HttpMethod.GET, null, null)) .satisfies(ex -> { assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); - assertThat(ex.getMessage()).isEqualTo( - "400 Client Error after GET http://localhost:" + port + "/status/badrequest : [no body]"); + assertThat(ex.getMessage()).isEqualTo("400 Client Error: [no body]"); }); } From f2b926467491098b09b38296b95d9543c97e22ad Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 13 Nov 2019 14:42:32 +0000 Subject: [PATCH 0052/2315] Remove Jetbrains annotations --- .../core/io/buffer/LeakAwareDataBufferFactory.java | 2 -- .../web/servlet/function/DefaultServerRequest.java | 4 ---- .../web/servlet/function/DefaultServerRequestBuilder.java | 6 ++---- .../web/servlet/function/support/RouterFunctionMapping.java | 4 +--- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactory.java b/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactory.java index 9c3dd02c2a23..4769e3a23aa6 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactory.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactory.java @@ -27,7 +27,6 @@ import io.netty.buffer.PooledByteBufAllocator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jetbrains.annotations.NotNull; import org.springframework.util.Assert; @@ -113,7 +112,6 @@ public DataBuffer allocateBuffer(int initialCapacity) { return createLeakAwareDataBuffer(this.delegate.allocateBuffer(initialCapacity)); } - @NotNull private DataBuffer createLeakAwareDataBuffer(DataBuffer delegateBuffer) { LeakAwareDataBuffer dataBuffer = new LeakAwareDataBuffer(delegateBuffer, this); if (this.trackCreated.get()) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java index 4431499f66b5..65b65d442372 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java @@ -40,8 +40,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; -import org.jetbrains.annotations.NotNull; - import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpRange; @@ -322,7 +320,6 @@ private ServletParametersMap(HttpServletRequest servletRequest) { this.servletRequest = servletRequest; } - @NotNull @Override public Set>> entrySet() { return this.servletRequest.getParameterMap().entrySet().stream() @@ -388,7 +385,6 @@ public void clear() { attributeNames.forEach(this.servletRequest::removeAttribute); } - @NotNull @Override public Set> entrySet() { return Collections.list(this.servletRequest.getAttributeNames()).stream() diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequestBuilder.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequestBuilder.java index 762d058ccda0..cc8c44dca77c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequestBuilder.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequestBuilder.java @@ -38,8 +38,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; -import org.jetbrains.annotations.NotNull; - import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpInputMessage; @@ -349,12 +347,12 @@ public int read() throws IOException { } @Override - public int read(@NotNull byte[] b, int off, int len) throws IOException { + public int read(byte[] b, int off, int len) throws IOException { return this.delegate.read(b, off, len); } @Override - public int read(@NotNull byte[] b) throws IOException { + public int read(byte[] b) throws IOException { return this.delegate.read(b); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java index 3aa46358d7b7..55dfa41e4df3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java @@ -23,8 +23,6 @@ import javax.servlet.http.HttpServletRequest; -import org.jetbrains.annotations.NotNull; - import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.ApplicationContext; @@ -167,7 +165,7 @@ private void initMessageConverters() { @Nullable @Override - protected Object getHandlerInternal(@NotNull HttpServletRequest servletRequest) throws Exception { + protected Object getHandlerInternal(HttpServletRequest servletRequest) throws Exception { String lookupPath = getUrlPathHelper().getLookupPathForRequest(servletRequest); servletRequest.setAttribute(LOOKUP_PATH, lookupPath); if (this.routerFunction != null) { From 2c1afca9c556b63c1645630b1db8d2934d1f2033 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 13 Nov 2019 15:03:22 +0000 Subject: [PATCH 0053/2315] Reject null form data names ...or skip if there are no values either. Closes gh-22372 --- .../http/converter/FormHttpMessageConverter.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java index fa79ef77aa01..ced2ae1767f9 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java @@ -40,6 +40,7 @@ import org.springframework.http.StreamingHttpOutputMessage; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MimeTypeUtils; import org.springframework.util.MultiValueMap; @@ -415,7 +416,11 @@ else if (mediaType.getCharset() == null) { protected String serializeForm(MultiValueMap formData, Charset charset) { StringBuilder builder = new StringBuilder(); - formData.forEach((name, values) -> + formData.forEach((name, values) -> { + if (name == null) { + Assert.isTrue(CollectionUtils.isEmpty(values), "Null name in form data: " + formData); + return; + } values.forEach(value -> { try { if (builder.length() != 0) { @@ -430,7 +435,8 @@ protected String serializeForm(MultiValueMap formData, Charset c catch (UnsupportedEncodingException ex) { throw new IllegalStateException(ex); } - })); + }); + }); return builder.toString(); } From 55011e7a0fb92b3dbcc52da23bc28dfae5b2b6b0 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 13 Nov 2019 16:17:01 +0100 Subject: [PATCH 0054/2315] Note on injecting results from local @Bean methods (self references) Closes gh-23934 --- src/docs/asciidoc/core/core-beans.adoc | 33 ++++++++++++++++++-------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc index a7b1fa44d06b..29e7f9d26450 100644 --- a/src/docs/asciidoc/core/core-beans.adoc +++ b/src/docs/asciidoc/core/core-beans.adoc @@ -5428,6 +5428,7 @@ If there is no other resolution indicator (such as a qualifier or a primary mark for a non-unique dependency situation, Spring matches the injection point name (that is, the field name or parameter name) against the target bean names and choose the same-named candidate, if any. +==== That said, if you intend to express annotation-driven injection by name, do not primarily use `@Autowired`, even if it is capable of selecting by bean name among @@ -5451,16 +5452,28 @@ back to the bean that is currently injected). Note that self injection is a fall Regular dependencies on other components always have precedence. In that sense, self references do not participate in regular candidate selection and are therefore in particular never primary. On the contrary, they always end up as lowest precedence. -In practice, you should use self references as a last resort only (for example, for calling other methods -on the same instance through the bean's transactional proxy). Consider factoring out -the effected methods to a separate delegate bean in such a scenario. Alternatively, you -can use `@Resource`, which may obtain a proxy back to the current bean by its unique name. +In practice, you should use self references as a last resort only (for example, for +calling other methods on the same instance through the bean's transactional proxy). +Consider factoring out the effected methods to a separate delegate bean in such a scenario. +Alternatively, you can use `@Resource`, which may obtain a proxy back to the current bean +by its unique name. + +[NOTE] +==== +Trying to inject the results from `@Bean` methods on the same configuration class is +effectively a self-reference scenario as well. Either lazily resolve such references +in the method signature where it is actually needed (as opposed to an autowired field +in the configuration class) or declare the affected `@Bean` methods as `static`, +decoupling them from the containing configuration class instance and its lifecycle. +Otherwise, such beans are only considered in the fallback phase, with matching beans +on other configuration classes selected as primary candidates instead (if available). +==== `@Autowired` applies to fields, constructors, and multi-argument methods, allowing for narrowing through qualifier annotations at the parameter level. In contrast, `@Resource` is supported only for fields and bean property setter methods with a single argument. -As a consequence, you should stick with qualifiers if your injection target is a constructor or a -multi-argument method. +As a consequence, you should stick with qualifiers if your injection target is a +constructor or a multi-argument method. You can create your own custom qualifier annotations. To do so, define an annotation and provide the `@Qualifier` annotation within your definition, as the following example shows: @@ -6849,12 +6862,12 @@ constraints applying. ==== You may declare `@Bean` methods as `static`, allowing for them to be called without creating their containing configuration class as an instance. This makes particular -sense when defining post-processor beans (for example, of type `BeanFactoryPostProcessor` or -`BeanPostProcessor`), since such beans get initialized early in the container +sense when defining post-processor beans (for example, of type `BeanFactoryPostProcessor` +or `BeanPostProcessor`), since such beans get initialized early in the container lifecycle and should avoid triggering other parts of the configuration at that point. -Calls to static `@Bean` methods never get intercepted by the container, -not even within `@Configuration` classes (as described earlier in this section), due to technical +Calls to static `@Bean` methods never get intercepted by the container, not even within +`@Configuration` classes (as described earlier in this section), due to technical limitations: CGLIB subclassing can override only non-static methods. As a consequence, a direct call to another `@Bean` method has standard Java semantics, resulting in an independent instance being returned straight from the factory method itself. From 32532a88c1aa24c902a09481f34e6a7bb2806fde Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 13 Nov 2019 16:17:08 +0100 Subject: [PATCH 0055/2315] Polishing --- .../transport/handler/EventSourceTransportHandler.java | 8 ++++---- .../transport/handler/HtmlFileTransportHandler.java | 4 ++-- .../transport/handler/WebSocketTransportHandler.java | 4 ++-- .../transport/handler/XhrPollingTransportHandler.java | 4 ++-- .../transport/handler/XhrStreamingTransportHandler.java | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java index b4ee97198a25..90b56c378c5c 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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. @@ -50,7 +50,7 @@ protected MediaType getContentType() { @Override public boolean checkSessionType(SockJsSession session) { - return session instanceof EventSourceStreamingSockJsSession; + return (session instanceof EventSourceStreamingSockJsSession); } @Override @@ -66,7 +66,7 @@ protected SockJsFrameFormat getFrameFormat(ServerHttpRequest request) { } - private class EventSourceStreamingSockJsSession extends StreamingSockJsSession { + private static class EventSourceStreamingSockJsSession extends StreamingSockJsSession { public EventSourceStreamingSockJsSession(String sessionId, SockJsServiceConfig config, WebSocketHandler wsHandler, Map attributes) { @@ -76,7 +76,7 @@ public EventSourceStreamingSockJsSession(String sessionId, SockJsServiceConfig c @Override protected byte[] getPrelude(ServerHttpRequest request) { - return new byte[] { '\r', '\n' }; + return new byte[] {'\r', '\n'}; } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java index 6473af39ca72..d39f51bbf9db 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -93,7 +93,7 @@ protected MediaType getContentType() { @Override public boolean checkSessionType(SockJsSession session) { - return session instanceof HtmlFileStreamingSockJsSession; + return (session instanceof HtmlFileStreamingSockJsSession); } @Override diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java index e4d67b0217a5..60423319dc6d 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -107,7 +107,7 @@ public boolean isRunning() { @Override public boolean checkSessionType(SockJsSession session) { - return session instanceof WebSocketServerSockJsSession; + return (session instanceof WebSocketServerSockJsSession); } @Override diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrPollingTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrPollingTransportHandler.java index 5e98adc36077..95a065801f68 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrPollingTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrPollingTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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,7 +54,7 @@ protected SockJsFrameFormat getFrameFormat(ServerHttpRequest request) { @Override public boolean checkSessionType(SockJsSession session) { - return session instanceof PollingSockJsSession; + return (session instanceof PollingSockJsSession); } @Override diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrStreamingTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrStreamingTransportHandler.java index af6f2bef16b2..f947643205ce 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrStreamingTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrStreamingTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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. @@ -59,7 +59,7 @@ protected MediaType getContentType() { @Override public boolean checkSessionType(SockJsSession session) { - return session instanceof XhrStreamingSockJsSession; + return (session instanceof XhrStreamingSockJsSession); } @Override From 22211a01ce5e07331a20fd9c256073a9d5392ce1 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 13 Nov 2019 17:23:23 +0100 Subject: [PATCH 0056/2315] Polishing --- .../beans/factory/support/ConstructorResolver.java | 4 +++- .../event/AnnotationDrivenEventListenerTests.java | 13 ++++++++----- .../core/codec/AbstractDataBufferDecoder.java | 1 + .../codec/ServerSentEventHttpMessageReader.java | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java index d98b72efc732..e5acd029ea47 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java @@ -486,7 +486,9 @@ public BeanWrapper instantiateUsingFactoryMethod( } } - candidates.sort(AutowireUtils.EXECUTABLE_COMPARATOR); + if (candidates.size() > 1) { // explicitly skip immutable singletonList + candidates.sort(AutowireUtils.EXECUTABLE_COMPARATOR); + } ConstructorArgumentValues resolvedValues = null; boolean autowiring = (mbd.getResolvedAutowireMode() == AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR); diff --git a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java index 1462146b9bc7..95ead7c1d922 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java @@ -850,9 +850,9 @@ public void handleIt(TestEvent event) { this.eventCollector.addEvent(this, event); } - @Override @EventListener @Async + @Override public void handleAsync(AnotherTestEvent event) { assertThat(Thread.currentThread().getName()).isNotEqualTo(event.content); this.eventCollector.addEvent(this, event); @@ -877,9 +877,9 @@ public void handleIt(TestEvent event) { this.eventCollector.addEvent(this, event); } - @Override @EventListener @Async + @Override public void handleAsync(AnotherTestEvent event) { assertThat(Thread.currentThread().getName()).isNotEqualTo(event.content); this.eventCollector.addEvent(this, event); @@ -994,20 +994,20 @@ public void handle(TestEvent event) { super.handle(event); } - @Override @EventListener(condition = "#payload.startsWith('OK')") + @Override public void handleString(String payload) { super.handleString(payload); } - @Override @ConditionalEvent("#root.event.timestamp > #p0") + @Override public void handleTimestamp(Long timestamp) { collectEvent(timestamp); } - @Override @ConditionalEvent("@conditionEvaluator.valid(#p0)") + @Override public void handleRatio(Double ratio) { collectEvent(ratio); } @@ -1085,6 +1085,7 @@ public String getConversationId() { } } + @Configuration @Import(UseMissingEventListener.class) public static class MissingEventListener { @@ -1095,6 +1096,7 @@ public MyEventListener missing() { } } + @Component public static class MyEventListener { @@ -1104,6 +1106,7 @@ public void hear(TestEvent e) { } } + public static class UseMissingEventListener { @Inject diff --git a/spring-core/src/main/java/org/springframework/core/codec/AbstractDataBufferDecoder.java b/spring-core/src/main/java/org/springframework/core/codec/AbstractDataBufferDecoder.java index ff01c0b47f44..0fd5870b2a2e 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/AbstractDataBufferDecoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/AbstractDataBufferDecoder.java @@ -102,6 +102,7 @@ public Mono decodeToMono(Publisher input, ResolvableType elementT * {@link #decode(DataBuffer, ResolvableType, MimeType, Map)} instead */ @Deprecated + @Nullable protected T decodeDataBuffer(DataBuffer buffer, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map hints) { diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java index b7553e168c7b..d6b9c9cb9db7 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java @@ -155,6 +155,7 @@ else if (line.startsWith(":")) { } } + @Nullable private Object decodeData(String data, ResolvableType dataType, Map hints) { if (String.class == dataType.resolve()) { return data.substring(0, data.length() - 1); From 6fa9871a7001b9f3a7bcb325dcd6981cfdf2c025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Wed, 13 Nov 2019 16:58:48 +0100 Subject: [PATCH 0057/2315] Provide orNull extensions for WebFlux ServerRequest Closes gh-23761 --- .../server/ServerRequestExtensions.kt | 56 ++++++++++++ .../server/ServerRequestExtensionsTests.kt | 90 +++++++++++++++++++ 2 files changed, 146 insertions(+) diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt index 7847bc627d0a..2c8df65950ae 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt @@ -21,11 +21,14 @@ import kotlinx.coroutines.reactive.awaitFirstOrNull import kotlinx.coroutines.reactive.awaitSingle import kotlinx.coroutines.reactive.asFlow import org.springframework.core.ParameterizedTypeReference +import org.springframework.http.MediaType import org.springframework.http.codec.multipart.Part +import org.springframework.util.CollectionUtils import org.springframework.util.MultiValueMap import org.springframework.web.server.WebSession import reactor.core.publisher.Flux import reactor.core.publisher.Mono +import java.net.InetSocketAddress import java.security.Principal /** @@ -112,3 +115,56 @@ suspend fun ServerRequest.awaitPrincipal(): Principal? = */ suspend fun ServerRequest.awaitSession(): WebSession = session().awaitSingle() + +/** + * Nullable variant of [ServerRequest.remoteAddress] + * + * @author Sebastien Deleuze + * @since 5.2.2 + */ +fun ServerRequest.remoteAddressOrNull(): InetSocketAddress? = remoteAddress().orElse(null) + +/** + * Nullable variant of [ServerRequest.attribute] + * + * @author Sebastien Deleuze + * @since 5.2.2 + */ +fun ServerRequest.attributeOrNull(name: String): Any? = attributes()[name] + +/** + * Nullable variant of [ServerRequest.queryParam] + * + * @author Sebastien Deleuze + * @since 5.2.2 + */ +fun ServerRequest.queryParamOrNull(name: String): String? { + val queryParamValues = queryParams()[name] + return if (CollectionUtils.isEmpty(queryParamValues)) { + null + } else { + var value: String? = queryParamValues!![0] + if (value == null) { + value = "" + } + value + } +} + +/** + * Nullable variant of [ServerRequest.Headers.contentLength] + * + * @author Sebastien Deleuze + * @since 5.2.2 + */ +fun ServerRequest.Headers.contentLengthOrNull(): Long? = + contentLength().run { if (isPresent) asLong else null } + +/** + * Nullable variant of [ServerRequest.Headers.contentType] + * + * @author Sebastien Deleuze + * @since 5.2.2 + */ +fun ServerRequest.Headers.contentTypeOrNull(): MediaType? = + contentType().orElse(null) diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt index 6d1b7960306f..4922b0409704 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt @@ -23,11 +23,15 @@ import kotlinx.coroutines.runBlocking import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.core.ParameterizedTypeReference +import org.springframework.http.MediaType import org.springframework.http.codec.multipart.Part +import org.springframework.util.CollectionUtils import org.springframework.util.MultiValueMap import org.springframework.web.server.WebSession import reactor.core.publisher.Mono +import java.net.InetSocketAddress import java.security.Principal +import java.util.* /** * Mock object based tests for [ServerRequest] Kotlin extensions. @@ -38,6 +42,8 @@ class ServerRequestExtensionsTests { val request = mockk(relaxed = true) + val headers = mockk(relaxed = true) + @Test fun `bodyToMono with reified type parameters`() { request.bodyToMono>() @@ -108,6 +114,90 @@ class ServerRequestExtensionsTests { } } + @Test + fun `remoteAddressOrNull with value`() { + val remoteAddress = InetSocketAddress(1234) + every { request.remoteAddress() } returns Optional.of(remoteAddress) + assertThat(remoteAddress).isEqualTo(request.remoteAddressOrNull()) + verify { request.remoteAddress() } + } + + @Test + fun `remoteAddressOrNull with null`() { + every { request.remoteAddress() } returns Optional.empty() + assertThat(request.remoteAddressOrNull()).isNull() + verify { request.remoteAddress() } + } + + @Test + fun `attributeOrNull with value`() { + every { request.attributes() } returns mapOf("foo" to "bar") + assertThat(request.attributeOrNull("foo")).isEqualTo("bar") + verify { request.attributes() } + } + + @Test + fun `attributeOrNull with null`() { + every { request.attributes() } returns mapOf("foo" to "bar") + assertThat(request.attributeOrNull("baz")).isNull() + verify { request.attributes() } + } + + @Test + fun `queryParamOrNull with value`() { + every { request.queryParams() } returns CollectionUtils.toMultiValueMap(mapOf("foo" to listOf("bar"))) + assertThat(request.queryParamOrNull("foo")).isEqualTo("bar") + verify { request.queryParams() } + } + + @Test + fun `queryParamOrNull with values`() { + every { request.queryParams() } returns CollectionUtils.toMultiValueMap(mapOf("foo" to listOf("bar", "bar"))) + assertThat(request.queryParamOrNull("foo")).isEqualTo("bar") + verify { request.queryParams() } + } + + @Test + fun `queryParamOrNull with null value`() { + every { request.queryParams() } returns CollectionUtils.toMultiValueMap(mapOf("foo" to listOf(null))) + assertThat(request.queryParamOrNull("foo")).isEqualTo("") + verify { request.queryParams() } + } + + @Test + fun `queryParamOrNull with null`() { + every { request.queryParams() } returns CollectionUtils.toMultiValueMap(mapOf("foo" to listOf("bar"))) + assertThat(request.queryParamOrNull("baz")).isNull() + verify { request.queryParams() } + } + + @Test + fun `contentLengthOrNull with value`() { + every { headers.contentLength() } returns OptionalLong.of(123) + assertThat(headers.contentLengthOrNull()).isEqualTo(123) + verify { headers.contentLength() } + } + + @Test + fun `contentLengthOrNull with null`() { + every { headers.contentLength() } returns OptionalLong.empty() + assertThat(headers.contentLengthOrNull()).isNull() + verify { headers.contentLength() } + } + + @Test + fun `contentTypeOrNull with value`() { + every { headers.contentType() } returns Optional.of(MediaType.APPLICATION_JSON) + assertThat(headers.contentTypeOrNull()).isEqualTo(MediaType.APPLICATION_JSON) + verify { headers.contentType() } + } + + @Test + fun `contentTypeOrNull with null`() { + every { headers.contentType() } returns Optional.empty() + assertThat(headers.contentTypeOrNull()).isNull() + verify { headers.contentType() } + } class Foo } From 3dc5e7b1d5fb166e66b0eb718aa57d246e967de9 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 13 Nov 2019 23:41:26 +0100 Subject: [PATCH 0058/2315] Avoid String concatenation for lookup in StaticMessageSource Closes gh-22451 --- .../context/support/StaticMessageSource.java | 72 ++++++++++++++----- .../support/StaticMessageSourceTests.java | 1 - 2 files changed, 54 insertions(+), 19 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/support/StaticMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/StaticMessageSource.java index 26df79d7b711..9f8ace3ab2fd 100644 --- a/spring-context/src/main/java/org/springframework/context/support/StaticMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/StaticMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -36,33 +36,35 @@ */ public class StaticMessageSource extends AbstractMessageSource { - /** Map from 'code + locale' keys to message Strings. */ - private final Map messages = new HashMap<>(); - - private final Map cachedMessageFormats = new HashMap<>(); + private final Map> messageMap = new HashMap<>(); @Override + @Nullable protected String resolveCodeWithoutArguments(String code, Locale locale) { - return this.messages.get(code + '_' + locale.toString()); + Map localeMap = this.messageMap.get(code); + if (localeMap == null) { + return null; + } + MessageHolder holder = localeMap.get(locale); + if (holder == null) { + return null; + } + return holder.getMessage(); } @Override @Nullable protected MessageFormat resolveCode(String code, Locale locale) { - String key = code + '_' + locale.toString(); - String msg = this.messages.get(key); - if (msg == null) { + Map localeMap = this.messageMap.get(code); + if (localeMap == null) { return null; } - synchronized (this.cachedMessageFormats) { - MessageFormat messageFormat = this.cachedMessageFormats.get(key); - if (messageFormat == null) { - messageFormat = createMessageFormat(msg, locale); - this.cachedMessageFormats.put(key, messageFormat); - } - return messageFormat; + MessageHolder holder = localeMap.get(locale); + if (holder == null) { + return null; } + return holder.getMessageFormat(); } /** @@ -75,7 +77,7 @@ public void addMessage(String code, Locale locale, String msg) { Assert.notNull(code, "Code must not be null"); Assert.notNull(locale, "Locale must not be null"); Assert.notNull(msg, "Message must not be null"); - this.messages.put(code + '_' + locale.toString(), msg); + this.messageMap.computeIfAbsent(code, key -> new HashMap<>(4)).put(locale, new MessageHolder(msg, locale)); if (logger.isDebugEnabled()) { logger.debug("Added message [" + msg + "] for code [" + code + "] and Locale [" + locale + "]"); } @@ -95,7 +97,41 @@ public void addMessages(Map messages, Locale locale) { @Override public String toString() { - return getClass().getName() + ": " + this.messages; + return getClass().getName() + ": " + this.messageMap; + } + + + private class MessageHolder { + + private final String message; + + private final Locale locale; + + @Nullable + private volatile MessageFormat cachedFormat; + + public MessageHolder(String message, Locale locale) { + this.message = message; + this.locale = locale; + } + + public String getMessage() { + return this.message; + } + + public MessageFormat getMessageFormat() { + MessageFormat messageFormat = this.cachedFormat; + if (messageFormat == null) { + messageFormat = createMessageFormat(this.message, this.locale); + this.cachedFormat = messageFormat; + } + return messageFormat; + } + + @Override + public String toString() { + return this.message; + } } } diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java index 5c0a5e122323..ca5b1bf675a6 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java @@ -59,7 +59,6 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { @Test @Override public void count() { - // These are only checked for current Ctx (not parent ctx) assertCount(15); } From a0e4ac39bf9430ec995ce4bb321ee694d742ffb9 Mon Sep 17 00:00:00 2001 From: monosoul Date: Wed, 30 Oct 2019 15:14:13 +0100 Subject: [PATCH 0059/2315] Inverse condition to fix ISO-formatted Instant parsing Prior to this commit, InstantFormatter was able to properly serialize an Instant that is far in the future (or in the past), but it could not properly deserialize it, because in such scenarios an ISO-formatted Instant starts with a +/- sign. This commit fixes this issue, while maintaining the previous contract, and also introduces tests for InstantFormatter. Closes gh-23895 --- .../datetime/standard/InstantFormatter.java | 10 +- .../standard/InstantFormatterTests.java | 119 ++++++++++++++++++ 2 files changed, 124 insertions(+), 5 deletions(-) create mode 100644 spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java index 985006e3ba38..010d004ae5d7 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java @@ -40,14 +40,14 @@ public class InstantFormatter implements Formatter { @Override public Instant parse(String text, Locale locale) throws ParseException { - if (text.length() > 0 && Character.isDigit(text.charAt(0))) { - // assuming UTC instant a la "2007-12-03T10:15:30.00Z" - return Instant.parse(text); - } - else { + if (text.length() > 0 && Character.isAlphabetic(text.charAt(0))) { // assuming RFC-1123 value a la "Tue, 3 Jun 2008 11:05:30 GMT" return Instant.from(DateTimeFormatter.RFC_1123_DATE_TIME.parse(text)); } + else { + // assuming UTC instant a la "2007-12-03T10:15:30.00Z" + return Instant.parse(text); + } } @Override diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java new file mode 100644 index 000000000000..5e9b0814fcbd --- /dev/null +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java @@ -0,0 +1,119 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.format.datetime.standard; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; + +import java.text.ParseException; +import java.time.Instant; +import java.time.format.DateTimeFormatter; +import java.util.Random; +import java.util.stream.Stream; + +import static java.time.Instant.MAX; +import static java.time.Instant.MIN; +import static java.time.ZoneId.systemDefault; +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Andrei Nevedomskii + */ +@SuppressWarnings("ConstantConditions") +class InstantFormatterTests { + + private final InstantFormatter instantFormatter = new InstantFormatter(); + + @ParameterizedTest + @ArgumentsSource(ISOSerializedInstantProvider.class) + void should_parse_an_ISO_formatted_string_representation_of_an_instant(String input) throws ParseException { + Instant expected = DateTimeFormatter.ISO_INSTANT.parse(input, Instant::from); + + Instant actual = instantFormatter.parse(input, null); + + assertThat(actual).isEqualTo(expected); + } + + @ParameterizedTest + @ArgumentsSource(RFC1123SerializedInstantProvider.class) + void should_parse_an_RFC1123_formatted_string_representation_of_an_instant(String input) throws ParseException { + Instant expected = DateTimeFormatter.RFC_1123_DATE_TIME.parse(input, Instant::from); + + Instant actual = instantFormatter.parse(input, null); + + assertThat(actual).isEqualTo(expected); + } + + @ParameterizedTest + @ArgumentsSource(RandomInstantProvider.class) + void should_serialize_an_instant_using_ISO_format_and_ignoring_locale(Instant input) { + String expected = DateTimeFormatter.ISO_INSTANT.format(input); + + String actual = instantFormatter.print(input, null); + + assertThat(actual).isEqualTo(expected); + } + + private static class ISOSerializedInstantProvider extends RandomInstantProvider { + + @Override + Stream provideArguments() { + return randomInstantStream(MIN, MAX).map(DateTimeFormatter.ISO_INSTANT::format); + } + } + + private static class RFC1123SerializedInstantProvider extends RandomInstantProvider { + + // RFC-1123 supports only 4-digit years + private final Instant min = Instant.parse("0000-01-01T00:00:00.00Z"); + + private final Instant max = Instant.parse("9999-12-31T23:59:59.99Z"); + + @Override + Stream provideArguments() { + return randomInstantStream(min, max) + .map(DateTimeFormatter.RFC_1123_DATE_TIME.withZone(systemDefault())::format); + } + } + + private static class RandomInstantProvider implements ArgumentsProvider { + + private static final long DATA_SET_SIZE = 10; + + static final Random RANDOM = new Random(); + + Stream provideArguments() { + return randomInstantStream(MIN, MAX); + } + + @Override + public final Stream provideArguments(ExtensionContext context) { + return provideArguments().map(Arguments::of).limit(DATA_SET_SIZE); + } + + Stream randomInstantStream(Instant min, Instant max) { + return Stream.concat( + Stream.of(Instant.now()), // make sure that the data set includes current instant + RANDOM.longs(min.getEpochSecond(), max.getEpochSecond()) + .mapToObj(Instant::ofEpochSecond) + ); + } + } +} \ No newline at end of file From 8186b77b5826fb780d5ff9d14a9b1f8c64232435 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 14 Nov 2019 09:54:50 +0100 Subject: [PATCH 0060/2315] Polish contribution See gh-23895 --- .../standard/InstantFormatterTests.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java index 5e9b0814fcbd..242f662c7d90 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java @@ -16,34 +16,42 @@ package org.springframework.format.datetime.standard; -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.ArgumentsProvider; -import org.junit.jupiter.params.provider.ArgumentsSource; - import java.text.ParseException; import java.time.Instant; import java.time.format.DateTimeFormatter; import java.util.Random; import java.util.stream.Stream; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; + import static java.time.Instant.MAX; import static java.time.Instant.MIN; import static java.time.ZoneId.systemDefault; import static org.assertj.core.api.Assertions.assertThat; /** + * Unit tests for {@link InstantFormatter}. + * * @author Andrei Nevedomskii + * @author Sam Brannen + * @since 5.2.2 */ -@SuppressWarnings("ConstantConditions") +@DisplayName("InstantFormatter unit tests") +@DisplayNameGeneration(ReplaceUnderscores.class) class InstantFormatterTests { private final InstantFormatter instantFormatter = new InstantFormatter(); @ParameterizedTest @ArgumentsSource(ISOSerializedInstantProvider.class) - void should_parse_an_ISO_formatted_string_representation_of_an_instant(String input) throws ParseException { + void should_parse_an_ISO_formatted_string_representation_of_an_Instant(String input) throws ParseException { Instant expected = DateTimeFormatter.ISO_INSTANT.parse(input, Instant::from); Instant actual = instantFormatter.parse(input, null); @@ -53,7 +61,7 @@ void should_parse_an_ISO_formatted_string_representation_of_an_instant(String in @ParameterizedTest @ArgumentsSource(RFC1123SerializedInstantProvider.class) - void should_parse_an_RFC1123_formatted_string_representation_of_an_instant(String input) throws ParseException { + void should_parse_an_RFC1123_formatted_string_representation_of_an_Instant(String input) throws ParseException { Instant expected = DateTimeFormatter.RFC_1123_DATE_TIME.parse(input, Instant::from); Instant actual = instantFormatter.parse(input, null); @@ -63,7 +71,7 @@ void should_parse_an_RFC1123_formatted_string_representation_of_an_instant(Strin @ParameterizedTest @ArgumentsSource(RandomInstantProvider.class) - void should_serialize_an_instant_using_ISO_format_and_ignoring_locale(Instant input) { + void should_serialize_an_Instant_using_ISO_format_and_ignoring_Locale(Instant input) { String expected = DateTimeFormatter.ISO_INSTANT.format(input); String actual = instantFormatter.print(input, null); @@ -97,7 +105,7 @@ private static class RandomInstantProvider implements ArgumentsProvider { private static final long DATA_SET_SIZE = 10; - static final Random RANDOM = new Random(); + private static final Random random = new Random(); Stream provideArguments() { return randomInstantStream(MIN, MAX); @@ -109,11 +117,9 @@ public final Stream provideArguments(ExtensionContext conte } Stream randomInstantStream(Instant min, Instant max) { - return Stream.concat( - Stream.of(Instant.now()), // make sure that the data set includes current instant - RANDOM.longs(min.getEpochSecond(), max.getEpochSecond()) - .mapToObj(Instant::ofEpochSecond) - ); + return Stream.concat(Stream.of(Instant.now()), // make sure that the data set includes current instant + random.longs(min.getEpochSecond(), max.getEpochSecond()).mapToObj(Instant::ofEpochSecond)); } } -} \ No newline at end of file + +} From 834ebc44f8ddef719603f6f1ed70ef83bb337f2a Mon Sep 17 00:00:00 2001 From: SchutzeHades Date: Thu, 14 Nov 2019 16:57:45 +0800 Subject: [PATCH 0061/2315] Fix inappropriate eager init. --- .../beans/factory/support/DefaultListableBeanFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 4f6dc67744bf..746b4367a9f3 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -473,10 +473,10 @@ public String[] getBeanNamesForType(ResolvableType type) { public String[] getBeanNamesForType(ResolvableType type, boolean includeNonSingletons, boolean allowEagerInit) { Class resolved = type.resolve(); if (resolved != null && !type.hasGenerics()) { - return getBeanNamesForType(resolved, includeNonSingletons, includeNonSingletons); + return getBeanNamesForType(resolved, includeNonSingletons, allowEagerInit); } else { - return doGetBeanNamesForType(type, includeNonSingletons, includeNonSingletons); + return doGetBeanNamesForType(type, includeNonSingletons, allowEagerInit); } } From 8df3afd0b65e15ed1063c737d7d428ede3670603 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 14 Nov 2019 13:26:38 +0100 Subject: [PATCH 0062/2315] Polish contribution See gh-23895 --- .../datetime/standard/InstantFormatter.java | 3 +- .../standard/InstantFormatterTests.java | 44 +++++++++---------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java index 010d004ae5d7..456c0ad09090 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/InstantFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 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. @@ -31,6 +31,7 @@ * (which is commonly used for HTTP date header values), as of Spring 4.3. * * @author Juergen Hoeller + * @author Andrei Nevedomskii * @since 4.0 * @see java.time.Instant#parse * @see java.time.format.DateTimeFormatter#ISO_INSTANT diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java index 242f662c7d90..16ba2cbd5e5c 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java @@ -41,7 +41,7 @@ * * @author Andrei Nevedomskii * @author Sam Brannen - * @since 5.2.2 + * @since 5.1.12 */ @DisplayName("InstantFormatter unit tests") @DisplayNameGeneration(ReplaceUnderscores.class) @@ -79,6 +79,27 @@ void should_serialize_an_Instant_using_ISO_format_and_ignoring_Locale(Instant in assertThat(actual).isEqualTo(expected); } + private static class RandomInstantProvider implements ArgumentsProvider { + + private static final long DATA_SET_SIZE = 10; + + private static final Random random = new Random(); + + @Override + public final Stream provideArguments(ExtensionContext context) { + return provideArguments().map(Arguments::of).limit(DATA_SET_SIZE); + } + + Stream provideArguments() { + return randomInstantStream(MIN, MAX); + } + + Stream randomInstantStream(Instant min, Instant max) { + return Stream.concat(Stream.of(Instant.now()), // make sure that the data set includes current instant + random.longs(min.getEpochSecond(), max.getEpochSecond()).mapToObj(Instant::ofEpochSecond)); + } + } + private static class ISOSerializedInstantProvider extends RandomInstantProvider { @Override @@ -101,25 +122,4 @@ Stream provideArguments() { } } - private static class RandomInstantProvider implements ArgumentsProvider { - - private static final long DATA_SET_SIZE = 10; - - private static final Random random = new Random(); - - Stream provideArguments() { - return randomInstantStream(MIN, MAX); - } - - @Override - public final Stream provideArguments(ExtensionContext context) { - return provideArguments().map(Arguments::of).limit(DATA_SET_SIZE); - } - - Stream randomInstantStream(Instant min, Instant max) { - return Stream.concat(Stream.of(Instant.now()), // make sure that the data set includes current instant - random.longs(min.getEpochSecond(), max.getEpochSecond()).mapToObj(Instant::ofEpochSecond)); - } - } - } From 56670ebec8e8fa6f9fa956fd9cdd71e5cceb89a0 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 14 Nov 2019 20:45:12 +0900 Subject: [PATCH 0063/2315] Polish CorsAbstractHandlerMappingTests See gh-23995 --- .../CorsAbstractHandlerMappingTests.java | 54 +++++++++---------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java index b8213381b028..602b9d9c83c0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java @@ -71,11 +71,10 @@ void actualRequestWithoutCorsConfigurationProvider() throws Exception { this.request.setRequestURI("/foo"); this.request.addHeader(HttpHeaders.ORIGIN, "https://domain2.com"); this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); - HandlerExecutionChain chain = handlerMapping.getHandler(this.request); + HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); assertThat(chain).isNotNull(); - boolean condition = chain.getHandler() instanceof SimpleHandler; - assertThat(condition).isTrue(); + assertThat(chain.getHandler()).isInstanceOf(SimpleHandler.class); } @Test @@ -84,11 +83,10 @@ void preflightRequestWithoutCorsConfigurationProvider() throws Exception { this.request.setRequestURI("/foo"); this.request.addHeader(HttpHeaders.ORIGIN, "https://domain2.com"); this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); - HandlerExecutionChain chain = handlerMapping.getHandler(this.request); + HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); assertThat(chain).isNotNull(); - boolean condition = chain.getHandler() instanceof SimpleHandler; - assertThat(condition).isTrue(); + assertThat(chain.getHandler()).isInstanceOf(SimpleHandler.class); } @Test @@ -97,12 +95,11 @@ void actualRequestWithCorsConfigurationProvider() throws Exception { this.request.setRequestURI("/cors"); this.request.addHeader(HttpHeaders.ORIGIN, "https://domain2.com"); this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); - HandlerExecutionChain chain = handlerMapping.getHandler(this.request); + HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); assertThat(chain).isNotNull(); - boolean condition = chain.getHandler() instanceof CorsAwareHandler; - assertThat(condition).isTrue(); - assertThat(getRequiredCorsConfiguration(chain, false).getAllowedOrigins()).isEqualTo(Collections.singletonList("*")); + assertThat(chain.getHandler()).isInstanceOf(CorsAwareHandler.class); + assertThat(getRequiredCorsConfiguration(chain, false).getAllowedOrigins()).containsExactly("*"); } @Test // see gh-23843 @@ -111,12 +108,11 @@ void actualRequestWithCorsConfigurationProviderForHandlerChain() throws Exceptio this.request.setRequestURI("/chain"); this.request.addHeader(HttpHeaders.ORIGIN, "https://domain2.com"); this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); - HandlerExecutionChain chain = handlerMapping.getHandler(this.request); + HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); assertThat(chain).isNotNull(); - boolean condition = chain.getHandler() instanceof CorsAwareHandler; - assertThat(condition).isTrue(); - assertThat(getRequiredCorsConfiguration(chain, false).getAllowedOrigins()).isEqualTo(Collections.singletonList("*")); + assertThat(chain.getHandler()).isInstanceOf(CorsAwareHandler.class); + assertThat(getRequiredCorsConfiguration(chain, false).getAllowedOrigins()).containsExactly("*"); } @Test @@ -125,12 +121,12 @@ void preflightRequestWithCorsConfigurationProvider() throws Exception { this.request.setRequestURI("/cors"); this.request.addHeader(HttpHeaders.ORIGIN, "https://domain2.com"); this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); - HandlerExecutionChain chain = handlerMapping.getHandler(this.request); + HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); assertThat(chain).isNotNull(); assertThat(chain.getHandler()).isNotNull(); assertThat(chain.getHandler().getClass().getSimpleName()).isEqualTo("PreFlightHandler"); - assertThat(getRequiredCorsConfiguration(chain, true).getAllowedOrigins()).isEqualTo(Collections.singletonList("*")); + assertThat(getRequiredCorsConfiguration(chain, true).getAllowedOrigins()).containsExactly("*"); } @Test @@ -142,12 +138,11 @@ void actualRequestWithMappedCorsConfiguration() throws Exception { this.request.setRequestURI("/foo"); this.request.addHeader(HttpHeaders.ORIGIN, "https://domain2.com"); this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); - HandlerExecutionChain chain = handlerMapping.getHandler(this.request); + HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); assertThat(chain).isNotNull(); - boolean condition = chain.getHandler() instanceof SimpleHandler; - assertThat(condition).isTrue(); - assertThat(getRequiredCorsConfiguration(chain, false).getAllowedOrigins()).isEqualTo(Collections.singletonList("*")); + assertThat(chain.getHandler()).isInstanceOf(SimpleHandler.class); + assertThat(getRequiredCorsConfiguration(chain, false).getAllowedOrigins()).containsExactly("*"); } @Test @@ -159,12 +154,12 @@ void preflightRequestWithMappedCorsConfiguration() throws Exception { this.request.setRequestURI("/foo"); this.request.addHeader(HttpHeaders.ORIGIN, "https://domain2.com"); this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); - HandlerExecutionChain chain = handlerMapping.getHandler(this.request); + HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); assertThat(chain).isNotNull(); assertThat(chain.getHandler()).isNotNull(); assertThat(chain.getHandler().getClass().getSimpleName()).isEqualTo("PreFlightHandler"); - assertThat(getRequiredCorsConfiguration(chain, true).getAllowedOrigins()).isEqualTo(Collections.singletonList("*")); + assertThat(getRequiredCorsConfiguration(chain, true).getAllowedOrigins()).containsExactly("*"); } @Test @@ -174,15 +169,14 @@ void actualRequestWithCorsConfigurationSource() throws Exception { this.request.setRequestURI("/foo"); this.request.addHeader(HttpHeaders.ORIGIN, "https://domain2.com"); this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); - HandlerExecutionChain chain = handlerMapping.getHandler(this.request); + HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); assertThat(chain).isNotNull(); - boolean condition = chain.getHandler() instanceof SimpleHandler; - assertThat(condition).isTrue(); + assertThat(chain.getHandler()).isInstanceOf(SimpleHandler.class); CorsConfiguration config = getRequiredCorsConfiguration(chain, false); assertThat(config).isNotNull(); - assertThat(config.getAllowedOrigins()).isEqualTo(Collections.singletonList("*")); - assertThat(config.getAllowCredentials()).isEqualTo(true); + assertThat(config.getAllowedOrigins()).containsExactly("*"); + assertThat(config.getAllowCredentials()).isTrue(); } @Test @@ -192,15 +186,15 @@ void preflightRequestWithCorsConfigurationSource() throws Exception { this.request.setRequestURI("/foo"); this.request.addHeader(HttpHeaders.ORIGIN, "https://domain2.com"); this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); - HandlerExecutionChain chain = handlerMapping.getHandler(this.request); + HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); assertThat(chain).isNotNull(); assertThat(chain.getHandler()).isNotNull(); assertThat(chain.getHandler().getClass().getSimpleName()).isEqualTo("PreFlightHandler"); CorsConfiguration config = getRequiredCorsConfiguration(chain, true); assertThat(config).isNotNull(); - assertThat(config.getAllowedOrigins()).isEqualTo(Collections.singletonList("*")); - assertThat(config.getAllowCredentials()).isEqualTo(true); + assertThat(config.getAllowedOrigins()).containsExactly("*"); + assertThat(config.getAllowCredentials()).isTrue(); } From 89b3a9cef218c0d6ff3121d3f0c386b0c2f06dbc Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 14 Nov 2019 14:30:21 +0100 Subject: [PATCH 0064/2315] Introduce JavaUtilLoggingConfigurer to configure JUL for tests --- .../logging/JavaUtilLoggingConfigurer.java | 56 +++++++++++++++++++ ...it.platform.launcher.TestExecutionListener | 1 + .../src/test/resources/jul-test.properties | 2 + 3 files changed, 59 insertions(+) create mode 100644 spring-webflux/src/test/java/org/springframework/test_fixtures/logging/JavaUtilLoggingConfigurer.java create mode 100644 spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener create mode 100644 spring-webflux/src/test/resources/jul-test.properties diff --git a/spring-webflux/src/test/java/org/springframework/test_fixtures/logging/JavaUtilLoggingConfigurer.java b/spring-webflux/src/test/java/org/springframework/test_fixtures/logging/JavaUtilLoggingConfigurer.java new file mode 100644 index 000000000000..8a9285b5c015 --- /dev/null +++ b/spring-webflux/src/test/java/org/springframework/test_fixtures/logging/JavaUtilLoggingConfigurer.java @@ -0,0 +1,56 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.test_fixtures.logging; + +import java.io.InputStream; +import java.util.logging.LogManager; + +import org.junit.platform.launcher.TestExecutionListener; +import org.junit.platform.launcher.TestPlan; + +/** + * JUnit Platform {@link TestExecutionListener} that configures Java Util Logging + * (JUL) from a file named {@code jul-test.properties} in the root of the classpath. + * + *

    This allows for projects to configure JUL for a test suite, analogous to + * log4j's support via {@code log4j2-test.xml}. + * + *

    This listener can be automatically registered on the JUnit Platform by + * adding the fully qualified name of this class to a file named + * {@code /META-INF/services/org.junit.platform.launcher.TestExecutionListener} + * — for example, under {@code src/test/resources}. + * + * @author Sam Brannen + * @since 5.2.2 + */ +public class JavaUtilLoggingConfigurer implements TestExecutionListener { + + public static final String JUL_TEST_PROPERTIES_FILE = "jul-test.properties"; + + + @Override + public void testPlanExecutionStarted(TestPlan testPlan) { + try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(JUL_TEST_PROPERTIES_FILE)) { + LogManager.getLogManager().readConfiguration(inputStream); + } + catch (Exception ex) { + System.err.println("WARNING: failed to configure Java Util Logging from classpath resource " + + JUL_TEST_PROPERTIES_FILE); + System.err.println(ex); + } + } +} diff --git a/spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener b/spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener new file mode 100644 index 000000000000..7585af90708e --- /dev/null +++ b/spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener @@ -0,0 +1 @@ +org.springframework.test_fixtures.logging.JavaUtilLoggingConfigurer \ No newline at end of file diff --git a/spring-webflux/src/test/resources/jul-test.properties b/spring-webflux/src/test/resources/jul-test.properties new file mode 100644 index 000000000000..fb322f8d3c35 --- /dev/null +++ b/spring-webflux/src/test/resources/jul-test.properties @@ -0,0 +1,2 @@ +# Console Logging +java.util.logging.ConsoleHandler.level = WARNING From 79910663450817c93535575dac2994253f7b6878 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 14 Nov 2019 15:25:26 +0100 Subject: [PATCH 0065/2315] Fix classpath --- spring-webflux/spring-webflux.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-webflux/spring-webflux.gradle b/spring-webflux/spring-webflux.gradle index 9da04cc63ff9..e056a47f283b 100644 --- a/spring-webflux/spring-webflux.gradle +++ b/spring-webflux/spring-webflux.gradle @@ -42,6 +42,7 @@ dependencies { testCompile("org.eclipse.jetty:jetty-server") testCompile("org.eclipse.jetty:jetty-servlet") testCompile("org.eclipse.jetty:jetty-reactive-httpclient") + testCompile("org.junit.platform:junit-platform-launcher") testCompile("com.squareup.okhttp3:mockwebserver") testCompile(project(":kotlin-coroutines")) testCompile("org.jetbrains.kotlin:kotlin-script-runtime") From 029e61f54abca55211a1a736ea4b9f0508a027de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Thu, 14 Nov 2019 14:22:44 +0100 Subject: [PATCH 0066/2315] Refine MethodParameter#isOptional Kotlin implementation This commit adds support for Continuation parameter that is now considered as an optional parameter since it is never provided by the user. It also simplifies and optimizes the implementation. Closes gh-23991 --- .../springframework/core/MethodParameter.java | 50 +++++++++---------- .../core/KotlinMethodParameterTests.kt | 8 +++ 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/MethodParameter.java b/spring-core/src/main/java/org/springframework/core/MethodParameter.java index 040819bea667..e3ae0562bac8 100644 --- a/spring-core/src/main/java/org/springframework/core/MethodParameter.java +++ b/spring-core/src/main/java/org/springframework/core/MethodParameter.java @@ -26,11 +26,9 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import kotlin.reflect.KFunction; import kotlin.reflect.KParameter; @@ -398,7 +396,7 @@ private MethodParameter nested(int nestingLevel, @Nullable Integer typeIndex) { * either in the form of Java 8's {@link java.util.Optional}, any variant * of a parameter-level {@code Nullable} annotation (such as from JSR-305 * or the FindBugs set of annotations), or a language-level nullable type - * declaration in Kotlin. + * declaration or {@code Continuation} parameter in Kotlin. * @since 4.3 */ public boolean isOptional() { @@ -867,37 +865,39 @@ private static int validateIndex(Executable executable, int parameterIndex) { private static class KotlinDelegate { /** - * Check whether the specified {@link MethodParameter} represents a nullable Kotlin type - * or an optional parameter (with a default value in the Kotlin declaration). + * Check whether the specified {@link MethodParameter} represents a nullable Kotlin type, + * an optional parameter (with a default value in the Kotlin declaration) or a {@code Continuation} parameter + * used in suspending functions. */ public static boolean isOptional(MethodParameter param) { Method method = param.getMethod(); - Constructor ctor = param.getConstructor(); int index = param.getParameterIndex(); if (method != null && index == -1) { KFunction function = ReflectJvmMapping.getKotlinFunction(method); return (function != null && function.getReturnType().isMarkedNullable()); } - else { - KFunction function = null; - Predicate predicate = null; - if (method != null) { - function = ReflectJvmMapping.getKotlinFunction(method); - predicate = p -> KParameter.Kind.VALUE.equals(p.getKind()); - } - else if (ctor != null) { - function = ReflectJvmMapping.getKotlinFunction(ctor); - predicate = p -> KParameter.Kind.VALUE.equals(p.getKind()) || - KParameter.Kind.INSTANCE.equals(p.getKind()); + KFunction function; + Predicate predicate; + if (method != null) { + if (param.parameterType.getName().equals("kotlin.coroutines.Continuation")) { + return true; } - if (function != null) { - List parameters = function.getParameters(); - KParameter parameter = parameters - .stream() - .filter(predicate) - .collect(Collectors.toList()) - .get(index); - return (parameter.getType().isMarkedNullable() || parameter.isOptional()); + function = ReflectJvmMapping.getKotlinFunction(method); + predicate = p -> KParameter.Kind.VALUE.equals(p.getKind()); + } + else { + function = ReflectJvmMapping.getKotlinFunction(param.getConstructor()); + predicate = p -> KParameter.Kind.VALUE.equals(p.getKind()) || + KParameter.Kind.INSTANCE.equals(p.getKind()); + } + if (function != null) { + int i = 0; + for (KParameter kParameter : function.getParameters()) { + if (predicate.test(kParameter)) { + if (index == i++) { + return (kParameter.getType().isMarkedNullable() || kParameter.isOptional()); + } + } } } return false; diff --git a/spring-core/src/test/kotlin/org/springframework/core/KotlinMethodParameterTests.kt b/spring-core/src/test/kotlin/org/springframework/core/KotlinMethodParameterTests.kt index b88fbaa64b87..419698d2ff6c 100644 --- a/spring-core/src/test/kotlin/org/springframework/core/KotlinMethodParameterTests.kt +++ b/spring-core/src/test/kotlin/org/springframework/core/KotlinMethodParameterTests.kt @@ -20,6 +20,7 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import java.lang.reflect.Method import java.lang.reflect.TypeVariable +import kotlin.coroutines.Continuation import kotlin.reflect.full.declaredFunctions import kotlin.reflect.jvm.javaMethod @@ -101,6 +102,13 @@ class KotlinMethodParameterTests { assertThat(returnGenericParameterType("suspendFun8")).isEqualTo(Object::class.java) } + @Test + fun `Continuation parameter is optional`() { + val method = this::class.java.getDeclaredMethod("suspendFun", String::class.java, Continuation::class.java) + assertThat(MethodParameter(method, 0).isOptional).isFalse() + assertThat(MethodParameter(method, 1).isOptional).isTrue() + } + private fun returnParameterType(funName: String) = returnMethodParameter(funName).parameterType private fun returnGenericParameterType(funName: String) = returnMethodParameter(funName).genericParameterType private fun returnGenericParameterTypeName(funName: String) = returnGenericParameterType(funName).typeName From d38b07b4504c8e832ffc0b1d3d5597e46b2ef20a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 14 Nov 2019 15:37:30 +0100 Subject: [PATCH 0067/2315] Move JavaUtilLoggingConfigurer to web.reactive.fixtures package --- .../reactive/fixtures}/JavaUtilLoggingConfigurer.java | 2 +- .../services/org.junit.platform.launcher.TestExecutionListener | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename spring-webflux/src/test/java/org/springframework/{test_fixtures/logging => web/reactive/fixtures}/JavaUtilLoggingConfigurer.java (97%) diff --git a/spring-webflux/src/test/java/org/springframework/test_fixtures/logging/JavaUtilLoggingConfigurer.java b/spring-webflux/src/test/java/org/springframework/web/reactive/fixtures/JavaUtilLoggingConfigurer.java similarity index 97% rename from spring-webflux/src/test/java/org/springframework/test_fixtures/logging/JavaUtilLoggingConfigurer.java rename to spring-webflux/src/test/java/org/springframework/web/reactive/fixtures/JavaUtilLoggingConfigurer.java index 8a9285b5c015..2c555e16ad91 100644 --- a/spring-webflux/src/test/java/org/springframework/test_fixtures/logging/JavaUtilLoggingConfigurer.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/fixtures/JavaUtilLoggingConfigurer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.test_fixtures.logging; +package org.springframework.web.reactive.fixtures; import java.io.InputStream; import java.util.logging.LogManager; diff --git a/spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener b/spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener index 7585af90708e..fd231f292ca1 100644 --- a/spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener +++ b/spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener @@ -1 +1 @@ -org.springframework.test_fixtures.logging.JavaUtilLoggingConfigurer \ No newline at end of file +org.springframework.web.reactive.fixtures.JavaUtilLoggingConfigurer \ No newline at end of file From 830f81210f62b38cce77ab8fb9d3a3ebac5d816b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 14 Nov 2019 18:31:32 +0100 Subject: [PATCH 0068/2315] Revise getElementTypeDescriptor javadoc (no IllegalStateException) Closes gh-23996 --- .../core/convert/TypeDescriptor.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java index c22e05c0092d..3e2aee829558 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java +++ b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java @@ -36,7 +36,8 @@ import org.springframework.util.ObjectUtils; /** - * Context about a type to convert from or to. + * Contextual descriptor about a type to convert from or to. + * Capable of representing arrays and generic collection types. * * @author Keith Donald * @author Andy Clement @@ -45,6 +46,8 @@ * @author Sam Brannen * @author Stephane Nicoll * @since 3.0 + * @see ConversionService#canConvert(TypeDescriptor, TypeDescriptor) + * @see ConversionService#convert(Object, TypeDescriptor, TypeDescriptor) */ @SuppressWarnings("serial") public class TypeDescriptor implements Serializable { @@ -322,9 +325,9 @@ public boolean isArray() { * If this type is a {@code Stream}, returns the stream's component type. * If this type is a {@link Collection} and it is parameterized, returns the Collection's element type. * If the Collection is not parameterized, returns {@code null} indicating the element type is not declared. - * @return the array component type or Collection element type, or {@code null} if this type is a - * Collection but its element type is not parameterized - * @throws IllegalStateException if this type is not a {@code java.util.Collection} or array type + * @return the array component type or Collection element type, or {@code null} if this type is not + * an array type or a {@code java.util.Collection} or if its element type is not parameterized + * @see #elementTypeDescriptor(Object) */ @Nullable public TypeDescriptor getElementTypeDescriptor() { @@ -351,8 +354,7 @@ public TypeDescriptor getElementTypeDescriptor() { * TypeDescriptor that is returned. * @param element the collection or array element * @return a element type descriptor, narrowed to the type of the provided element - * @throws IllegalStateException if this type is not a {@code java.util.Collection} - * or array type + * @see #getElementTypeDescriptor() * @see #narrow(Object) */ @Nullable From 905e3c1f9f429afaf582cb8cb774fa15e6d3f4fc Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 14 Nov 2019 17:36:37 +0000 Subject: [PATCH 0069/2315] Avoid indefinite wait in JettyWebSocketClient Closes gh-23994 --- .../web/socket/client/jetty/JettyWebSocketClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java index 459e2562248a..4c8b2d37426a 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -22,6 +22,7 @@ import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; @@ -155,7 +156,7 @@ public ListenableFuture doHandshakeInternal(WebSocketHandler w Callable connectTask = () -> { Future future = this.client.connect(listener, uri, request); - future.get(); + future.get(this.client.getConnectTimeout() + 2000, TimeUnit.MILLISECONDS); return wsSession; }; From 46fe74d2f9a87cc10b8eaab339ad74435c232c27 Mon Sep 17 00:00:00 2001 From: Mark Hobson Date: Sat, 14 Jul 2018 13:04:13 +0100 Subject: [PATCH 0070/2315] Preserve media type parameters when setting charset Issue: SPR-17040 --- .../AbstractWireFeedHttpMessageConverter.java | 2 +- .../AtomFeedHttpMessageConverterTests.java | 26 +++++++++++++++-- .../RssChannelHttpMessageConverterTests.java | 29 +++++++++++++++++-- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java index bd2bd774e8b2..5494fe8a2929 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java @@ -90,7 +90,7 @@ protected void writeInternal(T wireFeed, HttpOutputMessage outputMessage) Charset.forName(wireFeed.getEncoding()) : DEFAULT_CHARSET); MediaType contentType = outputMessage.getHeaders().getContentType(); if (contentType != null) { - contentType = new MediaType(contentType.getType(), contentType.getSubtype(), charset); + contentType = new MediaType(contentType, charset); outputMessage.getHeaders().setContentType(contentType); } diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java index bf2956f1b4b5..0c6da02d2cd9 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java @@ -21,7 +21,9 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.rometools.rome.feed.atom.Entry; import com.rometools.rome.feed.atom.Feed; @@ -37,6 +39,7 @@ import org.springframework.http.MockHttpOutputMessage; import org.springframework.tests.XmlContent; +import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; /** @@ -106,7 +109,9 @@ public void write() throws IOException, SAXException { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); converter.write(feed, null, outputMessage); - assertThat(outputMessage.getHeaders().getContentType()).as("Invalid content-type").isEqualTo(new MediaType("application", "atom+xml", StandardCharsets.UTF_8)); + assertThat(outputMessage.getHeaders().getContentType()) + .as("Invalid content-type") + .isEqualTo(new MediaType("application", "atom+xml", StandardCharsets.UTF_8)); String expected = "" + "title" + "id1title1" + "id2title2"; @@ -125,7 +130,24 @@ public void writeOtherCharset() throws IOException, SAXException { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); converter.write(feed, null, outputMessage); - assertThat(outputMessage.getHeaders().getContentType()).as("Invalid content-type").isEqualTo(new MediaType("application", "atom+xml", Charset.forName(encoding))); + assertThat(outputMessage.getHeaders().getContentType()) + .as("Invalid content-type") + .isEqualTo(new MediaType("application", "atom+xml", Charset.forName(encoding))); + } + + @Test + public void writeOtherContentTypeParameters() throws IOException { + Feed feed = new Feed("atom_1.0"); + + MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); + converter.write(feed, new MediaType("application", "atom+xml", singletonMap("type", "feed")), outputMessage); + + Map expectedParameters = new HashMap<>(); + expectedParameters.put("charset", "UTF-8"); + expectedParameters.put("type", "feed"); + assertThat(outputMessage.getHeaders().getContentType()) + .as("Invalid content-type") + .isEqualTo(new MediaType("application", "atom+xml", expectedParameters)); } } diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java index ea48f3523171..3d8c5e7d508c 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java @@ -21,7 +21,9 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.rometools.rome.feed.rss.Channel; import com.rometools.rome.feed.rss.Item; @@ -34,6 +36,7 @@ import org.springframework.http.MockHttpOutputMessage; import org.springframework.tests.XmlContent; +import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; /** @@ -103,7 +106,9 @@ public void write() throws IOException, SAXException { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); converter.write(channel, null, outputMessage); - assertThat(outputMessage.getHeaders().getContentType()).as("Invalid content-type").isEqualTo(new MediaType("application", "rss+xml", StandardCharsets.UTF_8)); + assertThat(outputMessage.getHeaders().getContentType()) + .as("Invalid content-type") + .isEqualTo(new MediaType("application", "rss+xml", StandardCharsets.UTF_8)); String expected = "" + "titlehttps://example.comdescription" + "title1" + @@ -129,7 +134,27 @@ public void writeOtherCharset() throws IOException, SAXException { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); converter.write(channel, null, outputMessage); - assertThat(outputMessage.getHeaders().getContentType()).as("Invalid content-type").isEqualTo(new MediaType("application", "rss+xml", Charset.forName(encoding))); + assertThat(outputMessage.getHeaders().getContentType()) + .as("Invalid content-type") + .isEqualTo(new MediaType("application", "rss+xml", Charset.forName(encoding))); + } + + @Test + public void writeOtherContentTypeParameters() throws IOException { + Channel channel = new Channel("rss_2.0"); + channel.setTitle("title"); + channel.setLink("http://example.com"); + channel.setDescription("description"); + + MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); + converter.write(channel, new MediaType("application", "rss+xml", singletonMap("x", "y")), outputMessage); + + Map expectedParameters = new HashMap<>(); + expectedParameters.put("charset", "UTF-8"); + expectedParameters.put("x", "y"); + assertThat(outputMessage.getHeaders().getContentType()) + .as("Invalid content-type") + .isEqualTo(new MediaType("application", "rss+xml", expectedParameters)); } } From c33cb26a730d1a38491b4977da3181a6451ab4f4 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 14 Nov 2019 14:16:26 +0000 Subject: [PATCH 0071/2315] Polishing contribution See gh-1885 --- .../AbstractWireFeedHttpMessageConverter.java | 2 +- .../AtomFeedHttpMessageConverterTests.java | 39 +++++++++--------- .../RssChannelHttpMessageConverterTests.java | 41 +++++++++---------- 3 files changed, 39 insertions(+), 43 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java index 5494fe8a2929..5a62697950cd 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java index 0c6da02d2cd9..1b057e584aec 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java @@ -21,15 +21,12 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import com.rometools.rome.feed.atom.Entry; import com.rometools.rome.feed.atom.Feed; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.xml.sax.SAXException; import org.xmlunit.diff.DefaultNodeMatcher; import org.xmlunit.diff.ElementSelectors; import org.xmlunit.diff.NodeMatcher; @@ -47,6 +44,10 @@ */ public class AtomFeedHttpMessageConverterTests { + private static final MediaType ATOM_XML_UTF8 = + new MediaType(MediaType.APPLICATION_ATOM_XML, StandardCharsets.UTF_8); + + private AtomFeedHttpMessageConverter converter; @@ -58,21 +59,21 @@ public void setUp() { @Test public void canRead() { - assertThat(converter.canRead(Feed.class, new MediaType("application", "atom+xml"))).isTrue(); - assertThat(converter.canRead(Feed.class, new MediaType("application", "atom+xml", StandardCharsets.UTF_8))).isTrue(); + assertThat(converter.canRead(Feed.class, MediaType.APPLICATION_ATOM_XML)).isTrue(); + assertThat(converter.canRead(Feed.class, ATOM_XML_UTF8)).isTrue(); } @Test public void canWrite() { - assertThat(converter.canWrite(Feed.class, new MediaType("application", "atom+xml"))).isTrue(); - assertThat(converter.canWrite(Feed.class, new MediaType("application", "atom+xml", StandardCharsets.UTF_8))).isTrue(); + assertThat(converter.canWrite(Feed.class, MediaType.APPLICATION_ATOM_XML)).isTrue(); + assertThat(converter.canWrite(Feed.class, ATOM_XML_UTF8)).isTrue(); } @Test public void read() throws IOException { InputStream is = getClass().getResourceAsStream("atom.xml"); MockHttpInputMessage inputMessage = new MockHttpInputMessage(is); - inputMessage.getHeaders().setContentType(new MediaType("application", "atom+xml", StandardCharsets.UTF_8)); + inputMessage.getHeaders().setContentType(ATOM_XML_UTF8); Feed result = converter.read(Feed.class, inputMessage); assertThat(result.getTitle()).isEqualTo("title"); assertThat(result.getSubtitle().getValue()).isEqualTo("subtitle"); @@ -89,7 +90,7 @@ public void read() throws IOException { } @Test - public void write() throws IOException, SAXException { + public void write() throws IOException { Feed feed = new Feed("atom_1.0"); feed.setTitle("title"); @@ -111,7 +112,7 @@ public void write() throws IOException, SAXException { assertThat(outputMessage.getHeaders().getContentType()) .as("Invalid content-type") - .isEqualTo(new MediaType("application", "atom+xml", StandardCharsets.UTF_8)); + .isEqualTo(ATOM_XML_UTF8); String expected = "" + "title" + "id1title1" + "id2title2"; @@ -121,7 +122,7 @@ public void write() throws IOException, SAXException { } @Test - public void writeOtherCharset() throws IOException, SAXException { + public void writeOtherCharset() throws IOException { Feed feed = new Feed("atom_1.0"); feed.setTitle("title"); String encoding = "ISO-8859-1"; @@ -137,17 +138,15 @@ public void writeOtherCharset() throws IOException, SAXException { @Test public void writeOtherContentTypeParameters() throws IOException { - Feed feed = new Feed("atom_1.0"); + MockHttpOutputMessage message = new MockHttpOutputMessage(); + MediaType contentType = new MediaType("application", "atom+xml", singletonMap("type", "feed")); + converter.write(new Feed("atom_1.0"), contentType, message); - MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); - converter.write(feed, new MediaType("application", "atom+xml", singletonMap("type", "feed")), outputMessage); - - Map expectedParameters = new HashMap<>(); - expectedParameters.put("charset", "UTF-8"); - expectedParameters.put("type", "feed"); - assertThat(outputMessage.getHeaders().getContentType()) + assertThat(message.getHeaders().getContentType().getParameters()) .as("Invalid content-type") - .isEqualTo(new MediaType("application", "atom+xml", expectedParameters)); + .hasSize(2) + .containsEntry("type", "feed") + .containsEntry("charset", "UTF-8"); } } diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java index 3d8c5e7d508c..a720f16d3b53 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java @@ -21,15 +21,12 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import com.rometools.rome.feed.rss.Channel; import com.rometools.rome.feed.rss.Item; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.xml.sax.SAXException; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; @@ -44,6 +41,10 @@ */ public class RssChannelHttpMessageConverterTests { + private static final MediaType RSS_XML_UTF8 = + new MediaType(MediaType.APPLICATION_RSS_XML, StandardCharsets.UTF_8); + + private RssChannelHttpMessageConverter converter; @@ -54,22 +55,19 @@ public void setUp() { @Test - public void canRead() { - assertThat(converter.canRead(Channel.class, new MediaType("application", "rss+xml"))).isTrue(); - assertThat(converter.canRead(Channel.class, new MediaType("application", "rss+xml", StandardCharsets.UTF_8))).isTrue(); - } + public void canReadAndWrite() { + assertThat(converter.canRead(Channel.class, MediaType.APPLICATION_RSS_XML)).isTrue(); + assertThat(converter.canRead(Channel.class, RSS_XML_UTF8)).isTrue(); - @Test - public void canWrite() { - assertThat(converter.canWrite(Channel.class, new MediaType("application", "rss+xml"))).isTrue(); - assertThat(converter.canWrite(Channel.class, new MediaType("application", "rss+xml", StandardCharsets.UTF_8))).isTrue(); + assertThat(converter.canWrite(Channel.class, MediaType.APPLICATION_RSS_XML)).isTrue(); + assertThat(converter.canWrite(Channel.class, RSS_XML_UTF8)).isTrue(); } @Test public void read() throws IOException { InputStream is = getClass().getResourceAsStream("rss.xml"); MockHttpInputMessage inputMessage = new MockHttpInputMessage(is); - inputMessage.getHeaders().setContentType(new MediaType("application", "rss+xml", StandardCharsets.UTF_8)); + inputMessage.getHeaders().setContentType(RSS_XML_UTF8); Channel result = converter.read(Channel.class, inputMessage); assertThat(result.getTitle()).isEqualTo("title"); assertThat(result.getLink()).isEqualTo("https://example.com"); @@ -86,7 +84,7 @@ public void read() throws IOException { } @Test - public void write() throws IOException, SAXException { + public void write() throws IOException { Channel channel = new Channel("rss_2.0"); channel.setTitle("title"); channel.setLink("https://example.com"); @@ -108,7 +106,7 @@ public void write() throws IOException, SAXException { assertThat(outputMessage.getHeaders().getContentType()) .as("Invalid content-type") - .isEqualTo(new MediaType("application", "rss+xml", StandardCharsets.UTF_8)); + .isEqualTo(RSS_XML_UTF8); String expected = "" + "titlehttps://example.comdescription" + "title1" + @@ -119,7 +117,7 @@ public void write() throws IOException, SAXException { } @Test - public void writeOtherCharset() throws IOException, SAXException { + public void writeOtherCharset() throws IOException { Channel channel = new Channel("rss_2.0"); channel.setTitle("title"); channel.setLink("https://example.com"); @@ -146,15 +144,14 @@ public void writeOtherContentTypeParameters() throws IOException { channel.setLink("http://example.com"); channel.setDescription("description"); - MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); - converter.write(channel, new MediaType("application", "rss+xml", singletonMap("x", "y")), outputMessage); + MockHttpOutputMessage message = new MockHttpOutputMessage(); + converter.write(channel, new MediaType("application", "rss+xml", singletonMap("x", "y")), message); - Map expectedParameters = new HashMap<>(); - expectedParameters.put("charset", "UTF-8"); - expectedParameters.put("x", "y"); - assertThat(outputMessage.getHeaders().getContentType()) + assertThat(message.getHeaders().getContentType().getParameters()) .as("Invalid content-type") - .isEqualTo(new MediaType("application", "rss+xml", expectedParameters)); + .hasSize(2) + .containsEntry("x", "y") + .containsEntry("charset", "UTF-8"); } } From a43ae63f17df875d29dbf986edfff3844da51136 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 15 Nov 2019 10:21:58 +0100 Subject: [PATCH 0072/2315] Upgrade to SLF4J 1.7.29, Jackson 2.10.1, WebJars Locator 0.43 --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 40db4edbaa50..4d73741fa08f 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ configure(allprojects) { project -> dependencyManagement { imports { - mavenBom "com.fasterxml.jackson:jackson-bom:2.10.0" + mavenBom "com.fasterxml.jackson:jackson-bom:2.10.1" mavenBom "io.netty:netty-bom:4.1.43.Final" mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR1" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" @@ -59,7 +59,7 @@ configure(allprojects) { project -> entry 'log4j-slf4j-impl' entry 'log4j-jul' } - dependency "org.slf4j:slf4j-api:1.7.28" + dependency "org.slf4j:slf4j-api:1.7.29" dependency "com.google.code.findbugs:jsr305:3.0.2" @@ -134,7 +134,7 @@ configure(allprojects) { project -> dependency "org.ehcache:ehcache:3.4.0" dependency "org.hibernate:hibernate-core:5.4.8.Final" dependency "org.hibernate:hibernate-validator:6.0.17.Final" - dependency "org.webjars:webjars-locator-core:0.42" + dependency "org.webjars:webjars-locator-core:0.43" dependency "org.webjars:underscorejs:1.8.3" dependencySet(group: 'org.apache.tomcat', version: '9.0.27') { From 1607f1db0bccce2d1a12102cc4a190356e8962e1 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 15 Nov 2019 10:50:28 +0100 Subject: [PATCH 0073/2315] Fix Checkstyle nohttp violation --- .../feed/RssChannelHttpMessageConverterTests.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java index a720f16d3b53..928c2cb9e1f1 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java @@ -25,7 +25,6 @@ import com.rometools.rome.feed.rss.Channel; import com.rometools.rome.feed.rss.Item; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; @@ -41,17 +40,9 @@ */ public class RssChannelHttpMessageConverterTests { - private static final MediaType RSS_XML_UTF8 = - new MediaType(MediaType.APPLICATION_RSS_XML, StandardCharsets.UTF_8); + private static final MediaType RSS_XML_UTF8 = new MediaType(MediaType.APPLICATION_RSS_XML, StandardCharsets.UTF_8); - - private RssChannelHttpMessageConverter converter; - - - @BeforeEach - public void setUp() { - converter = new RssChannelHttpMessageConverter(); - } + private final RssChannelHttpMessageConverter converter = new RssChannelHttpMessageConverter(); @Test @@ -141,7 +132,7 @@ public void writeOtherCharset() throws IOException { public void writeOtherContentTypeParameters() throws IOException { Channel channel = new Channel("rss_2.0"); channel.setTitle("title"); - channel.setLink("http://example.com"); + channel.setLink("https://example.com"); channel.setDescription("description"); MockHttpOutputMessage message = new MockHttpOutputMessage(); From d397baa559f76d88b744787da32841be59d6df96 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 15 Nov 2019 12:43:55 +0100 Subject: [PATCH 0074/2315] Polish Javadoc for AutowiredAnnotationBeanPostProcessor --- .../AutowiredAnnotationBeanPostProcessor.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index 75063ba2e6b8..b2453bf5932a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -153,7 +153,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean /** * Create a new {@code AutowiredAnnotationBeanPostProcessor} for Spring's - * standard {@link Autowired @Autowired} annotation. + * standard {@link Autowired @Autowired} and {@link Value @Value} annotations. *

    Also supports JSR-330's {@link javax.inject.Inject @Inject} annotation, * if available. */ @@ -174,9 +174,10 @@ public AutowiredAnnotationBeanPostProcessor() { /** * Set the 'autowired' annotation type, to be used on constructors, fields, - * setter methods and arbitrary config methods. - *

    The default autowired annotation type is the Spring-provided {@link Autowired} - * annotation, as well as {@link Value}. + * setter methods, and arbitrary config methods. + *

    The default autowired annotation types are the Spring-provided + * {@link Autowired @Autowired} and {@link Value @Value} annotations as well + * as JSR-330's {@link javax.inject.Inject @Inject} annotation, if available. *

    This setter property exists so that developers can provide their own * (non-Spring-specific) annotation type to indicate that a member is supposed * to be autowired. @@ -189,9 +190,10 @@ public void setAutowiredAnnotationType(Class autowiredAnno /** * Set the 'autowired' annotation types, to be used on constructors, fields, - * setter methods and arbitrary config methods. - *

    The default autowired annotation type is the Spring-provided {@link Autowired} - * annotation, as well as {@link Value}. + * setter methods, and arbitrary config methods. + *

    The default autowired annotation types are the Spring-provided + * {@link Autowired @Autowired} and {@link Value @Value} annotations as well + * as JSR-330's {@link javax.inject.Inject @Inject} annotation, if available. *

    This setter property exists so that developers can provide their own * (non-Spring-specific) annotation types to indicate that a member is supposed * to be autowired. @@ -203,7 +205,7 @@ public void setAutowiredAnnotationTypes(Set> autowir } /** - * Set the name of a parameter of the annotation that specifies whether it is required. + * Set the name of an attribute of the annotation that specifies whether it is required. * @see #setRequiredParameterValue(boolean) */ public void setRequiredParameterName(String requiredParameterName) { @@ -211,7 +213,7 @@ public void setRequiredParameterName(String requiredParameterName) { } /** - * Set the boolean value that marks a dependency as required + * Set the boolean value that marks a dependency as required. *

    For example if using 'required=true' (the default), this value should be * {@code true}; but if using 'optional=false', this value should be {@code false}. * @see #setRequiredParameterName(String) @@ -415,9 +417,11 @@ public PropertyValues postProcessPropertyValues( /** * 'Native' processing method for direct calls with an arbitrary target instance, - * resolving all of its fields and methods which are annotated with {@code @Autowired}. + * resolving all of its fields and methods which are annotated with one of the + * configured 'autowired' annotation types. * @param bean the target instance to process * @throws BeanCreationException if autowiring failed + * @see #setAutowiredAnnotationTypes(Set) */ public void processInjection(Object bean) throws BeanCreationException { Class clazz = bean.getClass(); From 9526e39f8813420f90d693c225366f80d55e0a7f Mon Sep 17 00:00:00 2001 From: denisgalaybo <57059361+denisgalaybo@users.noreply.github.com> Date: Sun, 17 Nov 2019 19:50:50 +0700 Subject: [PATCH 0075/2315] Fix errors in reference manual Closes gh-24008 --- src/docs/asciidoc/rsocket.adoc | 4 ++-- src/docs/asciidoc/web/webflux-functional.adoc | 2 +- src/docs/asciidoc/web/webflux.adoc | 4 ++-- src/docs/asciidoc/web/webmvc-functional.adoc | 2 +- src/docs/asciidoc/web/webmvc.adoc | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/docs/asciidoc/rsocket.adoc b/src/docs/asciidoc/rsocket.adoc index 9ea969f6045b..34a1e23e7274 100644 --- a/src/docs/asciidoc/rsocket.adoc +++ b/src/docs/asciidoc/rsocket.adoc @@ -485,7 +485,7 @@ Once you have a <> or [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java ---- - ViewBox box = ... ; + ViewBox viewBox = ... ; Flux locations = requester.route("locate.radars.within") // <1> .data(viewBox) // <2> @@ -499,7 +499,7 @@ Once you have a <> or [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin ---- - val box: ViewBox = ... + val viewBox: ViewBox = ... val locations = requester.route("locate.radars.within") // <1> .data(viewBox) // <2> diff --git a/src/docs/asciidoc/web/webflux-functional.adoc b/src/docs/asciidoc/web/webflux-functional.adoc index 7ff4621301ed..c79290b13989 100644 --- a/src/docs/asciidoc/web/webflux-functional.adoc +++ b/src/docs/asciidoc/web/webflux-functional.adoc @@ -474,7 +474,7 @@ header: ---- RouterFunction route = RouterFunctions.route() .GET("/hello-world", accept(MediaType.TEXT_PLAIN), - request -> ServerResponse.ok().bodyValue("Hello World")); + request -> ServerResponse.ok().bodyValue("Hello World")).build(); ---- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index 4a10ce87a806..00f71a50baa5 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -3625,7 +3625,7 @@ You can use the `@EnableWebFlux` annotation in your Java config, as the followin ---- The preceding example registers a number of Spring WebFlux -<> and adapts to dependencies +<> and adapts to dependencies available on the classpath -- for JSON, XML, and others. @@ -3861,10 +3861,10 @@ which customizes Jackson's default properties with the following ones: It also automatically registers the following well-known modules if they are detected on the classpath: -* https://github.com/FasterXML/jackson-datatype-jdk7[`jackson-datatype-jdk7`]: Support for Java 7 types like `java.nio.file.Path`. * https://github.com/FasterXML/jackson-datatype-joda[`jackson-datatype-joda`]: Support for Joda-Time types. * https://github.com/FasterXML/jackson-datatype-jsr310[`jackson-datatype-jsr310`]: Support for Java 8 Date and Time API types. * https://github.com/FasterXML/jackson-datatype-jdk8[`jackson-datatype-jdk8`]: Support for other Java 8 types, such as `Optional`. +* https://github.com/FasterXML/jackson-module-kotlin[`jackson-module-kotlin`]: Support for Kotlin classes and data classes. diff --git a/src/docs/asciidoc/web/webmvc-functional.adoc b/src/docs/asciidoc/web/webmvc-functional.adoc index 68e6bfb21465..0df2d09d7c75 100644 --- a/src/docs/asciidoc/web/webmvc-functional.adoc +++ b/src/docs/asciidoc/web/webmvc-functional.adoc @@ -409,7 +409,7 @@ header: ---- RouterFunction route = RouterFunctions.route() .GET("/hello-world", accept(MediaType.TEXT_PLAIN), - request -> ServerResponse.ok().body("Hello World")); + request -> ServerResponse.ok().body("Hello World")).build(); ---- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index 14e7d8aa7d43..da4f667bf301 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -5317,10 +5317,10 @@ This builder customizes Jackson's default properties as follows: It also automatically registers the following well-known modules if they are detected on the classpath: -* https://github.com/FasterXML/jackson-datatype-jdk7[jackson-datatype-jdk7]: Support for Java 7 types, such as `java.nio.file.Path`. * https://github.com/FasterXML/jackson-datatype-joda[jackson-datatype-joda]: Support for Joda-Time types. * https://github.com/FasterXML/jackson-datatype-jsr310[jackson-datatype-jsr310]: Support for Java 8 Date and Time API types. * https://github.com/FasterXML/jackson-datatype-jdk8[jackson-datatype-jdk8]: Support for other Java 8 types, such as `Optional`. +* https://github.com/FasterXML/jackson-module-kotlin[`jackson-module-kotlin`]: Support for Kotlin classes and data classes. NOTE: Enabling indentation with Jackson XML support requires https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.codehaus.woodstox%22%20AND%20a%3A%22woodstox-core-asl%22[`woodstox-core-asl`] From 769a15cb822a52139141369d945ac0d4221028ae Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 18 Nov 2019 13:01:26 +0100 Subject: [PATCH 0076/2315] Polishing --- .../java/org/springframework/aop/scope/ScopedProxyUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyUtils.java b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyUtils.java index cc3d00da8488..e1899cf8e5bc 100644 --- a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyUtils.java @@ -124,8 +124,8 @@ public static String getOriginalBeanName(@Nullable String targetBeanName) { } /** - * Specify if the {@code beanName} is the name of a bean that references the target - * bean within a scoped proxy. + * Determine if the {@code beanName} is the name of a bean that references + * the target bean within a scoped proxy. * @since 4.1.4 */ public static boolean isScopedTarget(@Nullable String beanName) { From 842b424acd8a4cbffd7f0dffae33fcce61fbce25 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 18 Nov 2019 17:27:09 +0000 Subject: [PATCH 0077/2315] Use method signature to refine RSocket @MessageMapping Before this change an @MessageMapping could be matched to any RSocket interaction type, which is arguably too flexible, makes it difficult to reason what would happen in case of a significant mismatch of cardinality, e.g. request for Fire-And-Forget (1-to-0) mapped to a method that returns Flux, and could result in payloads being ignored, or not seen unintentionally. This commit checks @ConnectMapping method on startup and rejects them if they return any values (sync or async). It also refines each @MessageMapping to match only the RSocket interaction type it fits based on the input and output cardinality of the handler method. Subsequently if a request is not matched, we'll do a second search to identify partial matches (by route only) and raise a helpful error that explains which interaction type is actually supported. The reference docs has been updated to explain the options. Closes gh-23999 --- .../handler/annotation/MessageMapping.java | 36 +++++-- .../AbstractMethodMessageHandler.java | 33 +++++- ...andlerMethodArgumentResolverComposite.java | 6 +- .../invocation/reactive/InvocableHelper.java | 8 ++ .../RSocketFrameTypeMessageCondition.java | 88 ++++++++++++--- .../support/RSocketMessageHandler.java | 101 ++++++++++++++++-- .../rsocket/RSocketBufferLeakTests.java | 15 +-- ...RSocketClientToServerIntegrationTests.java | 4 +- ...RSocketFrameTypeMessageConditionTests.java | 27 ++++- .../support/RSocketMessageHandlerTests.java | 100 +++++++++++++++++ ...lientToServerCoroutinesIntegrationTests.kt | 4 +- src/docs/asciidoc/rsocket.adoc | 94 +++++++++++++--- 12 files changed, 450 insertions(+), 66 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageMapping.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageMapping.java index 27c4076c8d0a..d6530a69873e 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageMapping.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageMapping.java @@ -64,18 +64,34 @@ * authenticated user. *

* - *

How the return value is handled depends on the processing scenario. For - * STOMP over WebSocket, it is turned into a message and sent to a default response - * destination or to a custom destination specified with an {@link SendTo @SendTo} - * or {@link org.springframework.messaging.simp.annotation.SendToUser @SendToUser} - * annotation. For RSocket, the response is used to reply to the stream request. + *

Return value handling depends on the processing scenario: + *

    + *
  • STOMP over WebSocket -- the value is turned into a message and sent to a + * default response destination or to a custom destination specified with an + * {@link SendTo @SendTo} or + * {@link org.springframework.messaging.simp.annotation.SendToUser @SendToUser} + * annotation. + *
  • RSocket -- the response is used to reply to the stream request. + *
* - *

Specializations of this annotation including - * {@link org.springframework.messaging.simp.annotation.SubscribeMapping @SubscribeMapping} or + *

Specializations of this annotation include + * {@link org.springframework.messaging.simp.annotation.SubscribeMapping @SubscribeMapping} + * (e.g. STOMP subscriptions) and * {@link org.springframework.messaging.rsocket.annotation.ConnectMapping @ConnectMapping} - * further narrow the mapping by message type. Both can be combined with a - * type-level {@code @MessageMapping} for declaring a common pattern prefix - * (or prefixes). + * (e.g. RSocket connections). Both narrow the primary mapping further and also match + * against the message type. Both can be combined with a type-level + * {@code @MessageMapping} that declares a common pattern prefix (or prefixes). + * + *

For further details on the use of this annotation in different contexts, + * see the following sections of the Spring Framework reference: + *

* *

NOTE: When using controller interfaces (e.g. for AOP proxying), * make sure to consistently put all your mapping annotations - such as diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java index d4a04d086be9..b0de4fde096a 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java @@ -232,6 +232,15 @@ public MultiValueMap getDestinationLookup() { return CollectionUtils.unmodifiableMultiValueMap(this.destinationLookup); } + /** + * Return the argument resolvers initialized during {@link #afterPropertiesSet()}. + * Primarily for internal use in sub-classes. + * @since 5.2.2 + */ + protected HandlerMethodArgumentResolverComposite getArgumentResolvers() { + return this.invocableHelper.getArgumentResolvers(); + } + @Override public void afterPropertiesSet() { @@ -377,6 +386,7 @@ protected final void registerHandlerMethod(Object handler, Method method, T mapp oldHandlerMethod.getBean() + "' bean method\n" + oldHandlerMethod + " mapped."); } + mapping = extendMapping(mapping, newHandlerMethod); this.handlerMethods.put(mapping, newHandlerMethod); for (String pattern : getDirectLookupMappings(mapping)) { @@ -402,6 +412,21 @@ private HandlerMethod createHandlerMethod(Object handler, Method method) { return handlerMethod; } + /** + * This method is invoked just before mappings are added. It allows + * sub-classes to update the mapping with the {@link HandlerMethod} in mind. + * This can be useful when the method signature is used to refine the + * mapping, e.g. based on the cardinality of input and output. + *

By default this method returns the mapping that is passed in. + * @param mapping the mapping to be added + * @param handlerMethod the target handler for the mapping + * @return a new mapping or the same + * @since 5.2.2 + */ + protected T extendMapping(T mapping, HandlerMethod handlerMethod) { + return mapping; + } + /** * Return String-based destinations for the given mapping, if any, that can * be used to find matches with a direct lookup (i.e. non-patterns). @@ -414,7 +439,13 @@ private HandlerMethod createHandlerMethod(Object handler, Method method) { @Override public Mono handleMessage(Message message) throws MessagingException { - Match match = getHandlerMethod(message); + Match match = null; + try { + match = getHandlerMethod(message); + } + catch (Exception ex) { + return Mono.error(ex); + } if (match == null) { // handleNoMatch would have been invoked already return Mono.empty(); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/HandlerMethodArgumentResolverComposite.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/HandlerMethodArgumentResolverComposite.java index fa0f28c244a6..6822b29f6344 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/HandlerMethodArgumentResolverComposite.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/HandlerMethodArgumentResolverComposite.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -38,7 +38,7 @@ * @author Rossen Stoyanchev * @since 5.2 */ -class HandlerMethodArgumentResolverComposite implements HandlerMethodArgumentResolver { +public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgumentResolver { protected final Log logger = LogFactory.getLog(getClass()); @@ -125,7 +125,7 @@ public Mono resolveArgument(MethodParameter parameter, Message messag * the given method parameter. */ @Nullable - private HandlerMethodArgumentResolver getArgumentResolver(MethodParameter parameter) { + public HandlerMethodArgumentResolver getArgumentResolver(MethodParameter parameter) { HandlerMethodArgumentResolver result = this.argumentResolverCache.get(parameter); if (result == null) { for (HandlerMethodArgumentResolver methodArgumentResolver : this.argumentResolvers) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHelper.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHelper.java index b144ae59a809..d4ba44d4a4d8 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHelper.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHelper.java @@ -80,6 +80,14 @@ public void addArgumentResolvers(List r this.argumentResolvers.addResolvers(resolvers); } + /** + * Return the configured resolvers. + * @since 5.2.2 + */ + public HandlerMethodArgumentResolverComposite getArgumentResolvers() { + return this.argumentResolvers; + } + /** * Add the return value handlers to use for message handling and exception * handling methods. diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java index ebbadd3cf433..3288df528087 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java @@ -56,6 +56,13 @@ public class RSocketFrameTypeMessageCondition extends AbstractMessageCondition frameTypes; @@ -68,6 +75,10 @@ public RSocketFrameTypeMessageCondition(Collection frameTypes) { this.frameTypes = Collections.unmodifiableSet(new LinkedHashSet<>(frameTypes)); } + private RSocketFrameTypeMessageCondition() { + this.frameTypes = Collections.emptySet(); + } + public Set getFrameTypes() { return this.frameTypes; @@ -124,18 +135,71 @@ public int compareTo(RSocketFrameTypeMessageCondition other, Message message) } - /** Condition to match the initial SETUP frame and subsequent metadata pushes. */ - public static final RSocketFrameTypeMessageCondition CONNECT_CONDITION = - new RSocketFrameTypeMessageCondition( - FrameType.SETUP, - FrameType.METADATA_PUSH); + /** + * Return a condition for matching the RSocket request interaction type with + * that is selected based on the delcared request and response cardinality + * of some handler method. + *

The table below shows the selections made: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Request CardinalityResponse CardinalityInteraction Types
0,10Fire-And-Forget, Request-Response
0,11Request-Response
0,12Request-Stream
2AnyRequest-Channel
+ * @param cardinalityIn -- the request cardinality: 1 for a single payload, + * 2 for many payloads, and 0 if input is not handled. + * @param cardinalityOut -- the response cardinality: 0 for no output + * payloads, 1 for a single payload, and 2 for many payloads. + * @return a condition to use for matching the interaction type + * @since 5.2.2 + */ + public static RSocketFrameTypeMessageCondition getCondition(int cardinalityIn, int cardinalityOut) { + switch (cardinalityIn) { + case 0: + case 1: + switch (cardinalityOut) { + case 0: return FF_RR_CONDITION; + case 1: return RR_CONDITION; + case 2: return RS_CONDITION; + default: throw new IllegalStateException("Invalid cardinality: " + cardinalityOut); + } + case 2: + return RC_CONDITION; + default: + throw new IllegalStateException("Invalid cardinality: " + cardinalityIn); + } + } + + + private static final RSocketFrameTypeMessageCondition FF_CONDITION = from(FrameType.REQUEST_FNF); + private static final RSocketFrameTypeMessageCondition RR_CONDITION = from(FrameType.REQUEST_RESPONSE); + private static final RSocketFrameTypeMessageCondition RS_CONDITION = from(FrameType.REQUEST_STREAM); + private static final RSocketFrameTypeMessageCondition RC_CONDITION = from(FrameType.REQUEST_CHANNEL); + private static final RSocketFrameTypeMessageCondition FF_RR_CONDITION = FF_CONDITION.combine(RR_CONDITION); - /** Condition to match one of the 4 stream request types. */ - public static final RSocketFrameTypeMessageCondition REQUEST_CONDITION = - new RSocketFrameTypeMessageCondition( - FrameType.REQUEST_FNF, - FrameType.REQUEST_RESPONSE, - FrameType.REQUEST_STREAM, - FrameType.REQUEST_CHANNEL); + private static RSocketFrameTypeMessageCondition from(FrameType... frameTypes) { + return new RSocketFrameTypeMessageCondition(frameTypes); + } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java index 7ee94e85c6c6..17aa48e99b01 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java @@ -19,6 +19,9 @@ import java.lang.reflect.AnnotatedElement; import java.util.ArrayList; import java.util.List; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; import io.rsocket.ConnectionSetupPayload; import io.rsocket.RSocket; @@ -28,6 +31,8 @@ import reactor.core.publisher.Mono; import org.springframework.beans.BeanUtils; +import org.springframework.core.MethodParameter; +import org.springframework.core.ReactiveAdapter; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.codec.Decoder; @@ -37,8 +42,11 @@ import org.springframework.messaging.MessageDeliveryException; import org.springframework.messaging.handler.CompositeMessageCondition; import org.springframework.messaging.handler.DestinationPatternsMessageCondition; +import org.springframework.messaging.handler.HandlerMethod; +import org.springframework.messaging.handler.MessageCondition; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.handler.annotation.reactive.MessageMappingMessageHandler; +import org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver; import org.springframework.messaging.handler.invocation.reactive.HandlerMethodReturnValueHandler; import org.springframework.messaging.rsocket.ClientRSocketFactoryConfigurer; import org.springframework.messaging.rsocket.MetadataExtractor; @@ -55,12 +63,27 @@ * Extension of {@link MessageMappingMessageHandler} for handling RSocket * requests with {@link ConnectMapping @ConnectMapping} and * {@link MessageMapping @MessageMapping} methods. - *

Use {@link #responder()} to obtain a {@link SocketAcceptor} adapter to - * plug in as responder into an {@link io.rsocket.RSocketFactory}. - *

Use {@link #clientResponder(RSocketStrategies, Object...)} to obtain a - * client responder configurer + * + *

For server scenarios this class can be declared as a bean in Spring + * configuration and that would detect {@code @MessageMapping} methods in + * {@code @Controller} beans. What beans are checked can be changed through a + * {@link #setHandlerPredicate(Predicate) handlerPredicate}. Given an instance + * of this class, you can then use {@link #responder()} to obtain a + * {@link SocketAcceptor} adapter to register with the + * {@link io.rsocket.RSocketFactory}. + * + *

For client scenarios, possibly in the same process as a server, consider + * consider using the static factory method + * {@link #clientResponder(RSocketStrategies, Object...)} to obtain a client + * responder to be registered with an * {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory - * RSocketRequester}. + * RSocketRequester.Builder}. + * + *

For {@code @MessageMapping} methods, this class automatically determines + * the RSocket interaction type based on the input and output cardinality of the + * method. See the + * + * "Annotated Responders" section of the Spring Framework reference for more details. * * @author Rossen Stoyanchev * @since 5.2 @@ -263,6 +286,17 @@ public void afterPropertiesSet() { getArgumentResolverConfigurer().addCustomResolver(new RSocketRequesterMethodArgumentResolver()); super.afterPropertiesSet(); + + getHandlerMethods().forEach((composite, handler) -> { + if (composite.getMessageConditions().contains(RSocketFrameTypeMessageCondition.CONNECT_CONDITION)) { + MethodParameter returnType = handler.getReturnType(); + if (getCardinality(returnType) > 0) { + throw new IllegalStateException( + "Invalid @ConnectMapping method. " + + "Return type must be void or a void async type: " + handler); + } + } + }); } @Override @@ -279,10 +313,9 @@ protected List initReturnValueHandler protected CompositeMessageCondition getCondition(AnnotatedElement element) { MessageMapping ann1 = AnnotatedElementUtils.findMergedAnnotation(element, MessageMapping.class); if (ann1 != null && ann1.value().length > 0) { - String[] patterns = processDestinations(ann1.value()); return new CompositeMessageCondition( - RSocketFrameTypeMessageCondition.REQUEST_CONDITION, - new DestinationPatternsMessageCondition(patterns, obtainRouteMatcher())); + RSocketFrameTypeMessageCondition.EMPTY_CONDITION, + new DestinationPatternsMessageCondition(processDestinations(ann1.value()), obtainRouteMatcher())); } ConnectMapping ann2 = AnnotatedElementUtils.findMergedAnnotation(element, ConnectMapping.class); if (ann2 != null) { @@ -294,6 +327,45 @@ protected CompositeMessageCondition getCondition(AnnotatedElement element) { return null; } + @Override + protected CompositeMessageCondition extendMapping(CompositeMessageCondition composite, HandlerMethod handler) { + + List> conditions = composite.getMessageConditions(); + Assert.isTrue(conditions.size() == 2 && + conditions.get(0) instanceof RSocketFrameTypeMessageCondition && + conditions.get(1) instanceof DestinationPatternsMessageCondition, + "Unexpected message condition types"); + + if (conditions.get(0) != RSocketFrameTypeMessageCondition.EMPTY_CONDITION) { + return composite; + } + + int responseCardinality = getCardinality(handler.getReturnType()); + int requestCardinality = 0; + for (MethodParameter parameter : handler.getMethodParameters()) { + if (getArgumentResolvers().getArgumentResolver(parameter) instanceof PayloadMethodArgumentResolver) { + requestCardinality = getCardinality(parameter); + } + } + + return new CompositeMessageCondition( + RSocketFrameTypeMessageCondition.getCondition(requestCardinality, responseCardinality), + conditions.get(1)); + } + + private int getCardinality(MethodParameter parameter) { + Class clazz = parameter.getParameterType(); + ReactiveAdapter adapter = getReactiveAdapterRegistry().getAdapter(clazz); + if (adapter == null) { + return clazz.equals(void.class) ? 0 : 1; + } + else if (parameter.nested().getNestedParameterType().equals(Void.class)) { + return 0; + } + else { + return adapter.isMultiValue() ? 2 : 1; + } + } @Override protected void handleNoMatch(@Nullable RouteMatcher.Route destination, Message message) { @@ -306,7 +378,18 @@ protected void handleNoMatch(@Nullable RouteMatcher.Route destination, Message frameTypes = getHandlerMethods().keySet().stream() + .map(CompositeMessageCondition::getMessageConditions) + .filter(conditions -> conditions.get(1).getMatchingCondition(message) != null) + .map(conditions -> (RSocketFrameTypeMessageCondition) conditions.get(0)) + .flatMap(condition -> condition.getFrameTypes().stream()) + .collect(Collectors.toSet()); + + throw new MessageDeliveryException(frameTypes.isEmpty() ? + "No handler for destination '" + destination + "'" : + "Destination '" + destination + "' does not support " + frameType + ". " + + "Supported interaction(s): " + frameTypes); } /** diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java index 6c288d587d40..b175f0990890 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java @@ -137,22 +137,16 @@ public void subscriptionTimeErrorForHandleAndReply() { @Test public void errorSignalWithExceptionHandler() { - Mono result = requester.route("error-signal").data("foo").retrieveMono(String.class); + Flux result = requester.route("error-signal").data("foo").retrieveFlux(String.class); StepVerifier.create(result).expectNext("Handled 'bad input'").expectComplete().verify(Duration.ofSeconds(5)); } @Test public void ignoreInput() { - Flux result = requester.route("ignore-input").data("a").retrieveFlux(String.class); + Mono result = requester.route("ignore-input").data("a").retrieveMono(String.class); StepVerifier.create(result).expectNext("bar").thenCancel().verify(Duration.ofSeconds(5)); } - @Test - public void retrieveMonoFromFluxResponderMethod() { - Mono result = requester.route("request-stream").data("foo").retrieveMono(String.class); - StepVerifier.create(result).expectNext("foo-1").expectComplete().verify(Duration.ofSeconds(5)); - } - @Controller static class ServerController { @@ -188,11 +182,6 @@ public String handleIllegalArgument(IllegalArgumentException ex) { Mono ignoreInput() { return Mono.delay(Duration.ofMillis(10)).map(l -> "bar"); } - - @MessageMapping("request-stream") - Flux stream(String payload) { - return Flux.range(1,100).delayElements(Duration.ofMillis(10)).map(idx -> payload + "-" + idx); - } } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketClientToServerIntegrationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketClientToServerIntegrationTests.java index 3b823757d4e9..db15789167b8 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketClientToServerIntegrationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketClientToServerIntegrationTests.java @@ -159,13 +159,13 @@ public void echoChannel() { @Test public void voidReturnValue() { - Flux result = requester.route("void-return-value").data("Hello").retrieveFlux(String.class); + Mono result = requester.route("void-return-value").data("Hello").retrieveMono(String.class); StepVerifier.create(result).expectComplete().verify(Duration.ofSeconds(5)); } @Test public void voidReturnValueFromExceptionHandler() { - Flux result = requester.route("void-return-value").data("bad").retrieveFlux(String.class); + Mono result = requester.route("void-return-value").data("bad").retrieveMono(String.class); StepVerifier.create(result).expectComplete().verify(Duration.ofSeconds(5)); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageConditionTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageConditionTests.java index 417baf1274e0..715ba8f43fd5 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageConditionTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageConditionTests.java @@ -26,6 +26,8 @@ import org.springframework.messaging.support.MessageBuilder; import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.messaging.rsocket.annotation.support.RSocketFrameTypeMessageCondition.CONNECT_CONDITION; +import static org.springframework.messaging.rsocket.annotation.support.RSocketFrameTypeMessageCondition.EMPTY_CONDITION; /** * Unit tests for {@link RSocketFrameTypeMessageCondition}. @@ -33,16 +35,37 @@ */ public class RSocketFrameTypeMessageConditionTests { + private static final RSocketFrameTypeMessageCondition FNF_RR_CONDITION = + new RSocketFrameTypeMessageCondition(FrameType.REQUEST_FNF, FrameType.REQUEST_RESPONSE); + + @Test public void getMatchingCondition() { Message message = message(FrameType.REQUEST_RESPONSE); - RSocketFrameTypeMessageCondition condition = condition(FrameType.REQUEST_FNF, FrameType.REQUEST_RESPONSE); - RSocketFrameTypeMessageCondition actual = condition.getMatchingCondition(message); + RSocketFrameTypeMessageCondition actual = FNF_RR_CONDITION.getMatchingCondition(message); assertThat(actual).isNotNull(); assertThat(actual.getFrameTypes()).hasSize(1).containsOnly(FrameType.REQUEST_RESPONSE); } + @Test + public void getMatchingConditionEmpty() { + Message message = message(FrameType.REQUEST_RESPONSE); + RSocketFrameTypeMessageCondition actual = EMPTY_CONDITION.getMatchingCondition(message); + + assertThat(actual).isNull(); + } + + @Test + public void combine() { + + assertThat(EMPTY_CONDITION.combine(CONNECT_CONDITION).getFrameTypes()) + .containsExactly(FrameType.SETUP, FrameType.METADATA_PUSH); + + assertThat(EMPTY_CONDITION.combine(new RSocketFrameTypeMessageCondition(FrameType.REQUEST_FNF)).getFrameTypes()) + .containsExactly(FrameType.REQUEST_FNF); + } + @Test public void compareTo() { Message message = message(null); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandlerTests.java index 52c124e07901..c7d0a80a1d87 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandlerTests.java @@ -21,6 +21,9 @@ import io.rsocket.frame.FrameType; import org.junit.jupiter.api.Test; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.codec.ByteArrayDecoder; @@ -170,6 +173,69 @@ private static void testMapping(Object controller, String... expectedPatterns) { } } + @Test + public void rejectConnectMappingMethodsThatCanReply() { + + RSocketMessageHandler handler = new RSocketMessageHandler(); + handler.setHandlers(Collections.singletonList(new InvalidConnectMappingController())); + assertThatThrownBy(handler::afterPropertiesSet) + .hasMessage("Invalid @ConnectMapping method. " + + "Return type must be void or a void async type: " + + "public java.lang.String org.springframework.messaging.rsocket.annotation.support." + + "RSocketMessageHandlerTests$InvalidConnectMappingController.connectString()"); + + handler = new RSocketMessageHandler(); + handler.setHandlers(Collections.singletonList(new AnotherInvalidConnectMappingController())); + assertThatThrownBy(handler::afterPropertiesSet) + .hasMessage("Invalid @ConnectMapping method. " + + "Return type must be void or a void async type: " + + "public reactor.core.publisher.Mono " + + "org.springframework.messaging.rsocket.annotation.support." + + "RSocketMessageHandlerTests$AnotherInvalidConnectMappingController.connectString()"); + } + + @Test + public void ignoreFireAndForgetToHandlerThatCanReply() { + + InteractionMismatchController controller = new InteractionMismatchController(); + + RSocketMessageHandler handler = new RSocketMessageHandler(); + handler.setHandlers(Collections.singletonList(controller)); + handler.afterPropertiesSet(); + + MessageHeaderAccessor headers = new MessageHeaderAccessor(); + headers.setLeaveMutable(true); + RouteMatcher.Route route = handler.getRouteMatcher().parseRoute("mono-string"); + headers.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, route); + headers.setHeader(RSocketFrameTypeMessageCondition.FRAME_TYPE_HEADER, FrameType.REQUEST_FNF); + Message message = MessageBuilder.createMessage(Mono.empty(), headers.getMessageHeaders()); + + // Simply dropped and logged (error cannot propagate to client) + StepVerifier.create(handler.handleMessage(message)).expectComplete().verify(); + assertThat(controller.invokeCount).isEqualTo(0); + } + + @Test + public void rejectRequestResponseToStreamingHandler() { + + RSocketMessageHandler handler = new RSocketMessageHandler(); + handler.setHandlers(Collections.singletonList(new InteractionMismatchController())); + handler.afterPropertiesSet(); + + MessageHeaderAccessor headers = new MessageHeaderAccessor(); + headers.setLeaveMutable(true); + RouteMatcher.Route route = handler.getRouteMatcher().parseRoute("flux-string"); + headers.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, route); + headers.setHeader(RSocketFrameTypeMessageCondition.FRAME_TYPE_HEADER, FrameType.REQUEST_RESPONSE); + Message message = MessageBuilder.createMessage(Mono.empty(), headers.getMessageHeaders()); + + StepVerifier.create(handler.handleMessage(message)) + .expectErrorMessage( + "Destination 'flux-string' does not support REQUEST_RESPONSE. " + + "Supported interaction(s): [REQUEST_STREAM]") + .verify(); + } + @Test public void handleNoMatch() { @@ -222,4 +288,38 @@ public void handleAll() { } } + + private static class InvalidConnectMappingController { + + @ConnectMapping + public String connectString() { + return ""; + } + } + + private static class AnotherInvalidConnectMappingController { + + @ConnectMapping + public Mono connectString() { + return Mono.empty(); + } + } + + private static class InteractionMismatchController { + + private int invokeCount; + + @MessageMapping("mono-string") + public Mono messageMonoString() { + this.invokeCount++; + return Mono.empty(); + } + + @MessageMapping("flux-string") + public Flux messageFluxString() { + this.invokeCount++; + return Flux.empty(); + } + } + } diff --git a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt index b02efc11d188..cbc5a5a77a73 100644 --- a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt +++ b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt @@ -84,13 +84,13 @@ class RSocketClientToServerCoroutinesIntegrationTests { @Test fun unitReturnValue() { - val result = requester.route("unit-return-value").data("Hello").retrieveFlux(String::class.java) + val result = requester.route("unit-return-value").data("Hello").retrieveMono(String::class.java) StepVerifier.create(result).expectComplete().verify(Duration.ofSeconds(5)) } @Test fun unitReturnValueFromExceptionHandler() { - val result = requester.route("unit-return-value").data("bad").retrieveFlux(String::class.java) + val result = requester.route("unit-return-value").data("bad").retrieveMono(String::class.java) StepVerifier.create(result).expectComplete().verify(Duration.ofSeconds(5)) } diff --git a/src/docs/asciidoc/rsocket.adoc b/src/docs/asciidoc/rsocket.adoc index 34a1e23e7274..752699289eb9 100644 --- a/src/docs/asciidoc/rsocket.adoc +++ b/src/docs/asciidoc/rsocket.adoc @@ -586,7 +586,7 @@ indicates only that the message was successfully sent, and not that it was handl == Annotated Responders RSocket responders can be implemented as `@MessageMapping` and `@ConnectMapping` methods. -`@MessageMapping` methods handle individual requests, and `@ConnectMapping` methods handle +`@MessageMapping` methods handle individual requests while `@ConnectMapping` methods handle connection-level events (setup and metadata push). Annotated responders are supported symmetrically, for responding from the server side and for responding from the client side. @@ -760,20 +760,90 @@ class RadarsController { } ---- -You don't need to explicit specify the RSocket interaction type. Simply declare the -expected input and output, and a route pattern. The supporting infrastructure will adapt -matching requests. +The above `@MessageMapping` method responds to a Request-Stream interaction having the +route "locate.radars.within". It supports a flexible method signature with the option to +use the following method arguments: -The following additional arguments are supported for `@MessageMapping` methods: +[cols="1,3",options="header"] +|=== +| Method Argument +| Description -* `RSocketRequester` -- the requester for the connection associated with the request, - to make requests to the remote end. -* `@DestinationVariable` -- the value for a variable from the pattern, e.g. +| `@Payload` +| The payload of the request. This can be a concrete value of asynchronous types like + `Mono` or `Flux`. + + *Note:* Use of the annotation is optional. A method argument that is not a simple type + and is not any of the other supported arguments, is assumed to be the expected payload. + +| `RSocketRequester` +| Requester for making requests to the remote end. + +| `@DestinationVariable` +| Value extracted from the route based on variables in the mapping pattern, e.g. `@MessageMapping("find.radar.{id}")`. -* `@Header` -- access to a metadata value registered for extraction, as described in - <>. -* `@Headers Map` -- access to all metadata values registered for - extraction, as described in <>. + +| `@Header` +| Metadata value registered for extraction as described in <>. + +| `@Headers Map` +| All metadata values registered for extraction as described in <>. + +|=== + +The return value is expected to be one or more Objects to be serialized as response +payloads. That can be asynchronous types like `Mono` or `Flux`, a concrete value, or +either `void` or a no-value asynchronous type such as `Mono`. + +The RSocket interaction type that an `@MessageMapping` method supports is determined from +the cardinality of the input (i.e. `@Payload` argument) and of the output, where +cardinality means the following: + +[%autowidth] +[cols=2*,options="header"] +|=== +| Cardinality +| Description + +| 1 +| Either an explicit value, or a single-value asynchronous type such as `Mono`. + +| Many +| A multi-value asynchronous type such as `Flux`. + +| 0 +| For input this means the method does not have an `@Payload` argument. + + For output this is `void` or a no-value asynchronous type such as `Mono`. +|=== + +The table below shows all input and output cardinality combinations and the corresponding +interaction type(s): + +[%autowidth] +[cols=3*,options="header"] +|=== +| Input Cardinality +| Output Cardinality +| Interaction Types + +| 0, 1 +| 0 +| Fire-and-Forget, Request-Response + +| 0, 1 +| 1 +| Request-Response + +| 0, 1 +| Many +| Request-Stream + +| Many +| 0, 1, Many +| Request-Channel + +|=== From f0b2f7186a013d1621869eccf50a1a273b12be5a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 18 Nov 2019 16:12:55 +0100 Subject: [PATCH 0078/2315] Polishing --- .../annotation/RequestMappingHandlerAdapter.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java index 9dd6be0c141b..53eda754d032 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java @@ -917,9 +917,9 @@ private ModelFactory getModelFactory(HandlerMethod handlerMethod, WebDataBinderF } List attrMethods = new ArrayList<>(); // Global methods first - this.modelAttributeAdviceCache.forEach((clazz, methodSet) -> { - if (clazz.isApplicableToBeanType(handlerType)) { - Object bean = clazz.resolveBean(); + this.modelAttributeAdviceCache.forEach((controllerAdviceBean, methodSet) -> { + if (controllerAdviceBean.isApplicableToBeanType(handlerType)) { + Object bean = controllerAdviceBean.resolveBean(); for (Method method : methodSet) { attrMethods.add(createModelAttributeMethod(binderFactory, bean, method)); } @@ -951,9 +951,9 @@ private WebDataBinderFactory getDataBinderFactory(HandlerMethod handlerMethod) t } List initBinderMethods = new ArrayList<>(); // Global methods first - this.initBinderAdviceCache.forEach((clazz, methodSet) -> { - if (clazz.isApplicableToBeanType(handlerType)) { - Object bean = clazz.resolveBean(); + this.initBinderAdviceCache.forEach((controllerAdviceBean, methodSet) -> { + if (controllerAdviceBean.isApplicableToBeanType(handlerType)) { + Object bean = controllerAdviceBean.resolveBean(); for (Method method : methodSet) { initBinderMethods.add(createInitBinderMethod(bean, method)); } From 3a39b7fe82a961883e8ba4b6bbf5d9d4cc500450 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 18 Nov 2019 22:28:53 +0100 Subject: [PATCH 0079/2315] Support scoped @ControllerAdvice beans again Spring Framework 5.2 introduced support for implementing the Ordered interface in a @ControllerAdvice bean. This support requires that @ControllerAdvice beans be eagerly resolved from the BeanFactory in order to invoke the getOrder() method defined in the Ordered interface. Unfortunately doing so resulted in a regression in that an attempt to eagerly resolve a scoped @ControllerAdvice bean throws a BeanCreationException due to the lack of an active scope (e.g., request or session scope). This commit fixes this regression by avoiding eager resolution of scoped @ControllerAdvice beans. As a direct consequence, the Ordered interface is not supported for scoped @ControllerAdvice beans. Closes gh-23985 --- .../web/bind/annotation/ControllerAdvice.java | 10 +- .../web/method/ControllerAdviceBean.java | 32 ++++++- ...copedControllerAdviceIntegrationTests.java | 91 +++++++++++++++++++ 3 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java diff --git a/spring-web/src/main/java/org/springframework/web/bind/annotation/ControllerAdvice.java b/spring-web/src/main/java/org/springframework/web/bind/annotation/ControllerAdvice.java index 47ebcd631487..decfce3eb1af 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/annotation/ControllerAdvice.java +++ b/spring-web/src/main/java/org/springframework/web/bind/annotation/ControllerAdvice.java @@ -42,10 +42,12 @@ * Note, however, that {@code @ControllerAdvice} beans that implement * {@link org.springframework.core.PriorityOrdered PriorityOrdered} are not * given priority over {@code @ControllerAdvice} beans that implement {@code Ordered}. - * For handling exceptions, an {@code @ExceptionHandler} will be picked on the - * first advice with a matching exception handler method. For model attributes - * and {@code InitBinder} initialization, {@code @ModelAttribute} and - * {@code @InitBinder} methods will also follow {@code @ControllerAdvice} order. + * In addition, {@code Ordered} is not honored for scoped {@code @ControllerAdvice} + * beans — for example if such a bean has been configured as a request-scoped + * or session-scoped bean. For handling exceptions, an {@code @ExceptionHandler} + * will be picked on the first advice with a matching exception handler method. For + * model attributes and data binding initialization, {@code @ModelAttribute} and + * {@code @InitBinder} methods will follow {@code @ControllerAdvice} order. * *

Note: For {@code @ExceptionHandler} methods, a root exception match will be * preferred to just matching a cause of the current exception, among the handler diff --git a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java index 90b59765d9ac..8ec98e0ee7b0 100644 --- a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java +++ b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; +import org.springframework.aop.scope.ScopedProxyUtils; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.context.ApplicationContext; @@ -124,19 +125,42 @@ public ControllerAdviceBean(String beanName, BeanFactory beanFactory, @Nullable /** * Get the order value for the contained bean. *

As of Spring Framework 5.2, the order value is lazily retrieved using - * the following algorithm and cached. + * the following algorithm and cached. Note, however, that a + * {@link ControllerAdvice @ControllerAdvice} bean that is configured as a + * scoped bean — for example, as a request-scoped or session-scoped + * bean — will not be eagerly resolved. Consequently, {@link Ordered} is + * not honored for scoped {@code @ControllerAdvice} beans. *

    *
  • If the {@linkplain #resolveBean resolved bean} implements {@link Ordered}, * use the value returned by {@link Ordered#getOrder()}.
  • - *
  • Otherwise use the value returned by {@link OrderUtils#getOrder(Class, int)} - * with {@link Ordered#LOWEST_PRECEDENCE} used as the default order value.
  • + *
  • If the {@linkplain #getBeanType() bean type} is known, use the value returned + * by {@link OrderUtils#getOrder(Class, int)} with {@link Ordered#LOWEST_PRECEDENCE} + * used as the default order value.
  • + *
  • Otherwise use {@link Ordered#LOWEST_PRECEDENCE} as the default, fallback + * order value.
  • *
* @see #resolveBean() */ @Override public int getOrder() { if (this.order == null) { - Object resolvedBean = resolveBean(); + Object resolvedBean = null; + if (this.beanOrName instanceof String) { + String beanName = (String) this.beanOrName; + String targetBeanName = ScopedProxyUtils.getTargetBeanName(beanName); + boolean isScopedProxy = this.beanFactory.containsBean(targetBeanName); + // Avoid eager @ControllerAdvice bean resolution for scoped proxies, + // since attempting to do so during context initialization would result + // in an exception due to the current absence of the scope. For example, + // an HTTP request or session scope is not active during initialization. + if (!isScopedProxy && !ScopedProxyUtils.isScopedTarget(beanName)) { + resolvedBean = resolveBean(); + } + } + else { + resolvedBean = resolveBean(); + } + if (resolvedBean instanceof Ordered) { this.order = ((Ordered) resolvedBean).getOrder(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java new file mode 100644 index 000000000000..14b812987afa --- /dev/null +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java @@ -0,0 +1,91 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.web.servlet.mvc.method.annotation; + +import java.util.List; + +import org.junit.jupiter.api.Test; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.mock.web.test.MockServletContext; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.context.annotation.RequestScope; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.method.ControllerAdviceBean; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; + +/** + * Integration tests for request-scoped {@link ControllerAdvice @ControllerAdvice} beans. + * + * @author Sam Brannen + * @since 5.2.2 + */ +class RequestScopedControllerAdviceIntegrationTests { + + @Test // gh-23985 + @SuppressWarnings({ "rawtypes", "unchecked" }) + void loadContextWithRequestScopedControllerAdvice() { + AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); + context.setServletContext(new MockServletContext()); + context.register(Config.class); + + assertThatCode(context::refresh).doesNotThrowAnyException(); + + // Until gh-24017 is fixed, we expect the RequestScopedControllerAdvice to show up twice. + Class[] expectedTypes = { RequestScopedControllerAdvice.class, RequestScopedControllerAdvice.class }; + + List adviceBeans = ControllerAdviceBean.findAnnotatedBeans(context); + assertThat(adviceBeans)// + .extracting(ControllerAdviceBean::getBeanType)// + .containsExactly(expectedTypes); + + assertThat(adviceBeans)// + .extracting(ControllerAdviceBean::getOrder)// + .containsExactly(42, 42); + + context.close(); + } + + + @Configuration + @EnableWebMvc + static class Config { + + @Bean + @RequestScope + RequestScopedControllerAdvice requestScopedControllerAdvice() { + return new RequestScopedControllerAdvice(); + } + } + + @ControllerAdvice + @Order(42) + static class RequestScopedControllerAdvice implements Ordered { + + @Override + public int getOrder() { + return 99; + } + } + +} From 9f7dd9f35260368cafbc405b52f90ef72a9d0686 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Tue, 19 Nov 2019 10:22:47 +0100 Subject: [PATCH 0080/2315] Add test for usage of bodyToMono in WebClient.ResponseSpec::onStatus See gh-23365 --- .../client/WebClientIntegrationTests.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java index 2cbe2f2e3587..dfe54d29dc8e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java @@ -1099,6 +1099,34 @@ void nullJsonResponseShouldBeReadAsEmpty(ClientHttpConnector connector) { .verifyComplete(); } + @ParameterizedWebClientTest + void mapBodyInOnStatus(ClientHttpConnector connector) { + startServer(connector); + + prepareResponse(response -> response + .setResponseCode(500) + .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .setBody("{\"fooValue\":\"bar\"}") + ); + + Mono result = this.webClient.get() + .uri("/json") + .retrieve() + .onStatus(HttpStatus::isError, response -> + response.bodyToMono(Foo.class) + .flatMap(foo -> Mono.error(new MyException(foo.getFooValue()))) + ) + .bodyToMono(String.class); + + StepVerifier.create(result) + .consumeErrorWith(throwable -> { + assertThat(throwable).isInstanceOf(MyException.class); + MyException error = (MyException) throwable; + assertThat(error.getMessage()).isEqualTo("bar"); + }) + .verify(); + } + private void prepareResponse(Consumer consumer) { MockResponse response = new MockResponse(); From 4c17314d0e07572fec0c28957f4de468238a2af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Tue, 19 Nov 2019 10:50:05 +0100 Subject: [PATCH 0081/2315] Upgrade to Kotlin 1.3.60 Closes gh-24006 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 4d73741fa08f..ee7a791d034d 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { plugins { id 'io.spring.dependency-management' version '1.0.8.RELEASE' apply false - id 'org.jetbrains.kotlin.jvm' version '1.3.50' apply false + id 'org.jetbrains.kotlin.jvm' version '1.3.60' apply false id 'org.jetbrains.dokka' version '0.9.18' apply false id 'org.asciidoctor.convert' version '1.5.8' id 'io.spring.nohttp' version '0.0.3.RELEASE' @@ -48,7 +48,7 @@ configure(allprojects) { project -> mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR1" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" mavenBom "org.eclipse.jetty:jetty-bom:9.4.21.v20190926" - mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.50" + mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.60" mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.2" mavenBom "org.junit:junit-bom:5.5.2" } From b4e1d483228c8b1763080e56b50c28c8bfd9a5d9 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 19 Nov 2019 14:20:19 +0100 Subject: [PATCH 0082/2315] Ignore scoped proxy targets for @ControllerAdvice beans Prior to this commit, methods in a @ControllerAdvice bean were registered and invoked twice if the advice was a scoped bean (e.g., request or session scoped). In other words, both the proxy bean and the target bean were wrapped in ControllerAdviceBean instances. This commit fixes this bug by modifying the findAnnotatedBeans() method in ControllerAdviceBean so that it filters out targets of scoped proxies. Closes gh-24017 --- .../spr/ControllerAdviceIntegrationTests.java | 128 ++++++++++++++++++ .../web/method/ControllerAdviceBean.java | 12 +- ...copedControllerAdviceIntegrationTests.java | 15 +- 3 files changed, 139 insertions(+), 16 deletions(-) create mode 100644 spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java new file mode 100644 index 000000000000..b62795d2b9f1 --- /dev/null +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java @@ -0,0 +1,128 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.test.web.servlet.samples.spr; + +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Controller; +import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.annotation.RequestScope; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrl; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup; + +/** + * Integration tests for {@link ControllerAdvice @ControllerAdvice}. + * + *

Introduced in conjunction with + * gh-24017. + * + * @author Sam Brannen + * @since 5.1.12 + */ +@SpringJUnitWebConfig +class ControllerAdviceIntegrationTests { + + MockMvc mockMvc; + + @BeforeEach + void setUpMockMvc(WebApplicationContext wac) { + this.mockMvc = webAppContextSetup(wac).build(); + } + + @Test + void controllerAdviceIsAppliedOnlyOnce() throws Exception { + assertThat(SingletonControllerAdvice.counter).hasValue(0); + assertThat(RequestScopedControllerAdvice.counter).hasValue(0); + + this.mockMvc.perform(get("/test"))// + .andExpect(status().isOk())// + .andExpect(forwardedUrl("singleton:1;request-scoped:1")); + + assertThat(SingletonControllerAdvice.counter).hasValue(1); + assertThat(RequestScopedControllerAdvice.counter).hasValue(1); + } + + @Configuration + @EnableWebMvc + static class Config { + + @Bean + TestController testController() { + return new TestController(); + } + + @Bean + SingletonControllerAdvice singletonControllerAdvice() { + return new SingletonControllerAdvice(); + } + + @Bean + @RequestScope + RequestScopedControllerAdvice requestScopedControllerAdvice() { + return new RequestScopedControllerAdvice(); + } + } + + @ControllerAdvice + static class SingletonControllerAdvice { + + static final AtomicInteger counter = new AtomicInteger(); + + @ModelAttribute + void initModel(Model model) { + model.addAttribute("singleton", counter.incrementAndGet()); + } + } + + @ControllerAdvice + static class RequestScopedControllerAdvice { + + static final AtomicInteger counter = new AtomicInteger(); + + @ModelAttribute + void initModel(Model model) { + model.addAttribute("request-scoped", counter.incrementAndGet()); + } + } + + @Controller + static class TestController { + + @GetMapping("/test") + String get(Model model) { + return "singleton:" + model.getAttribute("singleton") + ";request-scoped:" + + model.getAttribute("request-scoped"); + } + } + +} diff --git a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java index 8ec98e0ee7b0..e66bb4473091 100644 --- a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java +++ b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java @@ -252,11 +252,13 @@ public String toString() { public static List findAnnotatedBeans(ApplicationContext context) { List adviceBeans = new ArrayList<>(); for (String name : BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context, Object.class)) { - ControllerAdvice controllerAdvice = context.findAnnotationOnBean(name, ControllerAdvice.class); - if (controllerAdvice != null) { - // Use the @ControllerAdvice annotation found by findAnnotationOnBean() - // in order to avoid a subsequent lookup of the same annotation. - adviceBeans.add(new ControllerAdviceBean(name, context, controllerAdvice)); + if (!ScopedProxyUtils.isScopedTarget(name)) { + ControllerAdvice controllerAdvice = context.findAnnotationOnBean(name, ControllerAdvice.class); + if (controllerAdvice != null) { + // Use the @ControllerAdvice annotation found by findAnnotationOnBean() + // in order to avoid a subsequent lookup of the same annotation. + adviceBeans.add(new ControllerAdviceBean(name, context, controllerAdvice)); + } } } OrderComparator.sort(adviceBeans); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java index 14b812987afa..8cb79c50d26c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java @@ -43,7 +43,6 @@ class RequestScopedControllerAdviceIntegrationTests { @Test // gh-23985 - @SuppressWarnings({ "rawtypes", "unchecked" }) void loadContextWithRequestScopedControllerAdvice() { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.setServletContext(new MockServletContext()); @@ -51,17 +50,11 @@ void loadContextWithRequestScopedControllerAdvice() { assertThatCode(context::refresh).doesNotThrowAnyException(); - // Until gh-24017 is fixed, we expect the RequestScopedControllerAdvice to show up twice. - Class[] expectedTypes = { RequestScopedControllerAdvice.class, RequestScopedControllerAdvice.class }; - List adviceBeans = ControllerAdviceBean.findAnnotatedBeans(context); - assertThat(adviceBeans)// - .extracting(ControllerAdviceBean::getBeanType)// - .containsExactly(expectedTypes); - - assertThat(adviceBeans)// - .extracting(ControllerAdviceBean::getOrder)// - .containsExactly(42, 42); + assertThat(adviceBeans).size().isEqualTo(1); + assertThat(adviceBeans.get(0))// + .returns(RequestScopedControllerAdvice.class, ControllerAdviceBean::getBeanType)// + .returns(42, ControllerAdviceBean::getOrder); context.close(); } From 4af6039359d5f950cf811f5b51edad28c728edc8 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 19 Nov 2019 14:53:30 +0100 Subject: [PATCH 0083/2315] Avoid substring allocation in StringUtils.replace Closes gh-24023 --- .../src/main/java/org/springframework/util/StringUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/StringUtils.java b/spring-core/src/main/java/org/springframework/util/StringUtils.java index 0b12f3430e28..4b720ac8e7f6 100644 --- a/spring-core/src/main/java/org/springframework/util/StringUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StringUtils.java @@ -420,14 +420,14 @@ public static String replace(String inString, String oldPattern, @Nullable Strin int pos = 0; // our position in the old string int patLen = oldPattern.length(); while (index >= 0) { - sb.append(inString.substring(pos, index)); + sb.append(inString, pos, index); sb.append(newPattern); pos = index + patLen; index = inString.indexOf(oldPattern, pos); } // append any characters to the right of a match - sb.append(inString.substring(pos)); + sb.append(inString, pos, inString.length()); return sb.toString(); } From 06b1f31cdd779a44a69f889b9f57b210e3432ca2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 19 Nov 2019 14:54:12 +0100 Subject: [PATCH 0084/2315] SynthesizedMergedAnnotationInvocationHandler does not pre-load values Closes gh-24029 --- ...izedMergedAnnotationInvocationHandler.java | 3 - .../core/annotation/AnnotationUtilsTests.java | 29 +- .../annotation/MergedAnnotationsTests.java | 341 +++++++----------- 3 files changed, 150 insertions(+), 223 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java b/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java index fe1131bf16c4..1a19f499e257 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java @@ -61,9 +61,6 @@ private SynthesizedMergedAnnotationInvocationHandler(MergedAnnotation annotat this.annotation = annotation; this.type = type; this.attributes = AttributeMethods.forAnnotationType(type); - for (int i = 0; i < this.attributes.size(); i++) { - getAttributeValue(this.attributes.get(i)); - } } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 63c46631bdb7..6270f108841e 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -28,6 +28,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Set; import javax.annotation.Nonnull; @@ -46,7 +47,7 @@ import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.springframework.core.annotation.AnnotationUtils.VALUE; import static org.springframework.core.annotation.AnnotationUtils.findAnnotation; import static org.springframework.core.annotation.AnnotationUtils.findAnnotationDeclaringClass; @@ -685,7 +686,8 @@ void getDeclaredRepeatableAnnotationsDeclaredOnClass() { assertThat(values).isEqualTo(expectedValuesJava); // Spring - Set set = getDeclaredRepeatableAnnotations(MyRepeatableClass.class, MyRepeatable.class, MyRepeatableContainer.class); + Set set = getDeclaredRepeatableAnnotations( + MyRepeatableClass.class, MyRepeatable.class, MyRepeatableContainer.class); assertThat(set).isNotNull(); values = set.stream().map(MyRepeatable::value).collect(toList()); assertThat(values).isEqualTo(expectedValuesSpring); @@ -720,7 +722,8 @@ void getDeclaredRepeatableAnnotationsDeclaredOnSuperclass() { @Test void synthesizeAnnotationWithImplicitAliasesWithMissingDefaultValues() throws Exception { Class clazz = ImplicitAliasesWithMissingDefaultValuesContextConfigClass.class; - Class annotationType = ImplicitAliasesWithMissingDefaultValuesContextConfig.class; + Class annotationType = + ImplicitAliasesWithMissingDefaultValuesContextConfig.class; ImplicitAliasesWithMissingDefaultValuesContextConfig config = clazz.getAnnotation(annotationType); assertThat(config).isNotNull(); @@ -735,7 +738,8 @@ void synthesizeAnnotationWithImplicitAliasesWithMissingDefaultValues() throws Ex @Test void synthesizeAnnotationWithImplicitAliasesWithDifferentDefaultValues() throws Exception { Class clazz = ImplicitAliasesWithDifferentDefaultValuesContextConfigClass.class; - Class annotationType = ImplicitAliasesWithDifferentDefaultValuesContextConfig.class; + Class annotationType = + ImplicitAliasesWithDifferentDefaultValuesContextConfig.class; ImplicitAliasesWithDifferentDefaultValuesContextConfig config = clazz.getAnnotation(annotationType); assertThat(config).isNotNull(); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -749,7 +753,8 @@ void synthesizeAnnotationWithImplicitAliasesWithDifferentDefaultValues() throws @Test void synthesizeAnnotationWithImplicitAliasesWithDuplicateValues() throws Exception { Class clazz = ImplicitAliasesWithDuplicateValuesContextConfigClass.class; - Class annotationType = ImplicitAliasesWithDuplicateValuesContextConfig.class; + Class annotationType = + ImplicitAliasesWithDuplicateValuesContextConfig.class; ImplicitAliasesWithDuplicateValuesContextConfig config = clazz.getAnnotation(annotationType); assertThat(config).isNotNull(); @@ -780,7 +785,8 @@ void synthesizeAnnotationFromMapWithoutAttributeAliases() throws Exception { @Test @SuppressWarnings("unchecked") void synthesizeAnnotationFromMapWithNestedMap() throws Exception { - ComponentScanSingleFilter componentScan = ComponentScanSingleFilterClass.class.getAnnotation(ComponentScanSingleFilter.class); + ComponentScanSingleFilter componentScan = + ComponentScanSingleFilterClass.class.getAnnotation(ComponentScanSingleFilter.class); assertThat(componentScan).isNotNull(); assertThat(componentScan.value().pattern()).as("value from ComponentScan: ").isEqualTo("*Foo"); @@ -827,7 +833,8 @@ void synthesizeAnnotationFromMapWithNestedArrayOfMaps() throws Exception { filters[1].put("pattern", "newBar"); filters[1].put("enigma", 42); - ComponentScan synthesizedComponentScan = synthesizeAnnotation(attributes, ComponentScan.class, ComponentScanClass.class); + ComponentScan synthesizedComponentScan = + synthesizeAnnotation(attributes, ComponentScan.class, ComponentScanClass.class); assertThat(synthesizedComponentScan).isNotNull(); assertThat(synthesizedComponentScan).isNotSameAs(componentScan); @@ -911,16 +918,16 @@ void synthesizeAnnotationFromMapWithNullAttributeValue() throws Exception { } private void assertMissingTextAttribute(Map attributes) { - assertThatIllegalArgumentException().isThrownBy(() -> - synthesizeAnnotation(attributes, AnnotationWithoutDefaults.class, null)) + assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(() -> + synthesizeAnnotation(attributes, AnnotationWithoutDefaults.class, null).text()) .withMessageContaining("No value found for attribute named 'text' in merged annotation"); } @Test void synthesizeAnnotationFromMapWithAttributeOfIncorrectType() throws Exception { Map map = Collections.singletonMap(VALUE, 42L); - assertThatIllegalArgumentException().isThrownBy(() -> - synthesizeAnnotation(map, Component.class, null)) + assertThatIllegalStateException().isThrownBy(() -> + synthesizeAnnotation(map, Component.class, null).value()) .withMessageContaining("Attribute 'value' in annotation org.springframework.stereotype.Component " + "should be compatible with java.lang.String but a java.lang.Long value was returned"); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java index 02fe39f0f33f..6241039c40f1 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java @@ -272,8 +272,7 @@ void getWithInheritedAnnotationsFromClassWithLocalAnnotationThatShadowsAnnotatio @Test void getWithInheritedAnnotationsFromMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() { MergedAnnotation annotation = MergedAnnotations.from( - MetaCycleAnnotatedClass.class, SearchStrategy.INHERITED_ANNOTATIONS).get( - Transactional.class); + MetaCycleAnnotatedClass.class, SearchStrategy.INHERITED_ANNOTATIONS).get(Transactional.class); assertThat(annotation.isPresent()).isFalse(); } @@ -396,8 +395,7 @@ void getWithInheritedAnnotationsFromImplicitAliasesInMetaAnnotationOnComposedAnn @Test void getWithInheritedAnnotationsFromAliasedValueComposedAnnotation() { - testGetWithInherited(AliasedValueComposedContextConfigurationClass.class, - "test.xml"); + testGetWithInherited(AliasedValueComposedContextConfigurationClass.class, "test.xml"); } @Test @@ -409,29 +407,25 @@ void getWithInheritedAnnotationsFromImplicitAliasesForSameAttributeInComposedAnn @Test void getWithInheritedAnnotationsFromTransitiveImplicitAliases() { - testGetWithInherited(TransitiveImplicitAliasesContextConfigurationClass.class, - "test.groovy"); + testGetWithInherited(TransitiveImplicitAliasesContextConfigurationClass.class, "test.groovy"); } @Test void getWithInheritedAnnotationsFromTransitiveImplicitAliasesWithSingleElementOverridingAnArrayViaAliasFor() { testGetWithInherited( - SingleLocationTransitiveImplicitAliasesContextConfigurationClass.class, - "test.groovy"); + SingleLocationTransitiveImplicitAliasesContextConfigurationClass.class, "test.groovy"); } @Test void getWithInheritedAnnotationsFromTransitiveImplicitAliasesWithSkippedLevel() { testGetWithInherited( - TransitiveImplicitAliasesWithSkippedLevelContextConfigurationClass.class, - "test.xml"); + TransitiveImplicitAliasesWithSkippedLevelContextConfigurationClass.class, "test.xml"); } @Test void getWithInheritedAnnotationsFromTransitiveImplicitAliasesWithSkippedLevelWithSingleElementOverridingAnArrayViaAliasFor() { testGetWithInherited( - SingleLocationTransitiveImplicitAliasesWithSkippedLevelContextConfigurationClass.class, - "test.xml"); + SingleLocationTransitiveImplicitAliasesWithSkippedLevelContextConfigurationClass.class, "test.xml"); } private void testGetWithInherited(Class element, String... expected) { @@ -461,8 +455,7 @@ void getWithInheritedAnnotationsFromShadowedAliasComposedAnnotation() { @Test void getWithTypeHierarchyFromInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( - InheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( - Transactional.class); + InheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Transactional.class); assertThat(annotation.isPresent()).isTrue(); assertThat(annotation.getAggregateIndex()).isEqualTo(0); } @@ -470,8 +463,7 @@ void getWithTypeHierarchyFromInheritedAnnotationInterface() { @Test void getWithTypeHierarchyFromSubInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( - SubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( - Transactional.class); + SubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Transactional.class); assertThat(annotation.isPresent()).isTrue(); assertThat(annotation.getAggregateIndex()).isEqualTo(1); } @@ -479,8 +471,7 @@ void getWithTypeHierarchyFromSubInheritedAnnotationInterface() { @Test void getWithTypeHierarchyFromSubSubInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( - SubSubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( - Transactional.class); + SubSubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Transactional.class); assertThat(annotation.isPresent()).isTrue(); assertThat(annotation.getAggregateIndex()).isEqualTo(2); } @@ -488,8 +479,7 @@ void getWithTypeHierarchyFromSubSubInheritedAnnotationInterface() { @Test void getWithTypeHierarchyFromNonInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( - NonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( - Order.class); + NonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Order.class); assertThat(annotation.isPresent()).isTrue(); assertThat(annotation.getAggregateIndex()).isEqualTo(0); } @@ -497,8 +487,7 @@ void getWithTypeHierarchyFromNonInheritedAnnotationInterface() { @Test void getWithTypeHierarchyFromSubNonInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( - SubNonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( - Order.class); + SubNonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Order.class); assertThat(annotation.isPresent()).isTrue(); assertThat(annotation.getAggregateIndex()).isEqualTo(1); } @@ -524,8 +513,7 @@ void getWithTypeHierarchyInheritedFromInterfaceMethod() } @Test - void getWithTypeHierarchyInheritedFromAbstractMethod() - throws NoSuchMethodException { + void getWithTypeHierarchyInheritedFromAbstractMethod() throws NoSuchMethodException { Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handle"); MergedAnnotation annotation = MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(Transactional.class); @@ -534,8 +522,7 @@ void getWithTypeHierarchyInheritedFromAbstractMethod() } @Test - void getWithTypeHierarchyInheritedFromBridgedMethod() - throws NoSuchMethodException { + void getWithTypeHierarchyInheritedFromBridgedMethod() throws NoSuchMethodException { Method method = ConcreteClassWithInheritedAnnotation.class.getMethod( "handleParameterized", String.class); MergedAnnotation annotation = MergedAnnotations.from(method, @@ -552,12 +539,10 @@ void getWithTypeHierarchyFromBridgeMethod() { methods.add(method); } }); - Method bridgeMethod = methods.get(0).getReturnType().equals(Object.class) - ? methods.get(0) - : methods.get(1); - Method bridgedMethod = methods.get(0).getReturnType().equals(Object.class) - ? methods.get(1) - : methods.get(0); + Method bridgeMethod = methods.get(0).getReturnType().equals(Object.class) ? + methods.get(0) : methods.get(1); + Method bridgedMethod = methods.get(0).getReturnType().equals(Object.class) ? + methods.get(1) : methods.get(0); assertThat(bridgeMethod.isBridge()).isTrue(); assertThat(bridgedMethod.isBridge()).isFalse(); MergedAnnotation annotation = MergedAnnotations.from(bridgeMethod, @@ -612,30 +597,25 @@ void getWithTypeHierarchyFromClassWithAttributeAliasInComposedAnnotationAndNeste MergedAnnotation[] excludeFilters = annotation.getAnnotationArray( "excludeFilters", Filter.class); assertThat(Arrays.stream(excludeFilters).map( - filter -> filter.getString("pattern"))).containsExactly("*Test", - "*Tests"); + filter -> filter.getString("pattern"))).containsExactly("*Test", "*Tests"); } @Test void getWithTypeHierarchyFromClassWithBothAttributesOfAnAliasPairDeclared() { - testGetWithTypeHierarchy(ComponentScanWithBasePackagesAndValueAliasClass.class, - "com.example.app.test"); + testGetWithTypeHierarchy(ComponentScanWithBasePackagesAndValueAliasClass.class, "com.example.app.test"); } @Test void getWithTypeHierarchyWithSingleElementOverridingAnArrayViaConvention() { - testGetWithTypeHierarchy(ConventionBasedSinglePackageComponentScanClass.class, - "com.example.app.test"); + testGetWithTypeHierarchy(ConventionBasedSinglePackageComponentScanClass.class, "com.example.app.test"); } @Test void getWithTypeHierarchyWithSingleElementOverridingAnArrayViaAliasFor() { - testGetWithTypeHierarchy(AliasForBasedSinglePackageComponentScanClass.class, - "com.example.app.test"); + testGetWithTypeHierarchy(AliasForBasedSinglePackageComponentScanClass.class, "com.example.app.test"); } - private MergedAnnotation testGetWithTypeHierarchy(Class element, - String... expected) { + private MergedAnnotation testGetWithTypeHierarchy(Class element, String... expected) { MergedAnnotation annotation = MergedAnnotations.from(element, SearchStrategy.TYPE_HIERARCHY).get(ComponentScan.class); assertThat(annotation.getStringArray("value")).containsExactly(expected); @@ -698,9 +678,8 @@ void getDirectWithJavaxAnnotationType() throws Exception { @Test void streamInheritedFromClassWithInterface() throws Exception { Method method = TransactionalServiceImpl.class.getMethod("doIt"); - assertThat(MergedAnnotations.from(method, - SearchStrategy.INHERITED_ANNOTATIONS).stream( - Transactional.class)).isEmpty(); + assertThat(MergedAnnotations.from(method, SearchStrategy.INHERITED_ANNOTATIONS).stream( + Transactional.class)).isEmpty(); } @Test @@ -713,22 +692,21 @@ void streamTypeHierarchyFromClassWithInterface() throws Exception { @Test void streamTypeHierarchyAndEnclosingClassesFromNonAnnotatedInnerClassWithAnnotatedEnclosingClass() { Stream> classes = MergedAnnotations.from(AnnotatedClass.NonAnnotatedInnerClass.class, - SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES).stream().map(MergedAnnotation::getType); + SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES).stream().map(MergedAnnotation::getType); assertThat(classes).containsExactly(Component.class, Indexed.class); } @Test void streamTypeHierarchyAndEnclosingClassesFromNonAnnotatedStaticNestedClassWithAnnotatedEnclosingClass() { Stream> classes = MergedAnnotations.from(AnnotatedClass.NonAnnotatedStaticNestedClass.class, - SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES).stream().map(MergedAnnotation::getType); + SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES).stream().map(MergedAnnotation::getType); assertThat(classes).containsExactly(Component.class, Indexed.class); } @Test void getFromMethodWithMethodAnnotationOnLeaf() throws Exception { Method method = Leaf.class.getMethod("annotatedOnLeaf"); assertThat(method.getAnnotation(Order.class)).isNotNull(); - assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( - 0); + assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(0); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(0); } @@ -737,8 +715,7 @@ void getFromMethodWithMethodAnnotationOnLeaf() throws Exception { void getFromMethodWithAnnotationOnMethodInInterface() throws Exception { Method method = Leaf.class.getMethod("fromInterfaceImplementedByRoot"); assertThat(method.getAnnotation(Order.class)).isNull(); - assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( - -1); + assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(-1); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(0); } @@ -747,8 +724,7 @@ void getFromMethodWithAnnotationOnMethodInInterface() throws Exception { void getFromMethodWithMetaAnnotationOnLeaf() throws Exception { Method method = Leaf.class.getMethod("metaAnnotatedOnLeaf"); assertThat(method.getAnnotation(Order.class)).isNull(); - assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( - 1); + assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(1); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(1); } @@ -757,9 +733,7 @@ void getFromMethodWithMetaAnnotationOnLeaf() throws Exception { void getFromMethodWithMetaMetaAnnotationOnLeaf() throws Exception { Method method = Leaf.class.getMethod("metaMetaAnnotatedOnLeaf"); assertThat(method.getAnnotation(Component.class)).isNull(); - assertThat( - MergedAnnotations.from(method).get(Component.class).getDistance()).isEqualTo( - 2); + assertThat(MergedAnnotations.from(method).get(Component.class).getDistance()).isEqualTo(2); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Component.class).getDistance()).isEqualTo(2); } @@ -768,8 +742,7 @@ void getFromMethodWithMetaMetaAnnotationOnLeaf() throws Exception { void getWithAnnotationOnRoot() throws Exception { Method method = Leaf.class.getMethod("annotatedOnRoot"); assertThat(method.getAnnotation(Order.class)).isNotNull(); - assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( - 0); + assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(0); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(0); } @@ -778,8 +751,7 @@ void getWithAnnotationOnRoot() throws Exception { void getFromMethodWithMetaAnnotationOnRoot() throws Exception { Method method = Leaf.class.getMethod("metaAnnotatedOnRoot"); assertThat(method.getAnnotation(Order.class)).isNull(); - assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( - 1); + assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(1); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(1); } @@ -788,8 +760,7 @@ void getFromMethodWithMetaAnnotationOnRoot() throws Exception { void getFromMethodWithOnRootButOverridden() throws Exception { Method method = Leaf.class.getMethod("overrideWithoutNewAnnotation"); assertThat(method.getAnnotation(Order.class)).isNull(); - assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( - -1); + assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(-1); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(0); } @@ -798,8 +769,7 @@ void getFromMethodWithOnRootButOverridden() throws Exception { void getFromMethodWithNotAnnotated() throws Exception { Method method = Leaf.class.getMethod("notAnnotated"); assertThat(method.getAnnotation(Order.class)).isNull(); - assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( - -1); + assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(-1); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(-1); } @@ -837,12 +807,10 @@ void getFromMethodWithBridgeMethod() throws Exception { @Test void getFromMethodWithBridgedMethod() throws Exception { - Method method = TransactionalStringGeneric.class.getMethod("something", - String.class); + Method method = TransactionalStringGeneric.class.getMethod("something", String.class); assertThat(method.isBridge()).isFalse(); assertThat(method.getAnnotation(Order.class)).isNull(); - assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( - -1); + assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(-1); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(0); assertThat(method.getAnnotation(Transactional.class)).isNotNull(); @@ -861,16 +829,14 @@ void getFromMethodWithInterface() throws Exception { @Test // SPR-16060 void getFromMethodWithGenericInterface() throws Exception { - Method method = ImplementsInterfaceWithGenericAnnotatedMethod.class.getMethod( - "foo", String.class); + Method method = ImplementsInterfaceWithGenericAnnotatedMethod.class.getMethod("foo", String.class); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(0); } @Test // SPR-17146 void getFromMethodWithGenericSuperclass() throws Exception { - Method method = ExtendsBaseClassWithGenericAnnotatedMethod.class.getMethod("foo", - String.class); + Method method = ExtendsBaseClassWithGenericAnnotatedMethod.class.getMethod("foo", String.class); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(0); } @@ -884,10 +850,8 @@ void getFromMethodWithInterfaceOnSuper() throws Exception { } @Test - void getFromMethodWhenInterfaceWhenSuperDoesNotImplementMethod() - throws Exception { - Method method = SubOfAbstractImplementsInterfaceWithAnnotatedMethod.class.getMethod( - "foo"); + void getFromMethodWhenInterfaceWhenSuperDoesNotImplementMethod() throws Exception { + Method method = SubOfAbstractImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo"); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(0); } @@ -903,8 +867,7 @@ void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverAnnotatio @Test void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedAnnotations() { MergedAnnotation annotation = MergedAnnotations.from( - SubSubClassWithInheritedAnnotation.class, SearchStrategy.TYPE_HIERARCHY).get( - Transactional.class); + SubSubClassWithInheritedAnnotation.class, SearchStrategy.TYPE_HIERARCHY).get(Transactional.class); assertThat(annotation.getBoolean("readOnly")).isTrue(); } @@ -919,16 +882,14 @@ void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverInherited @Test void getDirectFromClassgetDirectFromClassMetaMetaAnnotatedClass() { MergedAnnotation annotation = MergedAnnotations.from( - MetaMetaAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get( - Component.class); + MetaMetaAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get(Component.class); assertThat(annotation.getString("value")).isEqualTo("meta2"); } @Test void getDirectFromClassWithMetaMetaMetaAnnotatedClass() { MergedAnnotation annotation = MergedAnnotations.from( - MetaMetaMetaAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get( - Component.class); + MetaMetaMetaAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get(Component.class); assertThat(annotation.getString("value")).isEqualTo("meta2"); } @@ -943,48 +904,42 @@ void getDirectFromClassWithAnnotatedClassWithMissingTargetMetaAnnotation() { @Test void getDirectFromClassWithMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() { MergedAnnotation annotation = MergedAnnotations.from( - MetaCycleAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get( - Component.class); + MetaCycleAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get(Component.class); assertThat(annotation.isPresent()).isFalse(); } @Test void getDirectFromClassWithInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( - InheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( - Transactional.class); + InheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Transactional.class); assertThat(annotation.getAggregateIndex()).isEqualTo(0); } @Test void getDirectFromClassWithSubInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( - SubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( - Transactional.class); + SubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Transactional.class); assertThat(annotation.getAggregateIndex()).isEqualTo(1); } @Test void getDirectFromClassWithSubSubInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( - SubSubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( - Transactional.class); + SubSubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Transactional.class); assertThat(annotation.getAggregateIndex()).isEqualTo(2); } @Test void getDirectFromClassWithNonInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( - NonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( - Order.class); + NonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Order.class); assertThat(annotation.getAggregateIndex()).isEqualTo(0); } @Test void getDirectFromClassWithSubNonInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( - SubNonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( - Order.class); + SubNonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Order.class); assertThat(annotation.getAggregateIndex()).isEqualTo(1); } @@ -1039,8 +994,7 @@ void getSuperClassForAllScenarios() { @Test void getSuperClassSourceForTypesWithSingleCandidateType() { // no class-level annotation - List> transactionalCandidateList = Collections.singletonList( - Transactional.class); + List> transactionalCandidateList = Collections.singletonList(Transactional.class); assertThat(getSuperClassSourceWithTypeIn(NonAnnotatedInterface.class, transactionalCandidateList)).isNull(); assertThat(getSuperClassSourceWithTypeIn(NonAnnotatedClass.class, @@ -1071,8 +1025,7 @@ void getSuperClassSourceForTypesWithSingleCandidateType() { @Test void getSuperClassSourceForTypesWithMultipleCandidateTypes() { - List> candidates = Arrays.asList(Transactional.class, - Order.class); + List> candidates = Arrays.asList(Transactional.class, Order.class); // no class-level annotation assertThat(getSuperClassSourceWithTypeIn(NonAnnotatedInterface.class, candidates)).isNull(); @@ -1107,8 +1060,7 @@ void getSuperClassSourceForTypesWithMultipleCandidateTypes() { candidates)).isEqualTo(TransactionalAndOrderedClass.class); } - private Object getSuperClassSourceWithTypeIn(Class clazz, - List> annotationTypes) { + private Object getSuperClassSourceWithTypeIn(Class clazz, List> annotationTypes) { return MergedAnnotations.from(clazz, SearchStrategy.SUPERCLASS).stream().filter( MergedAnnotationPredicates.typeIn(annotationTypes).and( MergedAnnotation::isDirectlyPresent)).map( @@ -1184,8 +1136,7 @@ void getAggregateIndexForAllScenarios() { SearchStrategy.INHERITED_ANNOTATIONS).get( Transactional.class).getAggregateIndex()).isEqualTo(0); // Since we're not traversing interface hierarchies the following, - // though perhaps - // counter intuitive, must be false: + // though perhaps counter intuitive, must be false: assertThat(MergedAnnotations.from(SubInheritedAnnotationInterface.class, SearchStrategy.INHERITED_ANNOTATIONS).get( Transactional.class).getAggregateIndex()).isEqualTo(-1); @@ -1212,15 +1163,13 @@ void getAggregateIndexForAllScenarios() { @Test void getDirectWithoutAttributeAliases() { - MergedAnnotation annotation = MergedAnnotations.from(WebController.class) - .get(Component.class); + MergedAnnotation annotation = MergedAnnotations.from(WebController.class).get(Component.class); assertThat(annotation.getString("value")).isEqualTo("webController"); } @Test void getDirectWithNestedAnnotations() { - MergedAnnotation annotation = MergedAnnotations.from(ComponentScanClass.class) - .get(ComponentScan.class); + MergedAnnotation annotation = MergedAnnotations.from(ComponentScanClass.class).get(ComponentScan.class); MergedAnnotation[] filters = annotation.getAnnotationArray("excludeFilters", Filter.class); assertThat(Arrays.stream(filters).map( filter -> filter.getString("pattern"))).containsExactly("*Foo", "*Bar"); @@ -1256,8 +1205,8 @@ void getDirectWithAttributeAliasesWithDifferentValues() throws Exception { @Test void getValueFromAnnotation() throws Exception { Method method = TransactionalStringGeneric.class.getMethod("something", Object.class); - MergedAnnotation annotation = MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY) - .get(Order.class); + MergedAnnotation annotation = + MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(Order.class); assertThat(annotation.getInt("value")).isEqualTo(1); } @@ -1275,8 +1224,8 @@ void getValueFromNonPublicAnnotation() throws Exception { @Test void getDefaultValueFromAnnotation() throws Exception { Method method = TransactionalStringGeneric.class.getMethod("something", Object.class); - MergedAnnotation annotation = MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY) - .get(Order.class); + MergedAnnotation annotation = + MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(Order.class); assertThat(annotation.getDefaultValue("value")).contains(Ordered.LOWEST_PRECEDENCE); } @@ -1294,8 +1243,7 @@ void getDefaultValueFromNonPublicAnnotation() { @Test void getDefaultValueFromAnnotationType() { MergedAnnotation annotation = MergedAnnotation.of(Order.class); - assertThat(annotation.getDefaultValue("value")).contains( - Ordered.LOWEST_PRECEDENCE); + assertThat(annotation.getDefaultValue("value")).contains(Ordered.LOWEST_PRECEDENCE); } @Test @@ -1327,8 +1275,7 @@ void getRepeatableDeclaredOnClass() { Class element = MyRepeatableClass.class; String[] expectedValuesJava = { "A", "B", "C" }; String[] expectedValuesSpring = { "A", "B", "C", "meta1" }; - testRepeatables(SearchStrategy.SUPERCLASS, element, expectedValuesJava, - expectedValuesSpring); + testRepeatables(SearchStrategy.SUPERCLASS, element, expectedValuesJava, expectedValuesSpring); } @Test @@ -1336,8 +1283,7 @@ void getRepeatableDeclaredOnSuperclass() { Class element = SubMyRepeatableClass.class; String[] expectedValuesJava = { "A", "B", "C" }; String[] expectedValuesSpring = { "A", "B", "C", "meta1" }; - testRepeatables(SearchStrategy.SUPERCLASS, element, expectedValuesJava, - expectedValuesSpring); + testRepeatables(SearchStrategy.SUPERCLASS, element, expectedValuesJava, expectedValuesSpring); } @Test @@ -1345,8 +1291,7 @@ void getRepeatableDeclaredOnClassAndSuperclass() { Class element = SubMyRepeatableWithAdditionalLocalDeclarationsClass.class; String[] expectedValuesJava = { "X", "Y", "Z" }; String[] expectedValuesSpring = { "X", "Y", "Z", "meta2" }; - testRepeatables(SearchStrategy.SUPERCLASS, element, expectedValuesJava, - expectedValuesSpring); + testRepeatables(SearchStrategy.SUPERCLASS, element, expectedValuesJava, expectedValuesSpring); } @Test @@ -1354,8 +1299,7 @@ void getRepeatableDeclaredOnMultipleSuperclasses() { Class element = SubSubMyRepeatableWithAdditionalLocalDeclarationsClass.class; String[] expectedValuesJava = { "X", "Y", "Z" }; String[] expectedValuesSpring = { "X", "Y", "Z", "meta2" }; - testRepeatables(SearchStrategy.SUPERCLASS, element, expectedValuesJava, - expectedValuesSpring); + testRepeatables(SearchStrategy.SUPERCLASS, element, expectedValuesJava, expectedValuesSpring); } @Test @@ -1363,8 +1307,7 @@ void getDirectRepeatablesDeclaredOnClass() { Class element = MyRepeatableClass.class; String[] expectedValuesJava = { "A", "B", "C" }; String[] expectedValuesSpring = { "A", "B", "C", "meta1" }; - testRepeatables(SearchStrategy.DIRECT, element, expectedValuesJava, - expectedValuesSpring); + testRepeatables(SearchStrategy.DIRECT, element, expectedValuesJava, expectedValuesSpring); } @Test @@ -1372,28 +1315,26 @@ void getDirectRepeatablesDeclaredOnSuperclass() { Class element = SubMyRepeatableClass.class; String[] expectedValuesJava = {}; String[] expectedValuesSpring = {}; - testRepeatables(SearchStrategy.DIRECT, element, expectedValuesJava, - expectedValuesSpring); + testRepeatables(SearchStrategy.DIRECT, element, expectedValuesJava, expectedValuesSpring); } private void testRepeatables(SearchStrategy searchStrategy, Class element, String[] expectedValuesJava, String[] expectedValuesSpring) { + testJavaRepeatables(searchStrategy, element, expectedValuesJava); testExplicitRepeatables(searchStrategy, element, expectedValuesSpring); testStandardRepeatables(searchStrategy, element, expectedValuesSpring); } - private void testJavaRepeatables(SearchStrategy searchStrategy, Class element, - String[] expected) { - MyRepeatable[] annotations = searchStrategy == SearchStrategy.DIRECT - ? element.getDeclaredAnnotationsByType(MyRepeatable.class) - : element.getAnnotationsByType(MyRepeatable.class); + private void testJavaRepeatables(SearchStrategy searchStrategy, Class element, String[] expected) { + MyRepeatable[] annotations = searchStrategy == SearchStrategy.DIRECT ? + element.getDeclaredAnnotationsByType(MyRepeatable.class) : + element.getAnnotationsByType(MyRepeatable.class); assertThat(Arrays.stream(annotations).map(MyRepeatable::value)).containsExactly( expected); } - private void testExplicitRepeatables(SearchStrategy searchStrategy, Class element, - String[] expected) { + private void testExplicitRepeatables(SearchStrategy searchStrategy, Class element, String[] expected) { MergedAnnotations annotations = MergedAnnotations.from(element, searchStrategy, RepeatableContainers.of(MyRepeatable.class, MyRepeatableContainer.class), AnnotationFilter.PLAIN); @@ -1404,8 +1345,7 @@ private void testExplicitRepeatables(SearchStrategy searchStrategy, Class ele "value"))).containsExactly(expected); } - private void testStandardRepeatables(SearchStrategy searchStrategy, Class element, - String[] expected) { + private void testStandardRepeatables(SearchStrategy searchStrategy, Class element, String[] expected) { MergedAnnotations annotations = MergedAnnotations.from(element, searchStrategy); assertThat(annotations.stream(MyRepeatable.class).filter( MergedAnnotationPredicates.firstRunOf( @@ -1429,10 +1369,8 @@ void synthesizeAlreadySynthesized() throws Exception { Method method = WebController.class.getMethod("handleMappedWithValueAttribute"); RequestMapping webMapping = method.getAnnotation(RequestMapping.class); assertThat(webMapping).isNotNull(); - RequestMapping synthesizedWebMapping = MergedAnnotation.from( - webMapping).synthesize(); - RequestMapping synthesizedAgainWebMapping = MergedAnnotation.from( - synthesizedWebMapping).synthesize(); + RequestMapping synthesizedWebMapping = MergedAnnotation.from(webMapping).synthesize(); + RequestMapping synthesizedAgainWebMapping = MergedAnnotation.from(synthesizedWebMapping).synthesize(); assertThat(synthesizedWebMapping).isInstanceOf(SynthesizedAnnotation.class); assertThat(synthesizedAgainWebMapping).isInstanceOf(SynthesizedAnnotation.class); assertThat(synthesizedWebMapping).isEqualTo(synthesizedAgainWebMapping); @@ -1443,8 +1381,9 @@ void synthesizeAlreadySynthesized() throws Exception { @Test void synthesizeWhenAliasForIsMissingAttributeDeclaration() throws Exception { - AliasForWithMissingAttributeDeclaration annotation = AliasForWithMissingAttributeDeclarationClass.class.getAnnotation( - AliasForWithMissingAttributeDeclaration.class); + AliasForWithMissingAttributeDeclaration annotation = + AliasForWithMissingAttributeDeclarationClass.class.getAnnotation( + AliasForWithMissingAttributeDeclaration.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> MergedAnnotation.from(annotation)) .withMessageStartingWith("@AliasFor declaration on attribute 'foo' in annotation") @@ -1453,8 +1392,7 @@ void synthesizeWhenAliasForIsMissingAttributeDeclaration() throws Exception { } @Test - void synthesizeWhenAliasForHasDuplicateAttributeDeclaration() - throws Exception { + void synthesizeWhenAliasForHasDuplicateAttributeDeclaration() throws Exception { AliasForWithDuplicateAttributeDeclaration annotation = AliasForWithDuplicateAttributeDeclarationClass.class.getAnnotation( AliasForWithDuplicateAttributeDeclaration.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1476,10 +1414,10 @@ void synthesizeWhenAttributeAliasForNonexistentAttribute() throws Exception { } @Test - void synthesizeWhenAttributeAliasWithMirroredAliasForWrongAttribute() - throws Exception { - AliasForWithMirroredAliasForWrongAttribute annotation = AliasForWithMirroredAliasForWrongAttributeClass.class.getAnnotation( - AliasForWithMirroredAliasForWrongAttribute.class); + void synthesizeWhenAttributeAliasWithMirroredAliasForWrongAttribute() throws Exception { + AliasForWithMirroredAliasForWrongAttribute annotation = + AliasForWithMirroredAliasForWrongAttributeClass.class.getAnnotation( + AliasForWithMirroredAliasForWrongAttribute.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> MergedAnnotation.from(annotation)) .withMessage("@AliasFor declaration on attribute 'bar' in annotation [" @@ -1488,8 +1426,7 @@ void synthesizeWhenAttributeAliasWithMirroredAliasForWrongAttribute() } @Test - void synthesizeWhenAttributeAliasForAttributeOfDifferentType() - throws Exception { + void synthesizeWhenAttributeAliasForAttributeOfDifferentType() throws Exception { AliasForAttributeOfDifferentType annotation = AliasForAttributeOfDifferentTypeClass.class.getAnnotation( AliasForAttributeOfDifferentType.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1502,8 +1439,7 @@ void synthesizeWhenAttributeAliasForAttributeOfDifferentType() } @Test - void synthesizeWhenAttributeAliasForWithMissingDefaultValues() - throws Exception { + void synthesizeWhenAttributeAliasForWithMissingDefaultValues() throws Exception { AliasForWithMissingDefaultValues annotation = AliasForWithMissingDefaultValuesClass.class.getAnnotation( AliasForWithMissingDefaultValues.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1516,10 +1452,10 @@ void synthesizeWhenAttributeAliasForWithMissingDefaultValues() } @Test - void synthesizeWhenAttributeAliasForAttributeWithDifferentDefaultValue() - throws Exception { - AliasForAttributeWithDifferentDefaultValue annotation = AliasForAttributeWithDifferentDefaultValueClass.class.getAnnotation( - AliasForAttributeWithDifferentDefaultValue.class); + void synthesizeWhenAttributeAliasForAttributeWithDifferentDefaultValue() throws Exception { + AliasForAttributeWithDifferentDefaultValue annotation = + AliasForAttributeWithDifferentDefaultValueClass.class.getAnnotation( + AliasForAttributeWithDifferentDefaultValue.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> MergedAnnotation.from(annotation)) .withMessageStartingWith("Misconfigured aliases") @@ -1530,10 +1466,10 @@ void synthesizeWhenAttributeAliasForAttributeWithDifferentDefaultValue() } @Test - void synthesizeWhenAttributeAliasForMetaAnnotationThatIsNotMetaPresent() - throws Exception { - AliasedComposedTestConfigurationNotMetaPresent annotation = AliasedComposedTestConfigurationNotMetaPresentClass.class.getAnnotation( - AliasedComposedTestConfigurationNotMetaPresent.class); + void synthesizeWhenAttributeAliasForMetaAnnotationThatIsNotMetaPresent() throws Exception { + AliasedComposedTestConfigurationNotMetaPresent annotation = + AliasedComposedTestConfigurationNotMetaPresentClass.class.getAnnotation( + AliasedComposedTestConfigurationNotMetaPresent.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> MergedAnnotation.from(annotation)) .withMessageStartingWith("@AliasFor declaration on attribute 'xmlConfigFile' in annotation") @@ -1545,14 +1481,10 @@ void synthesizeWhenAttributeAliasForMetaAnnotationThatIsNotMetaPresent() @Test void synthesizeWithImplicitAliases() throws Exception { - testSynthesisWithImplicitAliases(ValueImplicitAliasesTestConfigurationClass.class, - "value"); - testSynthesisWithImplicitAliases( - Location1ImplicitAliasesTestConfigurationClass.class, "location1"); - testSynthesisWithImplicitAliases(XmlImplicitAliasesTestConfigurationClass.class, - "xmlFile"); - testSynthesisWithImplicitAliases( - GroovyImplicitAliasesSimpleTestConfigurationClass.class, "groovyScript"); + testSynthesisWithImplicitAliases(ValueImplicitAliasesTestConfigurationClass.class, "value"); + testSynthesisWithImplicitAliases(Location1ImplicitAliasesTestConfigurationClass.class, "location1"); + testSynthesisWithImplicitAliases(XmlImplicitAliasesTestConfigurationClass.class, "xmlFile"); + testSynthesisWithImplicitAliases(GroovyImplicitAliasesSimpleTestConfigurationClass.class, "groovyScript"); } private void testSynthesisWithImplicitAliases(Class clazz, String expected) @@ -1588,8 +1520,8 @@ private void testSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted( ImplicitAliasesWithImpliedAliasNamesOmittedTestConfiguration config = clazz.getAnnotation( ImplicitAliasesWithImpliedAliasNamesOmittedTestConfiguration.class); assertThat(config).isNotNull(); - ImplicitAliasesWithImpliedAliasNamesOmittedTestConfiguration synthesized = MergedAnnotation.from( - config).synthesize(); + ImplicitAliasesWithImpliedAliasNamesOmittedTestConfiguration synthesized = + MergedAnnotation.from(config).synthesize(); assertThat(synthesized).isInstanceOf(SynthesizedAnnotation.class); assertThat(synthesized.value()).isEqualTo(expected); assertThat(synthesized.location()).isEqualTo(expected); @@ -1598,10 +1530,10 @@ private void testSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted( @Test void synthesizeWithImplicitAliasesForAliasPair() throws Exception { - ImplicitAliasesForAliasPairTestConfiguration config = ImplicitAliasesForAliasPairTestConfigurationClass.class.getAnnotation( - ImplicitAliasesForAliasPairTestConfiguration.class); - ImplicitAliasesForAliasPairTestConfiguration synthesized = MergedAnnotation.from( - config).synthesize(); + ImplicitAliasesForAliasPairTestConfiguration config = + ImplicitAliasesForAliasPairTestConfigurationClass.class.getAnnotation( + ImplicitAliasesForAliasPairTestConfiguration.class); + ImplicitAliasesForAliasPairTestConfiguration synthesized = MergedAnnotation.from(config).synthesize(); assertThat(synthesized).isInstanceOf(SynthesizedAnnotation.class); assertThat(synthesized.xmlFile()).isEqualTo("test.xml"); assertThat(synthesized.groovyScript()).isEqualTo("test.xml"); @@ -1609,10 +1541,10 @@ void synthesizeWithImplicitAliasesForAliasPair() throws Exception { @Test void synthesizeWithTransitiveImplicitAliases() throws Exception { - TransitiveImplicitAliasesTestConfiguration config = TransitiveImplicitAliasesTestConfigurationClass.class.getAnnotation( - TransitiveImplicitAliasesTestConfiguration.class); - TransitiveImplicitAliasesTestConfiguration synthesized = MergedAnnotation.from( - config).synthesize(); + TransitiveImplicitAliasesTestConfiguration config = + TransitiveImplicitAliasesTestConfigurationClass.class.getAnnotation( + TransitiveImplicitAliasesTestConfiguration.class); + TransitiveImplicitAliasesTestConfiguration synthesized = MergedAnnotation.from(config).synthesize(); assertThat(synthesized).isInstanceOf(SynthesizedAnnotation.class); assertThat(synthesized.xml()).isEqualTo("test.xml"); assertThat(synthesized.groovy()).isEqualTo("test.xml"); @@ -1620,8 +1552,9 @@ void synthesizeWithTransitiveImplicitAliases() throws Exception { @Test void synthesizeWithTransitiveImplicitAliasesForAliasPair() throws Exception { - TransitiveImplicitAliasesForAliasPairTestConfiguration config = TransitiveImplicitAliasesForAliasPairTestConfigurationClass.class.getAnnotation( - TransitiveImplicitAliasesForAliasPairTestConfiguration.class); + TransitiveImplicitAliasesForAliasPairTestConfiguration config = + TransitiveImplicitAliasesForAliasPairTestConfigurationClass.class.getAnnotation( + TransitiveImplicitAliasesForAliasPairTestConfiguration.class); TransitiveImplicitAliasesForAliasPairTestConfiguration synthesized = MergedAnnotation.from( config).synthesize(); assertThat(synthesized).isInstanceOf(SynthesizedAnnotation.class); @@ -1632,7 +1565,8 @@ void synthesizeWithTransitiveImplicitAliasesForAliasPair() throws Exception { @Test void synthesizeWithImplicitAliasesWithMissingDefaultValues() throws Exception { Class clazz = ImplicitAliasesWithMissingDefaultValuesTestConfigurationClass.class; - Class annotationType = ImplicitAliasesWithMissingDefaultValuesTestConfiguration.class; + Class annotationType = + ImplicitAliasesWithMissingDefaultValuesTestConfiguration.class; ImplicitAliasesWithMissingDefaultValuesTestConfiguration config = clazz.getAnnotation( annotationType); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1647,7 +1581,8 @@ void synthesizeWithImplicitAliasesWithMissingDefaultValues() throws Exception { void synthesizeWithImplicitAliasesWithDifferentDefaultValues() throws Exception { Class clazz = ImplicitAliasesWithDifferentDefaultValuesTestConfigurationClass.class; - Class annotationType = ImplicitAliasesWithDifferentDefaultValuesTestConfiguration.class; + Class annotationType = + ImplicitAliasesWithDifferentDefaultValuesTestConfiguration.class; ImplicitAliasesWithDifferentDefaultValuesTestConfiguration config = clazz.getAnnotation( annotationType); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1661,7 +1596,8 @@ void synthesizeWithImplicitAliasesWithDifferentDefaultValues() @Test void synthesizeWithImplicitAliasesWithDuplicateValues() throws Exception { Class clazz = ImplicitAliasesWithDuplicateValuesTestConfigurationClass.class; - Class annotationType = ImplicitAliasesWithDuplicateValuesTestConfiguration.class; + Class annotationType = + ImplicitAliasesWithDuplicateValuesTestConfiguration.class; ImplicitAliasesWithDuplicateValuesTestConfiguration config = clazz.getAnnotation( annotationType); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1678,8 +1614,7 @@ void synthesizeFromMapWithoutAttributeAliases() throws Exception { Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); Map map = Collections.singletonMap("value", "webController"); - MergedAnnotation annotation = MergedAnnotation.of(Component.class, - map); + MergedAnnotation annotation = MergedAnnotation.of(Component.class, map); Component synthesizedComponent = annotation.synthesize(); assertThat(synthesizedComponent).isInstanceOf(SynthesizedAnnotation.class); assertThat(synthesizedComponent.value()).isEqualTo("webController"); @@ -1824,7 +1759,7 @@ void synthesizeFromMapWithNullAttributeValue() throws Exception { private void testMissingTextAttribute(Map attributes) { assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(() -> - MergedAnnotation.of(AnnotationWithoutDefaults.class, attributes).synthesize()) + MergedAnnotation.of(AnnotationWithoutDefaults.class, attributes).synthesize().text()) .withMessage("No value found for attribute named 'text' in merged annotation " + AnnotationWithoutDefaults.class.getName()); } @@ -1832,46 +1767,34 @@ private void testMissingTextAttribute(Map attributes) { @Test void synthesizeFromMapWithAttributeOfIncorrectType() throws Exception { Map map = Collections.singletonMap("value", 42L); - MergedAnnotation annotation = MergedAnnotation.of(Component.class, - map); - // annotation.synthesize(); - assertThatIllegalStateException().isThrownBy(() -> - annotation.synthesize()) - .withMessage("Attribute 'value' in annotation " + - "org.springframework.stereotype.Component should be " + - "compatible with java.lang.String but a java.lang.Long value was returned"); + MergedAnnotation annotation = MergedAnnotation.of(Component.class, map); + assertThatIllegalStateException().isThrownBy(() -> annotation.synthesize().value()) + .withMessage("Attribute 'value' in annotation " + + "org.springframework.stereotype.Component should be " + + "compatible with java.lang.String but a java.lang.Long value was returned"); } @Test - void synthesizeFromAnnotationAttributesWithoutAttributeAliases() - throws Exception { + void synthesizeFromAnnotationAttributesWithoutAttributeAliases() throws Exception { Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); Map attributes = MergedAnnotation.from(component).asMap(); - Component synthesized = MergedAnnotation.of(Component.class, - attributes).synthesize(); + Component synthesized = MergedAnnotation.of(Component.class, attributes).synthesize(); assertThat(synthesized).isInstanceOf(SynthesizedAnnotation.class); assertThat(synthesized).isEqualTo(component); } @Test void toStringForSynthesizedAnnotations() throws Exception { - Method methodWithPath = WebController.class.getMethod( - "handleMappedWithPathAttribute"); - RequestMapping webMappingWithAliases = methodWithPath.getAnnotation( - RequestMapping.class); + Method methodWithPath = WebController.class.getMethod("handleMappedWithPathAttribute"); + RequestMapping webMappingWithAliases = methodWithPath.getAnnotation(RequestMapping.class); assertThat(webMappingWithAliases).isNotNull(); - Method methodWithPathAndValue = WebController.class.getMethod( - "handleMappedWithSamePathAndValueAttributes"); - RequestMapping webMappingWithPathAndValue = methodWithPathAndValue.getAnnotation( - RequestMapping.class); + Method methodWithPathAndValue = WebController.class.getMethod("handleMappedWithSamePathAndValueAttributes"); + RequestMapping webMappingWithPathAndValue = methodWithPathAndValue.getAnnotation(RequestMapping.class); assertThat(methodWithPathAndValue).isNotNull(); - RequestMapping synthesizedWebMapping1 = MergedAnnotation.from( - webMappingWithAliases).synthesize(); - RequestMapping synthesizedWebMapping2 = MergedAnnotation.from( - webMappingWithPathAndValue).synthesize(); - assertThat(webMappingWithAliases.toString()).isNotEqualTo( - synthesizedWebMapping1.toString()); + RequestMapping synthesizedWebMapping1 = MergedAnnotation.from(webMappingWithAliases).synthesize(); + RequestMapping synthesizedWebMapping2 = MergedAnnotation.from(webMappingWithPathAndValue).synthesize(); + assertThat(webMappingWithAliases.toString()).isNotEqualTo(synthesizedWebMapping1.toString()); assertToStringForWebMappingWithPathAndValue(synthesizedWebMapping1); assertToStringForWebMappingWithPathAndValue(synthesizedWebMapping2); } From fd6efb9a65082a1b16997f2a4f5ce7f2d6d7009c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 19 Nov 2019 15:53:20 +0100 Subject: [PATCH 0085/2315] Polishing --- .../context/annotation/AnnotatedBeanDefinitionReader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotatedBeanDefinitionReader.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotatedBeanDefinitionReader.java index eea4fa96315d..c7529380cc80 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotatedBeanDefinitionReader.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotatedBeanDefinitionReader.java @@ -238,10 +238,10 @@ public void registerBean(Class beanClass, @Nullable String name, @Nullabl * class-declared annotations. * @param beanClass the class of the bean * @param name an explicit name for the bean - * @param supplier a callback for creating an instance of the bean - * (may be {@code null}) * @param qualifiers specific qualifier annotations to consider, if any, * in addition to qualifiers at the bean class level + * @param supplier a callback for creating an instance of the bean + * (may be {@code null}) * @param customizers one or more callbacks for customizing the factory's * {@link BeanDefinition}, e.g. setting a lazy-init or primary flag * @since 5.0 From cd619a2f095de60638cf343220606559d8b9464a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 19 Nov 2019 16:07:12 +0100 Subject: [PATCH 0086/2315] Update @since tag --- .../RequestScopedControllerAdviceIntegrationTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java index 8cb79c50d26c..8669d4b64fc8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java @@ -38,7 +38,7 @@ * Integration tests for request-scoped {@link ControllerAdvice @ControllerAdvice} beans. * * @author Sam Brannen - * @since 5.2.2 + * @since 5.1.12 */ class RequestScopedControllerAdviceIntegrationTests { From f08cf0e86462a041a560332a45fde6ab473faccc Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 19 Nov 2019 16:03:43 +0000 Subject: [PATCH 0087/2315] Add RSocketFrameTypeMessageCondition constants See gh-23999 --- .../RSocketFrameTypeMessageCondition.java | 65 ++++++++++++------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java index 3288df528087..7ae1c1bf9ca1 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java @@ -45,6 +45,45 @@ public class RSocketFrameTypeMessageCondition extends AbstractMessageCondition frameTypeConditionCache; @@ -56,13 +95,6 @@ public class RSocketFrameTypeMessageCondition extends AbstractMessageCondition frameTypes; @@ -179,27 +211,16 @@ public static RSocketFrameTypeMessageCondition getCondition(int cardinalityIn, i case 0: case 1: switch (cardinalityOut) { - case 0: return FF_RR_CONDITION; - case 1: return RR_CONDITION; - case 2: return RS_CONDITION; + case 0: return REQUEST_FNF_OR_RESPONSE_CONDITION; + case 1: return REQUEST_RESPONSE_CONDITION; + case 2: return REQUEST_STREAM_CONDITION; default: throw new IllegalStateException("Invalid cardinality: " + cardinalityOut); } case 2: - return RC_CONDITION; + return REQUEST_CHANNEL_CONDITION; default: throw new IllegalStateException("Invalid cardinality: " + cardinalityIn); } } - - private static final RSocketFrameTypeMessageCondition FF_CONDITION = from(FrameType.REQUEST_FNF); - private static final RSocketFrameTypeMessageCondition RR_CONDITION = from(FrameType.REQUEST_RESPONSE); - private static final RSocketFrameTypeMessageCondition RS_CONDITION = from(FrameType.REQUEST_STREAM); - private static final RSocketFrameTypeMessageCondition RC_CONDITION = from(FrameType.REQUEST_CHANNEL); - private static final RSocketFrameTypeMessageCondition FF_RR_CONDITION = FF_CONDITION.combine(RR_CONDITION); - - private static RSocketFrameTypeMessageCondition from(FrameType... frameTypes) { - return new RSocketFrameTypeMessageCondition(frameTypes); - } - } From 2728f10a07f1da5daf61f7ba6d5b3060a7e9ef0b Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 19 Nov 2019 17:00:46 +0100 Subject: [PATCH 0088/2315] Test instance behavior for request-scoped @ControllerAdvice beans The test introduced in this commit is intended to serve as a regression test for the status quo. See gh-23985 --- .../spr/ControllerAdviceIntegrationTests.java | 55 +++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java index b62795d2b9f1..226d9a453b78 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java @@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.annotation.RequestScope; import org.springframework.web.servlet.config.annotation.EnableWebMvc; @@ -57,6 +58,7 @@ class ControllerAdviceIntegrationTests { @BeforeEach void setUpMockMvc(WebApplicationContext wac) { this.mockMvc = webAppContextSetup(wac).build(); + resetCounters(); } @Test @@ -64,14 +66,45 @@ void controllerAdviceIsAppliedOnlyOnce() throws Exception { assertThat(SingletonControllerAdvice.counter).hasValue(0); assertThat(RequestScopedControllerAdvice.counter).hasValue(0); - this.mockMvc.perform(get("/test"))// + this.mockMvc.perform(get("/test").param("requestParam", "foo"))// .andExpect(status().isOk())// - .andExpect(forwardedUrl("singleton:1;request-scoped:1")); + .andExpect(forwardedUrl("singleton:1;request-scoped:1;requestParam:foo")); assertThat(SingletonControllerAdvice.counter).hasValue(1); assertThat(RequestScopedControllerAdvice.counter).hasValue(1); } + @Test + void requestScopedControllerAdviceBeanIsNotCached() throws Exception { + assertThat(SingletonControllerAdvice.instanceCounter).hasValue(0); + assertThat(RequestScopedControllerAdvice.instanceCounter).hasValue(0); + + this.mockMvc.perform(get("/test").param("requestParam", "foo"))// + .andExpect(status().isOk())// + .andExpect(forwardedUrl("singleton:1;request-scoped:1;requestParam:foo")); + + // A singleton @ControllerAdvice bean should not be instantiated again. + assertThat(SingletonControllerAdvice.instanceCounter).hasValue(0); + // A request-scoped @ControllerAdvice bean should be instantiated once per request. + assertThat(RequestScopedControllerAdvice.instanceCounter).hasValue(1); + + this.mockMvc.perform(get("/test").param("requestParam", "bar"))// + .andExpect(status().isOk())// + .andExpect(forwardedUrl("singleton:2;request-scoped:2;requestParam:bar")); + + // A singleton @ControllerAdvice bean should not be instantiated again. + assertThat(SingletonControllerAdvice.instanceCounter).hasValue(0); + // A request-scoped @ControllerAdvice bean should be instantiated once per request. + assertThat(RequestScopedControllerAdvice.instanceCounter).hasValue(2); + } + + private void resetCounters() { + SingletonControllerAdvice.counter.set(0); + SingletonControllerAdvice.instanceCounter.set(0); + RequestScopedControllerAdvice.counter.set(0); + RequestScopedControllerAdvice.instanceCounter.set(0); + } + @Configuration @EnableWebMvc static class Config { @@ -98,6 +131,12 @@ static class SingletonControllerAdvice { static final AtomicInteger counter = new AtomicInteger(); + static final AtomicInteger instanceCounter = new AtomicInteger(); + + { + instanceCounter.incrementAndGet(); + } + @ModelAttribute void initModel(Model model) { model.addAttribute("singleton", counter.incrementAndGet()); @@ -109,8 +148,15 @@ static class RequestScopedControllerAdvice { static final AtomicInteger counter = new AtomicInteger(); + static final AtomicInteger instanceCounter = new AtomicInteger(); + + { + instanceCounter.incrementAndGet(); + } + @ModelAttribute - void initModel(Model model) { + void initModel(@RequestParam String requestParam, Model model) { + model.addAttribute("requestParam", requestParam); model.addAttribute("request-scoped", counter.incrementAndGet()); } } @@ -121,7 +167,8 @@ static class TestController { @GetMapping("/test") String get(Model model) { return "singleton:" + model.getAttribute("singleton") + ";request-scoped:" - + model.getAttribute("request-scoped"); + + model.getAttribute("request-scoped") + ";requestParam:" + + model.getAttribute("requestParam"); } } From f4e0288357090449ccd435074b98ebca5adc2640 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 19 Nov 2019 16:18:08 +0000 Subject: [PATCH 0089/2315] Remove mentions of Tomcat async request timeout value Close gh-24030 --- .../java/org/springframework/mock/web/MockAsyncContext.java | 4 ++-- .../org/springframework/mock/web/test/MockAsyncContext.java | 4 ++-- .../web/servlet/config/annotation/AsyncSupportConfigurer.java | 4 ++-- .../mvc/method/annotation/RequestMappingHandlerAdapter.java | 2 +- .../org/springframework/web/servlet/config/spring-mvc.xsd | 2 +- src/docs/asciidoc/web/webmvc.adoc | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockAsyncContext.java b/spring-test/src/main/java/org/springframework/mock/web/MockAsyncContext.java index 620439d1ae25..f3c6fcc1ad65 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockAsyncContext.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockAsyncContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -53,7 +53,7 @@ public class MockAsyncContext implements AsyncContext { @Nullable private String dispatchedPath; - private long timeout = 10 * 1000L; // 10 seconds is Tomcat's default + private long timeout = 10 * 1000L; private final List dispatchHandlers = new ArrayList<>(); diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockAsyncContext.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockAsyncContext.java index 4c60f1e40df0..577847644760 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockAsyncContext.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockAsyncContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -53,7 +53,7 @@ public class MockAsyncContext implements AsyncContext { @Nullable private String dispatchedPath; - private long timeout = 10 * 1000L; // 10 seconds is Tomcat's default + private long timeout = 10 * 1000L; private final List dispatchHandlers = new ArrayList<>(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java index 841c38e249b1..a43bcb31a54b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -71,7 +71,7 @@ public AsyncSupportConfigurer setTaskExecutor(AsyncTaskExecutor taskExecutor) { * processing thread has exited and ends when the request is dispatched again * for further processing of the concurrently produced result. *

If this value is not set, the default timeout of the underlying - * implementation is used, e.g. 10 seconds on Tomcat with Servlet 3. + * implementation is used. * @param timeout the timeout value in milliseconds */ public AsyncSupportConfigurer setDefaultTimeout(long timeout) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java index 53eda754d032..7b0f5038ee02 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java @@ -414,7 +414,7 @@ public void setTaskExecutor(AsyncTaskExecutor taskExecutor) { * processing thread has exited and ends when the request is dispatched again * for further processing of the concurrently produced result. *

If this value is not set, the default timeout of the underlying - * implementation is used, e.g. 10 seconds on Tomcat with Servlet 3. + * implementation is used. * @param timeout the timeout value in milliseconds */ public void setAsyncRequestTimeout(long timeout) { diff --git a/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc.xsd b/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc.xsd index 7c6fd031df8c..398247f4f91b 100644 --- a/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc.xsd +++ b/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc.xsd @@ -253,7 +253,7 @@ Specify the amount of time, in milliseconds, before asynchronous request handling times out. In Servlet 3, the timeout begins after the main request processing thread has exited and ends when the request is dispatched again for further processing of the concurrently produced result. If this value is not set, - the default timeout of the underlying implementation is used, e.g. 10 seconds on Tomcat with Servlet 3. + the default timeout of the underlying implementation is used. ]]> diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index da4f667bf301..71909cf617d5 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -4637,7 +4637,7 @@ The MVC configuration exposes the following options related to asynchronous requ You can configure the following: * Default timeout value for async requests, which if not set, depends -on the underlying Servlet container (for example, 10 seconds on Tomcat). +on the underlying Servlet container. * `AsyncTaskExecutor` to use for blocking writes when streaming with <> and for executing `Callable` instances returned from controller methods. We highly recommended configuring this property if you From 6fdeb10ee004abbaf3f29162db00ff01a2025aa2 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 20 Nov 2019 10:56:44 +0100 Subject: [PATCH 0090/2315] Start building against Reactor Dysprosium-SR2 snapshots See gh-24037 --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ee7a791d034d..c28aedca588e 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ configure(allprojects) { project -> imports { mavenBom "com.fasterxml.jackson:jackson-bom:2.10.1" mavenBom "io.netty:netty-bom:4.1.43.Final" - mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR1" + mavenBom "io.projectreactor:reactor-bom:Dysprosium-BUILD-SNAPSHOT" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" mavenBom "org.eclipse.jetty:jetty-bom:9.4.21.v20190926" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.60" @@ -296,6 +296,7 @@ configure(allprojects) { project -> repositories { mavenCentral() maven { url "https://repo.spring.io/libs-spring-framework-build" } + maven { url "https://repo.spring.io/snapshot" } } } configurations.all { From e8b81ffc16590d24d9bcd4dd456faa0787871d92 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Wed, 20 Nov 2019 11:55:25 +0100 Subject: [PATCH 0091/2315] Improve documentation of WebClient.Builder::filter Closes gh-23342 --- .../springframework/web/reactive/function/client/WebClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java index 5b6a6359dcd0..57fb6397242a 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java @@ -264,7 +264,7 @@ interface Builder { Builder defaultRequest(Consumer> defaultRequest); /** - * Add the given filter to the filter chain. + * Add the given filter to the end of the filter chain. * @param filter the filter to be added to the chain */ Builder filter(ExchangeFilterFunction filter); From a5f2d8c2221725eb0125e00dda48488dc3ac9489 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 20 Nov 2019 17:37:40 +0100 Subject: [PATCH 0092/2315] Mark SqlRowSet accessor methods as nullable (for alignment with JDBC) Closes gh-24042 --- .../rowset/ResultSetWrappingSqlRowSet.java | 27 +++++++++++++++- .../jdbc/support/rowset/SqlRowSet.java | 31 +++++++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java index 8062eb0eaf85..220c8d174633 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -29,6 +29,7 @@ import java.util.Map; import org.springframework.jdbc.InvalidResultSetAccessException; +import org.springframework.lang.Nullable; /** * The default implementation of Spring's {@link SqlRowSet} interface, wrapping a @@ -160,6 +161,7 @@ public int findColumn(String columnLabel) throws InvalidResultSetAccessException * @see java.sql.ResultSet#getBigDecimal(int) */ @Override + @Nullable public BigDecimal getBigDecimal(int columnIndex) throws InvalidResultSetAccessException { try { return this.resultSet.getBigDecimal(columnIndex); @@ -173,6 +175,7 @@ public BigDecimal getBigDecimal(int columnIndex) throws InvalidResultSetAccessEx * @see java.sql.ResultSet#getBigDecimal(String) */ @Override + @Nullable public BigDecimal getBigDecimal(String columnLabel) throws InvalidResultSetAccessException { return getBigDecimal(findColumn(columnLabel)); } @@ -223,6 +226,7 @@ public byte getByte(String columnLabel) throws InvalidResultSetAccessException { * @see java.sql.ResultSet#getDate(int) */ @Override + @Nullable public Date getDate(int columnIndex) throws InvalidResultSetAccessException { try { return this.resultSet.getDate(columnIndex); @@ -236,6 +240,7 @@ public Date getDate(int columnIndex) throws InvalidResultSetAccessException { * @see java.sql.ResultSet#getDate(String) */ @Override + @Nullable public Date getDate(String columnLabel) throws InvalidResultSetAccessException { return getDate(findColumn(columnLabel)); } @@ -244,6 +249,7 @@ public Date getDate(String columnLabel) throws InvalidResultSetAccessException { * @see java.sql.ResultSet#getDate(int, Calendar) */ @Override + @Nullable public Date getDate(int columnIndex, Calendar cal) throws InvalidResultSetAccessException { try { return this.resultSet.getDate(columnIndex, cal); @@ -257,6 +263,7 @@ public Date getDate(int columnIndex, Calendar cal) throws InvalidResultSetAccess * @see java.sql.ResultSet#getDate(String, Calendar) */ @Override + @Nullable public Date getDate(String columnLabel, Calendar cal) throws InvalidResultSetAccessException { return getDate(findColumn(columnLabel), cal); } @@ -349,6 +356,7 @@ public long getLong(String columnLabel) throws InvalidResultSetAccessException { * @see java.sql.ResultSet#getNString(int) */ @Override + @Nullable public String getNString(int columnIndex) throws InvalidResultSetAccessException { try { return this.resultSet.getNString(columnIndex); @@ -362,6 +370,7 @@ public String getNString(int columnIndex) throws InvalidResultSetAccessException * @see java.sql.ResultSet#getNString(String) */ @Override + @Nullable public String getNString(String columnLabel) throws InvalidResultSetAccessException { return getNString(findColumn(columnLabel)); } @@ -370,6 +379,7 @@ public String getNString(String columnLabel) throws InvalidResultSetAccessExcept * @see java.sql.ResultSet#getObject(int) */ @Override + @Nullable public Object getObject(int columnIndex) throws InvalidResultSetAccessException { try { return this.resultSet.getObject(columnIndex); @@ -383,6 +393,7 @@ public Object getObject(int columnIndex) throws InvalidResultSetAccessException * @see java.sql.ResultSet#getObject(String) */ @Override + @Nullable public Object getObject(String columnLabel) throws InvalidResultSetAccessException { return getObject(findColumn(columnLabel)); } @@ -391,6 +402,7 @@ public Object getObject(String columnLabel) throws InvalidResultSetAccessExcepti * @see java.sql.ResultSet#getObject(int, Map) */ @Override + @Nullable public Object getObject(int columnIndex, Map> map) throws InvalidResultSetAccessException { try { return this.resultSet.getObject(columnIndex, map); @@ -404,6 +416,7 @@ public Object getObject(int columnIndex, Map> map) throws Inval * @see java.sql.ResultSet#getObject(String, Map) */ @Override + @Nullable public Object getObject(String columnLabel, Map> map) throws InvalidResultSetAccessException { return getObject(findColumn(columnLabel), map); } @@ -412,6 +425,7 @@ public Object getObject(String columnLabel, Map> map) throws In * @see java.sql.ResultSet#getObject(int, Class) */ @Override + @Nullable public T getObject(int columnIndex, Class type) throws InvalidResultSetAccessException { try { return this.resultSet.getObject(columnIndex, type); @@ -425,6 +439,7 @@ public T getObject(int columnIndex, Class type) throws InvalidResultSetAc * @see java.sql.ResultSet#getObject(String, Class) */ @Override + @Nullable public T getObject(String columnLabel, Class type) throws InvalidResultSetAccessException { return getObject(findColumn(columnLabel), type); } @@ -454,6 +469,7 @@ public short getShort(String columnLabel) throws InvalidResultSetAccessException * @see java.sql.ResultSet#getString(int) */ @Override + @Nullable public String getString(int columnIndex) throws InvalidResultSetAccessException { try { return this.resultSet.getString(columnIndex); @@ -467,6 +483,7 @@ public String getString(int columnIndex) throws InvalidResultSetAccessException * @see java.sql.ResultSet#getString(String) */ @Override + @Nullable public String getString(String columnLabel) throws InvalidResultSetAccessException { return getString(findColumn(columnLabel)); } @@ -475,6 +492,7 @@ public String getString(String columnLabel) throws InvalidResultSetAccessExcepti * @see java.sql.ResultSet#getTime(int) */ @Override + @Nullable public Time getTime(int columnIndex) throws InvalidResultSetAccessException { try { return this.resultSet.getTime(columnIndex); @@ -488,6 +506,7 @@ public Time getTime(int columnIndex) throws InvalidResultSetAccessException { * @see java.sql.ResultSet#getTime(String) */ @Override + @Nullable public Time getTime(String columnLabel) throws InvalidResultSetAccessException { return getTime(findColumn(columnLabel)); } @@ -496,6 +515,7 @@ public Time getTime(String columnLabel) throws InvalidResultSetAccessException { * @see java.sql.ResultSet#getTime(int, Calendar) */ @Override + @Nullable public Time getTime(int columnIndex, Calendar cal) throws InvalidResultSetAccessException { try { return this.resultSet.getTime(columnIndex, cal); @@ -509,6 +529,7 @@ public Time getTime(int columnIndex, Calendar cal) throws InvalidResultSetAccess * @see java.sql.ResultSet#getTime(String, Calendar) */ @Override + @Nullable public Time getTime(String columnLabel, Calendar cal) throws InvalidResultSetAccessException { return getTime(findColumn(columnLabel), cal); } @@ -517,6 +538,7 @@ public Time getTime(String columnLabel, Calendar cal) throws InvalidResultSetAcc * @see java.sql.ResultSet#getTimestamp(int) */ @Override + @Nullable public Timestamp getTimestamp(int columnIndex) throws InvalidResultSetAccessException { try { return this.resultSet.getTimestamp(columnIndex); @@ -530,6 +552,7 @@ public Timestamp getTimestamp(int columnIndex) throws InvalidResultSetAccessExce * @see java.sql.ResultSet#getTimestamp(String) */ @Override + @Nullable public Timestamp getTimestamp(String columnLabel) throws InvalidResultSetAccessException { return getTimestamp(findColumn(columnLabel)); } @@ -538,6 +561,7 @@ public Timestamp getTimestamp(String columnLabel) throws InvalidResultSetAccessE * @see java.sql.ResultSet#getTimestamp(int, Calendar) */ @Override + @Nullable public Timestamp getTimestamp(int columnIndex, Calendar cal) throws InvalidResultSetAccessException { try { return this.resultSet.getTimestamp(columnIndex, cal); @@ -551,6 +575,7 @@ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws InvalidResul * @see java.sql.ResultSet#getTimestamp(String, Calendar) */ @Override + @Nullable public Timestamp getTimestamp(String columnLabel, Calendar cal) throws InvalidResultSetAccessException { return getTimestamp(findColumn(columnLabel), cal); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/SqlRowSet.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/SqlRowSet.java index b504af7da505..cb49fd0597af 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/SqlRowSet.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/SqlRowSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -25,6 +25,7 @@ import java.util.Map; import org.springframework.jdbc.InvalidResultSetAccessException; +import org.springframework.lang.Nullable; /** * Mirror interface for {@link javax.sql.RowSet}, representing a disconnected variant of @@ -74,6 +75,7 @@ public interface SqlRowSet extends Serializable { * @return an BigDecimal object representing the column value * @see java.sql.ResultSet#getBigDecimal(int) */ + @Nullable BigDecimal getBigDecimal(int columnIndex) throws InvalidResultSetAccessException; /** @@ -82,6 +84,7 @@ public interface SqlRowSet extends Serializable { * @return an BigDecimal object representing the column value * @see java.sql.ResultSet#getBigDecimal(String) */ + @Nullable BigDecimal getBigDecimal(String columnLabel) throws InvalidResultSetAccessException; /** @@ -122,6 +125,7 @@ public interface SqlRowSet extends Serializable { * @return a Date object representing the column value * @see java.sql.ResultSet#getDate(int) */ + @Nullable Date getDate(int columnIndex) throws InvalidResultSetAccessException; /** @@ -130,6 +134,7 @@ public interface SqlRowSet extends Serializable { * @return a Date object representing the column value * @see java.sql.ResultSet#getDate(String) */ + @Nullable Date getDate(String columnLabel) throws InvalidResultSetAccessException; /** @@ -139,6 +144,7 @@ public interface SqlRowSet extends Serializable { * @return a Date object representing the column value * @see java.sql.ResultSet#getDate(int, Calendar) */ + @Nullable Date getDate(int columnIndex, Calendar cal) throws InvalidResultSetAccessException; /** @@ -148,6 +154,7 @@ public interface SqlRowSet extends Serializable { * @return a Date object representing the column value * @see java.sql.ResultSet#getDate(String, Calendar) */ + @Nullable Date getDate(String columnLabel, Calendar cal) throws InvalidResultSetAccessException; /** @@ -222,6 +229,7 @@ public interface SqlRowSet extends Serializable { * @since 4.1.3 * @see java.sql.ResultSet#getNString(int) */ + @Nullable String getNString(int columnIndex) throws InvalidResultSetAccessException; /** @@ -232,6 +240,7 @@ public interface SqlRowSet extends Serializable { * @since 4.1.3 * @see java.sql.ResultSet#getNString(String) */ + @Nullable String getNString(String columnLabel) throws InvalidResultSetAccessException; /** @@ -240,6 +249,7 @@ public interface SqlRowSet extends Serializable { * @return a Object representing the column value * @see java.sql.ResultSet#getObject(int) */ + @Nullable Object getObject(int columnIndex) throws InvalidResultSetAccessException; /** @@ -248,6 +258,7 @@ public interface SqlRowSet extends Serializable { * @return a Object representing the column value * @see java.sql.ResultSet#getObject(String) */ + @Nullable Object getObject(String columnLabel) throws InvalidResultSetAccessException; /** @@ -257,6 +268,7 @@ public interface SqlRowSet extends Serializable { * @return a Object representing the column value * @see java.sql.ResultSet#getObject(int, Map) */ + @Nullable Object getObject(int columnIndex, Map> map) throws InvalidResultSetAccessException; /** @@ -266,6 +278,7 @@ public interface SqlRowSet extends Serializable { * @return a Object representing the column value * @see java.sql.ResultSet#getObject(String, Map) */ + @Nullable Object getObject(String columnLabel, Map> map) throws InvalidResultSetAccessException; /** @@ -273,9 +286,10 @@ public interface SqlRowSet extends Serializable { * @param columnIndex the column index * @param type the Java type to convert the designated column to * @return a Object representing the column value - * @see java.sql.ResultSet#getObject(int) * @since 4.1.3 + * @see java.sql.ResultSet#getObject(int, Class) */ + @Nullable T getObject(int columnIndex, Class type) throws InvalidResultSetAccessException; /** @@ -283,9 +297,10 @@ public interface SqlRowSet extends Serializable { * @param columnLabel the column label * @param type the Java type to convert the designated column to * @return a Object representing the column value - * @see java.sql.ResultSet#getObject(int) * @since 4.1.3 + * @see java.sql.ResultSet#getObject(String, Class) */ + @Nullable T getObject(String columnLabel, Class type) throws InvalidResultSetAccessException; /** @@ -310,6 +325,7 @@ public interface SqlRowSet extends Serializable { * @return a String representing the column value * @see java.sql.ResultSet#getString(int) */ + @Nullable String getString(int columnIndex) throws InvalidResultSetAccessException; /** @@ -318,6 +334,7 @@ public interface SqlRowSet extends Serializable { * @return a String representing the column value * @see java.sql.ResultSet#getString(String) */ + @Nullable String getString(String columnLabel) throws InvalidResultSetAccessException; /** @@ -326,6 +343,7 @@ public interface SqlRowSet extends Serializable { * @return a Time object representing the column value * @see java.sql.ResultSet#getTime(int) */ + @Nullable Time getTime(int columnIndex) throws InvalidResultSetAccessException; /** @@ -334,6 +352,7 @@ public interface SqlRowSet extends Serializable { * @return a Time object representing the column value * @see java.sql.ResultSet#getTime(String) */ + @Nullable Time getTime(String columnLabel) throws InvalidResultSetAccessException; /** @@ -343,6 +362,7 @@ public interface SqlRowSet extends Serializable { * @return a Time object representing the column value * @see java.sql.ResultSet#getTime(int, Calendar) */ + @Nullable Time getTime(int columnIndex, Calendar cal) throws InvalidResultSetAccessException; /** @@ -352,6 +372,7 @@ public interface SqlRowSet extends Serializable { * @return a Time object representing the column value * @see java.sql.ResultSet#getTime(String, Calendar) */ + @Nullable Time getTime(String columnLabel, Calendar cal) throws InvalidResultSetAccessException; /** @@ -360,6 +381,7 @@ public interface SqlRowSet extends Serializable { * @return a Timestamp object representing the column value * @see java.sql.ResultSet#getTimestamp(int) */ + @Nullable Timestamp getTimestamp(int columnIndex) throws InvalidResultSetAccessException; /** @@ -368,6 +390,7 @@ public interface SqlRowSet extends Serializable { * @return a Timestamp object representing the column value * @see java.sql.ResultSet#getTimestamp(String) */ + @Nullable Timestamp getTimestamp(String columnLabel) throws InvalidResultSetAccessException; /** @@ -377,6 +400,7 @@ public interface SqlRowSet extends Serializable { * @return a Timestamp object representing the column value * @see java.sql.ResultSet#getTimestamp(int, Calendar) */ + @Nullable Timestamp getTimestamp(int columnIndex, Calendar cal) throws InvalidResultSetAccessException; /** @@ -386,6 +410,7 @@ public interface SqlRowSet extends Serializable { * @return a Timestamp object representing the column value * @see java.sql.ResultSet#getTimestamp(String, Calendar) */ + @Nullable Timestamp getTimestamp(String columnLabel, Calendar cal) throws InvalidResultSetAccessException; From 82f4e933e0399b2c6a24a4fc0cd7c1c277cfa4f1 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 20 Nov 2019 17:37:58 +0100 Subject: [PATCH 0093/2315] Upgrade to Hibernate ORM 5.4.9, Hibernate Validator 6.1, Undertow 2.0.28 --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index c28aedca588e..eee85543e368 100644 --- a/build.gradle +++ b/build.gradle @@ -132,8 +132,8 @@ configure(allprojects) { project -> dependency "net.sf.ehcache:ehcache:2.10.6" dependency "org.ehcache:jcache:1.0.1" dependency "org.ehcache:ehcache:3.4.0" - dependency "org.hibernate:hibernate-core:5.4.8.Final" - dependency "org.hibernate:hibernate-validator:6.0.17.Final" + dependency "org.hibernate:hibernate-core:5.4.9.Final" + dependency "org.hibernate:hibernate-validator:6.1.0.Final" dependency "org.webjars:webjars-locator-core:0.43" dependency "org.webjars:underscorejs:1.8.3" @@ -148,7 +148,7 @@ configure(allprojects) { project -> entry 'tomcat-embed-core' entry 'tomcat-embed-websocket' } - dependencySet(group: 'io.undertow', version: '2.0.27.Final') { + dependencySet(group: 'io.undertow', version: '2.0.28.Final') { entry 'undertow-core' entry('undertow-websockets-jsr') { exclude group: "org.jboss.spec.javax.websocket", name: "jboss-websocket-api_1.1_spec" From 996f7290cf97df2938287630ca956fe5ac35fdc8 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 20 Nov 2019 19:40:55 +0000 Subject: [PATCH 0094/2315] Allow async metadata in RSocketRequester This commit allows single-value async producers for the values of metadata entries in both the SETUP and for requests. The same is also enabled for data in the SETUP frame. Close gh-23640 --- .../rsocket/DefaultRSocketRequester.java | 63 +++++----- .../DefaultRSocketRequesterBuilder.java | 96 ++++++++------- .../messaging/rsocket/MetadataEncoder.java | 114 ++++++++++++++---- .../messaging/rsocket/RSocketRequester.java | 13 +- .../DefaultMetadataExtractorTests.java | 12 +- .../DefaultRSocketRequesterBuilderTests.java | 35 ++++++ .../rsocket/DefaultRSocketRequesterTests.java | 56 ++++++++- .../rsocket/MetadataEncoderTests.java | 42 +++++-- 8 files changed, 310 insertions(+), 121 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java index e579c8e11c95..249ce6106e7b 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java @@ -114,22 +114,20 @@ private DataBufferFactory bufferFactory() { private class DefaultRequestSpec implements RequestSpec { - private final MetadataEncoder metadataEncoder; + private final MetadataEncoder metadataEncoder = new MetadataEncoder(metadataMimeType(), strategies); @Nullable - private Mono payloadMono = emptyPayload(); + private Mono payloadMono; @Nullable - private Flux payloadFlux = null; + private Flux payloadFlux; public DefaultRequestSpec(String route, Object... vars) { - this.metadataEncoder = new MetadataEncoder(metadataMimeType(), strategies); this.metadataEncoder.route(route, vars); } public DefaultRequestSpec(Object metadata, @Nullable MimeType mimeType) { - this.metadataEncoder = new MetadataEncoder(metadataMimeType(), strategies); this.metadataEncoder.metadata(metadata, mimeType); } @@ -188,17 +186,14 @@ else if (adapter != null) { publisher = adapter.toPublisher(input); } else { - this.payloadMono = Mono - .fromCallable(() -> encodeData(input, ResolvableType.forInstance(input), null)) - .map(this::firstPayload) - .doOnDiscard(Payload.class, Payload::release) - .switchIfEmpty(emptyPayload()); + ResolvableType type = ResolvableType.forInstance(input); + this.payloadMono = firstPayload(Mono.fromCallable(() -> encodeData(input, type, null))); this.payloadFlux = null; return; } if (isVoid(elementType) || (adapter != null && adapter.isNoValue())) { - this.payloadMono = Mono.when(publisher).then(emptyPayload()); + this.payloadMono = firstPayload(Mono.when(publisher).then(Mono.just(emptyDataBuffer))); this.payloadFlux = null; return; } @@ -207,10 +202,10 @@ else if (adapter != null) { strategies.encoder(elementType, dataMimeType) : null; if (adapter != null && !adapter.isMultiValue()) { - this.payloadMono = Mono.from(publisher) + Mono data = Mono.from(publisher) .map(value -> encodeData(value, elementType, encoder)) - .map(this::firstPayload) - .switchIfEmpty(emptyPayload()); + .defaultIfEmpty(emptyDataBuffer); + this.payloadMono = firstPayload(data); this.payloadFlux = null; return; } @@ -218,18 +213,18 @@ else if (adapter != null) { this.payloadMono = null; this.payloadFlux = Flux.from(publisher) .map(value -> encodeData(value, elementType, encoder)) + .defaultIfEmpty(emptyDataBuffer) .switchOnFirst((signal, inner) -> { DataBuffer data = signal.get(); if (data != null) { - return Mono.fromCallable(() -> firstPayload(data)) + return firstPayload(Mono.fromCallable(() -> data)) .concatWith(inner.skip(1).map(PayloadUtils::createPayload)); } else { return inner.map(PayloadUtils::createPayload); } }) - .doOnDiscard(Payload.class, Payload::release) - .switchIfEmpty(emptyPayload()); + .doOnDiscard(Payload.class, Payload::release); } @SuppressWarnings("unchecked") @@ -242,26 +237,25 @@ private DataBuffer encodeData(T value, ResolvableType elementType, @Nullable value, bufferFactory(), elementType, dataMimeType, EMPTY_HINTS); } - private Payload firstPayload(DataBuffer data) { - DataBuffer metadata; - try { - metadata = this.metadataEncoder.encode(); - } - catch (Throwable ex) { - DataBufferUtils.release(data); - throw ex; - } - return PayloadUtils.createPayload(data, metadata); - } - - private Mono emptyPayload() { - return Mono.fromCallable(() -> firstPayload(emptyDataBuffer)); + /** + * Create the 1st request payload with encoded data and metadata. + * @param encodedData the encoded payload data; expected to not be empty! + */ + private Mono firstPayload(Mono encodedData) { + return Mono.zip(encodedData, this.metadataEncoder.encode()) + .map(tuple -> PayloadUtils.createPayload(tuple.getT1(), tuple.getT2())) + .doOnDiscard(DataBuffer.class, DataBufferUtils::release) + .doOnDiscard(Payload.class, Payload::release); } @Override public Mono send() { - Assert.state(this.payloadMono != null, "No RSocket interaction model for one-way send with Flux"); - return this.payloadMono.flatMap(rsocket::fireAndForget); + return getPayloadMonoRequired().flatMap(rsocket::fireAndForget); + } + + private Mono getPayloadMonoRequired() { + Assert.state(this.payloadFlux == null, "No RSocket interaction model for Flux request to Mono response."); + return this.payloadMono != null ? this.payloadMono : firstPayload(Mono.just(emptyDataBuffer)); } @Override @@ -286,8 +280,7 @@ public Flux retrieveFlux(ParameterizedTypeReference dataTypeRef) { @SuppressWarnings("unchecked") private Mono retrieveMono(ResolvableType elementType) { - Assert.notNull(this.payloadMono, "No RSocket interaction model for Flux request to Mono response."); - Mono payloadMono = this.payloadMono.flatMap(rsocket::requestResponse); + Mono payloadMono = getPayloadMonoRequired().flatMap(rsocket::requestResponse); if (isVoid(elementType)) { return (Mono) payloadMono.then(); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java index 7d634b9f82a7..24d8026aa592 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java @@ -33,6 +33,7 @@ import io.rsocket.transport.netty.client.WebsocketClientTransport; import reactor.core.publisher.Mono; +import org.springframework.core.ReactiveAdapter; import org.springframework.core.ResolvableType; import org.springframework.core.codec.Decoder; import org.springframework.core.codec.Encoder; @@ -57,6 +58,8 @@ final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder { private static final Map HINTS = Collections.emptyMap(); + private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; + @Nullable private MimeType dataMimeType; @@ -175,50 +178,14 @@ private Mono doConnect(ClientTransport transport) { factory.dataMimeType(dataMimeType.toString()); factory.metadataMimeType(metaMimeType.toString()); - Payload setupPayload = getSetupPayload(dataMimeType, metaMimeType, rsocketStrategies); - if (setupPayload != null) { - factory.setupPayload(setupPayload); - } - - return factory.transport(transport) - .start() - .map(rsocket -> new DefaultRSocketRequester( - rsocket, dataMimeType, metaMimeType, rsocketStrategies)); - } - - @Nullable - private Payload getSetupPayload(MimeType dataMimeType, MimeType metaMimeType, RSocketStrategies strategies) { - DataBuffer metadata = null; - if (this.setupRoute != null || !CollectionUtils.isEmpty(this.setupMetadata)) { - metadata = new MetadataEncoder(metaMimeType, strategies) - .metadataAndOrRoute(this.setupMetadata, this.setupRoute, this.setupRouteVars) - .encode(); - } - DataBuffer data = null; - if (this.setupData != null) { - try { - ResolvableType type = ResolvableType.forClass(this.setupData.getClass()); - Encoder encoder = strategies.encoder(type, dataMimeType); - Assert.notNull(encoder, () -> "No encoder for " + dataMimeType + ", " + type); - data = encoder.encodeValue(this.setupData, strategies.dataBufferFactory(), type, dataMimeType, HINTS); - } - catch (Throwable ex) { - if (metadata != null) { - DataBufferUtils.release(metadata); - } - throw ex; - } - } - if (metadata == null && data == null) { - return null; - } - metadata = metadata != null ? metadata : emptyBuffer(strategies); - data = data != null ? data : emptyBuffer(strategies); - return PayloadUtils.createPayload(data, metadata); - } - - private DataBuffer emptyBuffer(RSocketStrategies strategies) { - return strategies.dataBufferFactory().wrap(new byte[0]); + return getSetupPayload(dataMimeType, metaMimeType, rsocketStrategies) + .doOnNext(factory::setupPayload) + .then(Mono.defer(() -> + factory.transport(transport) + .start() + .map(rsocket -> new DefaultRSocketRequester( + rsocket, dataMimeType, metaMimeType, rsocketStrategies)) + )); } private RSocketStrategies getRSocketStrategies() { @@ -261,4 +228,45 @@ private static MimeType getMimeType(Decoder decoder) { return mimeType.getParameters().isEmpty() ? mimeType : new MimeType(mimeType, Collections.emptyMap()); } + private Mono getSetupPayload( + MimeType dataMimeType, MimeType metaMimeType, RSocketStrategies strategies) { + + Object data = this.setupData; + boolean hasMetadata = (this.setupRoute != null || !CollectionUtils.isEmpty(this.setupMetadata)); + if (!hasMetadata && data == null) { + return Mono.empty(); + } + + Mono dataMono = Mono.empty(); + if (data != null) { + ReactiveAdapter adapter = strategies.reactiveAdapterRegistry().getAdapter(data.getClass()); + Assert.isTrue(adapter == null || !adapter.isMultiValue(), "Expected single value: " + data); + Mono mono = (adapter != null ? Mono.from(adapter.toPublisher(data)) : Mono.just(data)); + dataMono = mono.map(value -> { + ResolvableType type = ResolvableType.forClass(value.getClass()); + Encoder encoder = strategies.encoder(type, dataMimeType); + Assert.notNull(encoder, () -> "No encoder for " + dataMimeType + ", " + type); + return encoder.encodeValue(value, strategies.dataBufferFactory(), type, dataMimeType, HINTS); + }); + } + + Mono metaMono = Mono.empty(); + if (hasMetadata) { + metaMono = new MetadataEncoder(metaMimeType, strategies) + .metadataAndOrRoute(this.setupMetadata, this.setupRoute, this.setupRouteVars) + .encode(); + } + + Mono emptyBuffer = Mono.fromCallable(() -> + strategies.dataBufferFactory().wrap(EMPTY_BYTE_ARRAY)); + + dataMono = dataMono.switchIfEmpty(emptyBuffer); + metaMono = metaMono.switchIfEmpty(emptyBuffer); + + return Mono.zip(dataMono, metaMono) + .map(tuple -> PayloadUtils.createPayload(tuple.getT1(), tuple.getT2())) + .doOnDiscard(DataBuffer.class, DataBufferUtils::release) + .doOnDiscard(Payload.class, Payload::release); + } + } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/MetadataEncoder.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/MetadataEncoder.java index cfe849ef7070..9ff1e0527404 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/MetadataEncoder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/MetadataEncoder.java @@ -15,8 +15,9 @@ */ package org.springframework.messaging.rsocket; +import java.util.ArrayList; import java.util.Collections; -import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,7 +28,9 @@ import io.rsocket.metadata.CompositeMetadataFlyweight; import io.rsocket.metadata.TaggingMetadataFlyweight; import io.rsocket.metadata.WellKnownMimeType; +import reactor.core.publisher.Mono; +import org.springframework.core.ReactiveAdapter; import org.springframework.core.ResolvableType; import org.springframework.core.codec.Encoder; import org.springframework.core.io.buffer.DataBuffer; @@ -50,6 +53,8 @@ final class MetadataEncoder { /** For route variable replacement. */ private static final Pattern VARS_PATTERN = Pattern.compile("\\{([^/]+?)}"); + private static final Object NO_VALUE = new Object(); + private final MimeType metadataMimeType; @@ -62,7 +67,9 @@ final class MetadataEncoder { @Nullable private String route; - private final Map metadata = new LinkedHashMap<>(4); + private final List metadataEntries = new ArrayList<>(4); + + private boolean hasAsyncValues; MetadataEncoder(MimeType metadataMimeType, RSocketStrategies strategies) { @@ -111,7 +118,7 @@ private static String expand(String route, Object... routeVars) { private void assertMetadataEntryCount() { if (!this.isComposite) { - int count = this.route != null ? this.metadata.size() + 1 : this.metadata.size(); + int count = this.route != null ? this.metadataEntries.size() + 1 : this.metadataEntries.size(); Assert.isTrue(count < 2, "Composite metadata required for multiple metadata entries."); } } @@ -128,10 +135,17 @@ else if (mimeType == null) { mimeType = this.metadataMimeType; } else if (!this.metadataMimeType.equals(mimeType)) { - throw new IllegalArgumentException("Mime type is optional (may be null) " + - "but was provided and does not match the connection metadata mime type."); + throw new IllegalArgumentException( + "Mime type is optional when not using composite metadata, but it was provided " + + "and does not match the connection metadata mime type '" + this.metadataMimeType + "'."); } - this.metadata.put(metadata, mimeType); + ReactiveAdapter adapter = this.strategies.reactiveAdapterRegistry().getAdapter(metadata.getClass()); + if (adapter != null) { + Assert.isTrue(!adapter.isMultiValue(), "Expected single value: " + metadata); + metadata = Mono.from(adapter.toPublisher(metadata)).defaultIfEmpty(NO_VALUE); + this.hasAsyncValues = true; + } + this.metadataEntries.add(new MetadataEntry(metadata, mimeType)); assertMetadataEntryCount(); return this; } @@ -159,7 +173,13 @@ public MetadataEncoder metadataAndOrRoute(@Nullable Map metada * Encode the collected metadata entries to a {@code DataBuffer}. * @see PayloadUtils#createPayload(DataBuffer, DataBuffer) */ - public DataBuffer encode() { + public Mono encode() { + return this.hasAsyncValues ? + resolveAsyncMetadata().map(this::encodeEntries) : + Mono.fromCallable(() -> encodeEntries(this.metadataEntries)); + } + + private DataBuffer encodeEntries(List entries) { if (this.isComposite) { CompositeByteBuf composite = this.allocator.compositeBuffer(); try { @@ -167,11 +187,11 @@ public DataBuffer encode() { CompositeMetadataFlyweight.encodeAndAddMetadata(composite, this.allocator, WellKnownMimeType.MESSAGE_RSOCKET_ROUTING, encodeRoute()); } - this.metadata.forEach((value, mimeType) -> { - ByteBuf metadata = (value instanceof ByteBuf ? - (ByteBuf) value : PayloadUtils.asByteBuf(encodeEntry(value, mimeType))); + entries.forEach(entry -> { + Object value = entry.value(); CompositeMetadataFlyweight.encodeAndAddMetadata( - composite, this.allocator, mimeType.toString(), metadata); + composite, this.allocator, entry.mimeType().toString(), + value instanceof ByteBuf ? (ByteBuf) value : PayloadUtils.asByteBuf(encodeEntry(entry))); }); return asDataBuffer(composite); } @@ -181,21 +201,21 @@ public DataBuffer encode() { } } else if (this.route != null) { - Assert.isTrue(this.metadata.isEmpty(), "Composite metadata required for route and other entries"); + Assert.isTrue(entries.isEmpty(), "Composite metadata required for route and other entries"); String routingMimeType = WellKnownMimeType.MESSAGE_RSOCKET_ROUTING.getString(); return this.metadataMimeType.toString().equals(routingMimeType) ? asDataBuffer(encodeRoute()) : encodeEntry(this.route, this.metadataMimeType); } else { - Assert.isTrue(this.metadata.size() == 1, "Composite metadata required for multiple entries"); - Map.Entry entry = this.metadata.entrySet().iterator().next(); - if (!this.metadataMimeType.equals(entry.getValue())) { + Assert.isTrue(entries.size() == 1, "Composite metadata required for multiple entries"); + MetadataEntry entry = entries.get(0); + if (!this.metadataMimeType.equals(entry.mimeType())) { throw new IllegalArgumentException( "Connection configured for metadata mime type " + - "'" + this.metadataMimeType + "', but actual is `" + this.metadata + "`"); + "'" + this.metadataMimeType + "', but actual is `" + entries + "`"); } - return encodeEntry(entry.getKey(), entry.getValue()); + return encodeEntry(entry); } } @@ -204,15 +224,19 @@ private ByteBuf encodeRoute() { this.allocator, Collections.singletonList(this.route)).getContent(); } + private DataBuffer encodeEntry(MetadataEntry entry) { + return encodeEntry(entry.value(), entry.mimeType()); + } + @SuppressWarnings("unchecked") - private DataBuffer encodeEntry(Object metadata, MimeType mimeType) { - if (metadata instanceof ByteBuf) { - return asDataBuffer((ByteBuf) metadata); + private DataBuffer encodeEntry(Object value, MimeType mimeType) { + if (value instanceof ByteBuf) { + return asDataBuffer((ByteBuf) value); } - ResolvableType type = ResolvableType.forInstance(metadata); + ResolvableType type = ResolvableType.forInstance(value); Encoder encoder = this.strategies.encoder(type, mimeType); - Assert.notNull(encoder, () -> "No encoder for metadata " + metadata + ", mimeType '" + mimeType + "'"); - return encoder.encodeValue((T) metadata, bufferFactory(), type, mimeType, Collections.emptyMap()); + Assert.notNull(encoder, () -> "No encoder for metadata " + value + ", mimeType '" + mimeType + "'"); + return encoder.encodeValue((T) value, bufferFactory(), type, mimeType, Collections.emptyMap()); } private DataBuffer asDataBuffer(ByteBuf byteBuf) { @@ -225,4 +249,48 @@ private DataBuffer asDataBuffer(ByteBuf byteBuf) { return buffer; } } + + private Mono> resolveAsyncMetadata() { + Assert.state(this.hasAsyncValues, "No asynchronous values to resolve"); + List> valueMonos = new ArrayList<>(); + this.metadataEntries.forEach(entry -> { + Object v = entry.value(); + valueMonos.add(v instanceof Mono ? (Mono) v : Mono.just(v)); + }); + return Mono.zip(valueMonos, values -> { + List result = new ArrayList<>(values.length); + for (int i = 0; i < values.length; i++) { + if (values[i] != NO_VALUE) { + result.add(new MetadataEntry(values[i], this.metadataEntries.get(i).mimeType())); + } + } + return result; + }); + } + + + /** + * Holder for the metadata value and mime type. + * @since 5.2.2 + */ + private static class MetadataEntry { + + private final Object value; + + private final MimeType mimeType; + + MetadataEntry(Object value, MimeType mimeType) { + this.value = value; + this.mimeType = mimeType; + } + + public Object value() { + return this.value; + } + + public MimeType mimeType() { + return this.mimeType; + } + } + } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java index 4998a1f92f0e..d2981ef41b76 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java @@ -85,7 +85,9 @@ public interface RSocketRequester { RequestSpec route(String route, Object... routeVars); /** - * Begin to specify a new request with the given metadata value. + * Begin to specify a new request with the given metadata value, which can + * be a concrete value or any producer of a single value that can be adapted + * to a {@link Publisher} via {@link ReactiveAdapterRegistry}. * @param metadata the metadata value to encode * @param mimeType the mime type that describes the metadata; * This is required for connection using composite metadata. Otherwise the @@ -143,6 +145,8 @@ interface Builder { /** * Set the data for the setup payload. The data will be encoded * according to the configured {@link #dataMimeType(MimeType)}. + * The data be a concrete value or any producer of a single value that + * can be adapted to a {@link Publisher} via {@link ReactiveAdapterRegistry}. *

By default this is not set. */ RSocketRequester.Builder setupData(Object data); @@ -158,7 +162,9 @@ interface Builder { /** * Add metadata entry to the setup payload. Composite metadata must be * in use if this is called more than once or in addition to - * {@link #setupRoute(String, Object...)}. + * {@link #setupRoute(String, Object...)}. The metadata value be a + * concrete value or any producer of a single value that can be adapted + * to a {@link Publisher} via {@link ReactiveAdapterRegistry}. */ RSocketRequester.Builder setupMetadata(Object value, @Nullable MimeType mimeType); @@ -335,6 +341,9 @@ interface MetadataSpec> { * Use this to append additional metadata entries when using composite * metadata. An {@link IllegalArgumentException} is raised if this * method is used when not using composite metadata. + * The metadata value be a concrete value or any producer of a single + * value that can be adapted to a {@link Publisher} via + * {@link ReactiveAdapterRegistry}. * @param metadata an Object to be encoded with a suitable * {@link org.springframework.core.codec.Encoder Encoder}, or a * {@link org.springframework.core.io.buffer.DataBuffer DataBuffer} diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java index c12a15160dfa..66061ec9c2ff 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java @@ -84,7 +84,7 @@ public void compositeMetadataWithDefaultSettings() { .metadata("html data", TEXT_HTML) .metadata("xml data", TEXT_XML); - DataBuffer metadata = metadataEncoder.encode(); + DataBuffer metadata = metadataEncoder.encode().block(); Payload payload = createPayload(metadata); Map result = this.extractor.extract(payload, COMPOSITE_METADATA); payload.release(); @@ -104,7 +104,7 @@ public void compositeMetadataWithMimeTypeRegistrations() { .metadata("html data", TEXT_HTML) .metadata("xml data", TEXT_XML); - DataBuffer metadata = metadataEncoder.encode(); + DataBuffer metadata = metadataEncoder.encode().block(); Payload payload = createPayload(metadata); Map result = this.extractor.extract(payload, COMPOSITE_METADATA); payload.release(); @@ -120,7 +120,7 @@ public void compositeMetadataWithMimeTypeRegistrations() { public void route() { MimeType metaMimeType = MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_ROUTING.getString()); MetadataEncoder metadataEncoder = new MetadataEncoder(metaMimeType, this.strategies).route("toA"); - DataBuffer metadata = metadataEncoder.encode(); + DataBuffer metadata = metadataEncoder.encode().block(); Payload payload = createPayload(metadata); Map result = this.extractor.extract(payload, metaMimeType); payload.release(); @@ -133,7 +133,7 @@ public void routeAsText() { this.extractor.metadataToExtract(TEXT_PLAIN, String.class, ROUTE_KEY); MetadataEncoder metadataEncoder = new MetadataEncoder(TEXT_PLAIN, this.strategies).route("toA"); - DataBuffer metadata = metadataEncoder.encode(); + DataBuffer metadata = metadataEncoder.encode().block(); Payload payload = createPayload(metadata); Map result = this.extractor.extract(payload, TEXT_PLAIN); payload.release(); @@ -151,7 +151,7 @@ public void routeWithCustomFormatting() { }); MetadataEncoder encoder = new MetadataEncoder(TEXT_PLAIN, this.strategies).metadata("toA:text data", null); - DataBuffer metadata = encoder.encode(); + DataBuffer metadata = encoder.encode().block(); Payload payload = createPayload(metadata); Map result = this.extractor.extract(payload, TEXT_PLAIN); payload.release(); @@ -167,7 +167,7 @@ public void nonCompositeMetadataCanBeReadTwice() { extractor.metadataToExtract(TEXT_PLAIN, String.class, "name"); MetadataEncoder encoder = new MetadataEncoder(TEXT_PLAIN, this.strategies).metadata("value", null); - DataBuffer metadata = encoder.encode(); + DataBuffer metadata = encoder.encode().block(); Payload payload = createPayload(metadata); Map result = extractor.extract(payload, TEXT_PLAIN); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java index 79fefddc1a74..a21f4f91d1b4 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java @@ -17,6 +17,7 @@ package org.springframework.messaging.rsocket; import java.lang.reflect.Field; +import java.time.Duration; import java.util.Collections; import java.util.List; import java.util.Map; @@ -39,6 +40,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.codec.Decoder; import org.springframework.core.codec.DecodingException; +import org.springframework.core.codec.StringDecoder; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.DefaultDataBufferFactory; @@ -191,6 +193,39 @@ public void setupRoute() { assertThat(setupPayload.getDataUtf8()).isEqualTo("My data"); } + @Test + public void setupWithAsyncValues() { + + Mono asyncMeta1 = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async Metadata 1"); + Mono asyncMeta2 = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async Metadata 2"); + Mono data = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async data"); + + RSocketRequester.builder() + .dataMimeType(MimeTypeUtils.TEXT_PLAIN) + .setupRoute("toA") + .setupMetadata(asyncMeta1, new MimeType("text", "x.test.metadata1")) + .setupMetadata(asyncMeta2, new MimeType("text", "x.test.metadata2")) + .setupData(data) + .connect(this.transport) + .block(); + + ConnectionSetupPayload payload = Mono.from(this.connection.sentFrames()) + .map(ConnectionSetupPayload::create) + .block(); + + MimeType compositeMimeType = + MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString()); + + DefaultMetadataExtractor extractor = new DefaultMetadataExtractor(StringDecoder.allMimeTypes()); + extractor.metadataToExtract(new MimeType("text", "x.test.metadata1"), String.class, "asyncMeta1"); + extractor.metadataToExtract(new MimeType("text", "x.test.metadata2"), String.class, "asyncMeta2"); + Map metadataValues = extractor.extract(payload, compositeMimeType); + + assertThat(metadataValues.get("asyncMeta1")).isEqualTo("Async Metadata 1"); + assertThat(metadataValues.get("asyncMeta2")).isEqualTo("Async Metadata 2"); + assertThat(payload.getDataUtf8()).isEqualTo("Async data"); + } + @Test public void frameDecoderMatchesDataBufferFactory() throws Exception { testFrameDecoder(new NettyDataBufferFactory(ByteBufAllocator.DEFAULT), PayloadDecoder.ZERO_COPY); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java index 94055e63f5e5..532e1d76b31e 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java @@ -20,6 +20,7 @@ import java.time.Duration; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; @@ -28,6 +29,7 @@ import io.reactivex.Single; import io.rsocket.AbstractRSocket; import io.rsocket.Payload; +import io.rsocket.metadata.WellKnownMimeType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; @@ -38,10 +40,12 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.lang.Nullable; import org.springframework.messaging.rsocket.RSocketRequester.RequestSpec; +import org.springframework.util.MimeType; +import org.springframework.util.MimeTypeUtils; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.springframework.util.MimeTypeUtils.TEXT_PLAIN; /** @@ -131,6 +135,54 @@ private void testSendFlux(Function mapper, String... e } } + @Test + public void sendWithoutData() { + this.requester.route("toA").send().block(Duration.ofSeconds(5)); + + assertThat(this.rsocket.getSavedMethodName()).isEqualTo("fireAndForget"); + assertThat(this.rsocket.getSavedPayload().getMetadataUtf8()).isEqualTo("toA"); + assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEqualTo(""); + } + + @Test + public void sendMonoWithoutData() { + this.requester.route("toA").retrieveMono(String.class).block(Duration.ofSeconds(5)); + + assertThat(this.rsocket.getSavedMethodName()).isEqualTo("requestResponse"); + assertThat(this.rsocket.getSavedPayload().getMetadataUtf8()).isEqualTo("toA"); + assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEqualTo(""); + } + + @Test + public void testSendWithAsyncMetadata() { + + MimeType compositeMimeType = + MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString()); + + Mono asyncMeta1 = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async Metadata 1"); + Mono asyncMeta2 = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async Metadata 2"); + + TestRSocket rsocket = new TestRSocket(); + RSocketRequester.wrap(rsocket, TEXT_PLAIN, compositeMimeType, this.strategies) + .route("toA") + .metadata(asyncMeta1, new MimeType("text", "x.test.metadata1")) + .metadata(asyncMeta2, new MimeType("text", "x.test.metadata2")) + .data("data") + .send() + .block(Duration.ofSeconds(5)); + + Payload payload = rsocket.getSavedPayload(); + + DefaultMetadataExtractor extractor = new DefaultMetadataExtractor(this.strategies.decoders()); + extractor.metadataToExtract(new MimeType("text", "x.test.metadata1"), String.class, "asyncMeta1"); + extractor.metadataToExtract(new MimeType("text", "x.test.metadata2"), String.class, "asyncMeta2"); + Map metadataValues = extractor.extract(payload, compositeMimeType); + + assertThat(metadataValues.get("asyncMeta1")).isEqualTo("Async Metadata 1"); + assertThat(metadataValues.get("asyncMeta2")).isEqualTo("Async Metadata 2"); + assertThat(payload.getDataUtf8()).isEqualTo("data"); + } + @Test public void retrieveMono() { String value = "bodyA"; @@ -176,7 +228,7 @@ public void retrieveFluxVoid() { @Test public void fluxToMonoIsRejected() { - assertThatIllegalArgumentException() + assertThatIllegalStateException() .isThrownBy(() -> this.requester.route("").data(Flux.just("a", "b")).retrieveMono(String.class)) .withMessage("No RSocket interaction model for Flux request to Mono response."); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java index 6e951de7e9a9..a1ca77d15dda 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java @@ -15,6 +15,7 @@ */ package org.springframework.messaging.rsocket; +import java.time.Duration; import java.util.Collections; import java.util.Iterator; import java.util.Map; @@ -26,6 +27,7 @@ import io.rsocket.metadata.RoutingMetadata; import io.rsocket.metadata.WellKnownMimeType; import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; @@ -56,11 +58,17 @@ public class MetadataEncoderTests { @Test public void compositeMetadata() { + Mono asyncMeta1 = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async Metadata 1"); + Mono asyncMeta2 = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async Metadata 2"); + DataBuffer buffer = new MetadataEncoder(COMPOSITE_METADATA, this.strategies) .route("toA") .metadata("My metadata", MimeTypeUtils.TEXT_PLAIN) + .metadata(asyncMeta1, new MimeType("text", "x.test.metadata1")) .metadata(Unpooled.wrappedBuffer("Raw data".getBytes(UTF_8)), MimeTypeUtils.APPLICATION_OCTET_STREAM) - .encode(); + .metadata(asyncMeta2, new MimeType("text", "x.test.metadata2")) + .encode() + .block(); CompositeMetadata entries = new CompositeMetadata(((NettyDataBuffer) buffer).getNativeBuffer(), false); Iterator iterator = entries.iterator(); @@ -75,11 +83,21 @@ public void compositeMetadata() { assertThat(entry.getMimeType()).isEqualTo(MimeTypeUtils.TEXT_PLAIN_VALUE); assertThat(entry.getContent().toString(UTF_8)).isEqualTo("My metadata"); + assertThat(iterator.hasNext()).isTrue(); + entry = iterator.next(); + assertThat(entry.getMimeType()).isEqualTo("text/x.test.metadata1"); + assertThat(entry.getContent().toString(UTF_8)).isEqualTo("Async Metadata 1"); + assertThat(iterator.hasNext()).isTrue(); entry = iterator.next(); assertThat(entry.getMimeType()).isEqualTo(MimeTypeUtils.APPLICATION_OCTET_STREAM_VALUE); assertThat(entry.getContent().toString(UTF_8)).isEqualTo("Raw data"); + assertThat(iterator.hasNext()).isTrue(); + entry = iterator.next(); + assertThat(entry.getMimeType()).isEqualTo("text/x.test.metadata2"); + assertThat(entry.getContent().toString(UTF_8)).isEqualTo("Async Metadata 2"); + assertThat(iterator.hasNext()).isFalse(); } @@ -92,7 +110,8 @@ public void routeWithRoutingMimeType() { DataBuffer buffer = new MetadataEncoder(mimeType, this.strategies) .route("toA") - .encode(); + .encode() + .block(); assertRoute("toA", ((NettyDataBuffer) buffer).getNativeBuffer()); } @@ -102,7 +121,8 @@ public void routeWithTextPlainMimeType() { DataBuffer buffer = new MetadataEncoder(MimeTypeUtils.TEXT_PLAIN, this.strategies) .route("toA") - .encode(); + .encode() + .block(); assertThat(dumpString(buffer)).isEqualTo("toA"); } @@ -112,7 +132,8 @@ public void routeWithVars() { DataBuffer buffer = new MetadataEncoder(MimeTypeUtils.TEXT_PLAIN, this.strategies) .route("a.{b}.{c}", "BBB", "C.C.C") - .encode(); + .encode() + .block(); assertThat(dumpString(buffer)).isEqualTo("a.BBB.C%2EC%2EC"); } @@ -122,7 +143,8 @@ public void metadataWithTextPlainMimeType() { DataBuffer buffer = new MetadataEncoder(MimeTypeUtils.TEXT_PLAIN, this.strategies) .metadata(Unpooled.wrappedBuffer("Raw data".getBytes(UTF_8)), null) - .encode(); + .encode() + .block(); assertThat(dumpString(buffer)).isEqualTo("Raw data"); } @@ -132,7 +154,8 @@ public void metadataWithByteBuf() { DataBuffer buffer = new MetadataEncoder(MimeTypeUtils.TEXT_PLAIN, this.strategies) .metadata("toA", null) - .encode(); + .encode() + .block(); assertThat(dumpString(buffer)).isEqualTo("toA"); } @@ -175,8 +198,8 @@ public void mimeTypeDoesNotMatchConnectionMetadataMimeType() { MetadataEncoder encoder = new MetadataEncoder(MimeTypeUtils.TEXT_PLAIN, this.strategies); assertThatThrownBy(() -> encoder.metadata("toA", MimeTypeUtils.APPLICATION_JSON)) - .hasMessage("Mime type is optional (may be null) " + - "but was provided and does not match the connection metadata mime type."); + .hasMessage("Mime type is optional when not using composite metadata, " + + "but it was provided and does not match the connection metadata mime type 'text/plain'."); } @Test @@ -186,7 +209,8 @@ public void defaultDataBufferFactory() { DataBuffer buffer = new MetadataEncoder(COMPOSITE_METADATA, strategies) .route("toA") - .encode(); + .encode() + .block(); ByteBuf byteBuf = new NettyDataBufferFactory(ByteBufAllocator.DEFAULT) .wrap(buffer.asByteBuffer()) From 336e0595c58844bc27913debd447ab471e2cd334 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 21 Nov 2019 13:22:30 +0100 Subject: [PATCH 0095/2315] Upgrade to Jetty 9.4.23 and Woodstox 6.0.2 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index eee85543e368..8122d0e95261 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ configure(allprojects) { project -> mavenBom "io.netty:netty-bom:4.1.43.Final" mavenBom "io.projectreactor:reactor-bom:Dysprosium-BUILD-SNAPSHOT" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" - mavenBom "org.eclipse.jetty:jetty-bom:9.4.21.v20190926" + mavenBom "org.eclipse.jetty:jetty-bom:9.4.23.v20191118" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.60" mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.2" mavenBom "org.junit:junit-bom:5.5.2" @@ -82,7 +82,7 @@ configure(allprojects) { project -> dependency "com.caucho:hessian:4.0.62" dependency "com.fasterxml:aalto-xml:1.2.2" - dependency("com.fasterxml.woodstox:woodstox-core:5.2.0") { + dependency("com.fasterxml.woodstox:woodstox-core:6.0.2") { exclude group: "stax", name: "stax-api" } dependency "com.google.code.gson:gson:2.8.6" From bb2e3ce6d13e14fb8c8aeac530859b06635eace0 Mon Sep 17 00:00:00 2001 From: Qimiao Chen Date: Thu, 21 Nov 2019 22:26:42 +0800 Subject: [PATCH 0096/2315] Polish AbstractBeanDefinition Closes gh-24048 --- .../support/AbstractBeanDefinition.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java index b1c6691d0968..6ffddcc13097 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java @@ -1162,28 +1162,28 @@ public boolean equals(@Nullable Object other) { } AbstractBeanDefinition that = (AbstractBeanDefinition) other; boolean rtn = ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName()); - rtn = rtn &= ObjectUtils.nullSafeEquals(this.scope, that.scope); - rtn = rtn &= this.abstractFlag == that.abstractFlag; - rtn = rtn &= this.lazyInit == that.lazyInit; - rtn = rtn &= this.autowireMode == that.autowireMode; - rtn = rtn &= this.dependencyCheck == that.dependencyCheck; - rtn = rtn &= Arrays.equals(this.dependsOn, that.dependsOn); - rtn = rtn &= this.autowireCandidate == that.autowireCandidate; - rtn = rtn &= ObjectUtils.nullSafeEquals(this.qualifiers, that.qualifiers); - rtn = rtn &= this.primary == that.primary; - rtn = rtn &= this.nonPublicAccessAllowed == that.nonPublicAccessAllowed; - rtn = rtn &= this.lenientConstructorResolution == that.lenientConstructorResolution; - rtn = rtn &= ObjectUtils.nullSafeEquals(this.constructorArgumentValues, that.constructorArgumentValues); - rtn = rtn &= ObjectUtils.nullSafeEquals(this.propertyValues, that.propertyValues); - rtn = rtn &= ObjectUtils.nullSafeEquals(this.methodOverrides, that.methodOverrides); - rtn = rtn &= ObjectUtils.nullSafeEquals(this.factoryBeanName, that.factoryBeanName); - rtn = rtn &= ObjectUtils.nullSafeEquals(this.factoryMethodName, that.factoryMethodName); - rtn = rtn &= ObjectUtils.nullSafeEquals(this.initMethodName, that.initMethodName); - rtn = rtn &= this.enforceInitMethod == that.enforceInitMethod; - rtn = rtn &= ObjectUtils.nullSafeEquals(this.destroyMethodName, that.destroyMethodName); - rtn = rtn &= this.enforceDestroyMethod == that.enforceDestroyMethod; - rtn = rtn &= this.synthetic == that.synthetic; - rtn = rtn &= this.role == that.role; + rtn &= ObjectUtils.nullSafeEquals(this.scope, that.scope); + rtn &= this.abstractFlag == that.abstractFlag; + rtn &= this.lazyInit == that.lazyInit; + rtn &= this.autowireMode == that.autowireMode; + rtn &= this.dependencyCheck == that.dependencyCheck; + rtn &= Arrays.equals(this.dependsOn, that.dependsOn); + rtn &= this.autowireCandidate == that.autowireCandidate; + rtn &= ObjectUtils.nullSafeEquals(this.qualifiers, that.qualifiers); + rtn &= this.primary == that.primary; + rtn &= this.nonPublicAccessAllowed == that.nonPublicAccessAllowed; + rtn &= this.lenientConstructorResolution == that.lenientConstructorResolution; + rtn &= ObjectUtils.nullSafeEquals(this.constructorArgumentValues, that.constructorArgumentValues); + rtn &= ObjectUtils.nullSafeEquals(this.propertyValues, that.propertyValues); + rtn &= ObjectUtils.nullSafeEquals(this.methodOverrides, that.methodOverrides); + rtn &= ObjectUtils.nullSafeEquals(this.factoryBeanName, that.factoryBeanName); + rtn &= ObjectUtils.nullSafeEquals(this.factoryMethodName, that.factoryMethodName); + rtn &= ObjectUtils.nullSafeEquals(this.initMethodName, that.initMethodName); + rtn &= this.enforceInitMethod == that.enforceInitMethod; + rtn &= ObjectUtils.nullSafeEquals(this.destroyMethodName, that.destroyMethodName); + rtn &= this.enforceDestroyMethod == that.enforceDestroyMethod; + rtn &= this.synthetic == that.synthetic; + rtn &= this.role == that.role; return rtn && super.equals(other); } From 1f3b595a034c7c554b716ed09e3419a84d3f5fde Mon Sep 17 00:00:00 2001 From: stsypanov Date: Tue, 5 Nov 2019 17:47:19 +0200 Subject: [PATCH 0097/2315] Use String.isEmpty() instead of String.equals("") --- .../factory/annotation/AnnotationBeanWiringInfoResolver.java | 2 +- .../org/springframework/mock/jndi/SimpleNamingContext.java | 4 ++-- .../http/codec/ServerSentEventHttpMessageReader.java | 2 +- .../org/springframework/http/server/DefaultPathContainer.java | 4 ++-- .../org/springframework/web/util/pattern/PathPattern.java | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolver.java index a0e05da517b2..b3550404c5c5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolver.java @@ -56,7 +56,7 @@ protected BeanWiringInfo buildWiringInfo(Object beanInstance, Configurable annot // Autowiring by name or by type return new BeanWiringInfo(annotation.autowire().value(), annotation.dependencyCheck()); } - else if (!"".equals(annotation.value())) { + else if (!annotation.value().isEmpty()) { // Explicitly specified bean name for bean definition to take property values from return new BeanWiringInfo(annotation.value(), false); } diff --git a/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java b/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java index 6c380907f274..f52b8191d4e4 100644 --- a/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java +++ b/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java @@ -126,7 +126,7 @@ public Object lookup(String lookupName) throws NameNotFoundException { if (logger.isDebugEnabled()) { logger.debug("Static JNDI lookup: [" + name + "]"); } - if ("".equals(name)) { + if (name.isEmpty()) { return new SimpleNamingContext(this.root, this.boundObjects, this.environment); } Object found = this.boundObjects.get(name); @@ -306,7 +306,7 @@ private abstract static class AbstractNamingEnumeration implements NamingEnum private Iterator iterator; private AbstractNamingEnumeration(SimpleNamingContext context, String proot) throws NamingException { - if (!"".equals(proot) && !proot.endsWith("/")) { + if (!proot.isEmpty() && !proot.endsWith("/")) { proot = proot + "/"; } String root = context.root + proot; diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java index d6b9c9cb9db7..a6de190d5104 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java @@ -105,7 +105,7 @@ public Flux read( ResolvableType valueType = (shouldWrap ? elementType.getGeneric() : elementType); return stringDecoder.decode(message.getBody(), STRING_TYPE, null, hints) - .bufferUntil(line -> line.equals("")) + .bufferUntil(String::isEmpty) .concatMap(lines -> Mono.justOrEmpty(buildEvent(lines, valueType, shouldWrap, hints))); } diff --git a/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java b/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java index 7d5a586a9b03..2098f4594166 100644 --- a/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java +++ b/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java @@ -97,7 +97,7 @@ public String toString() { static PathContainer createFromUrlPath(String path, Options options) { - if (path.equals("")) { + if (path.isEmpty()) { return EMPTY_PATH; } char separator = options.separator(); @@ -117,7 +117,7 @@ static PathContainer createFromUrlPath(String path, Options options) { while (begin < path.length()) { int end = path.indexOf(separator, begin); String segment = (end != -1 ? path.substring(begin, end) : path.substring(begin)); - if (!segment.equals("")) { + if (!segment.isEmpty()) { elements.add(options.shouldDecodeAndParseSegments() ? decodeAndParsePathSegment(segment) : new DefaultPathSegment(segment, separatorElement)); diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java index 85216a8cda55..81fd66763897 100644 --- a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java +++ b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java @@ -411,8 +411,8 @@ else if (!StringUtils.hasLength(pattern2string.patternString)) { int dotPos2 = p2string.indexOf('.'); String file2 = (dotPos2 == -1 ? p2string : p2string.substring(0, dotPos2)); String secondExtension = (dotPos2 == -1 ? "" : p2string.substring(dotPos2)); - boolean firstExtensionWild = (firstExtension.equals(".*") || firstExtension.equals("")); - boolean secondExtensionWild = (secondExtension.equals(".*") || secondExtension.equals("")); + boolean firstExtensionWild = (firstExtension.equals(".*") || firstExtension.isEmpty()); + boolean secondExtensionWild = (secondExtension.equals(".*") || secondExtension.isEmpty()); if (!firstExtensionWild && !secondExtensionWild) { throw new IllegalArgumentException( "Cannot combine patterns: " + this.patternString + " and " + pattern2string); From b5529f3f2bcf69c89a0a6a52c4f6b0034dc7f61e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 21 Nov 2019 18:20:17 +0100 Subject: [PATCH 0098/2315] Restore short-circuiting in equals implementation Closes gh-24048 --- .../support/AbstractBeanDefinition.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java index 6ffddcc13097..96887d80e2d1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java @@ -1162,28 +1162,28 @@ public boolean equals(@Nullable Object other) { } AbstractBeanDefinition that = (AbstractBeanDefinition) other; boolean rtn = ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName()); - rtn &= ObjectUtils.nullSafeEquals(this.scope, that.scope); - rtn &= this.abstractFlag == that.abstractFlag; - rtn &= this.lazyInit == that.lazyInit; - rtn &= this.autowireMode == that.autowireMode; - rtn &= this.dependencyCheck == that.dependencyCheck; - rtn &= Arrays.equals(this.dependsOn, that.dependsOn); - rtn &= this.autowireCandidate == that.autowireCandidate; - rtn &= ObjectUtils.nullSafeEquals(this.qualifiers, that.qualifiers); - rtn &= this.primary == that.primary; - rtn &= this.nonPublicAccessAllowed == that.nonPublicAccessAllowed; - rtn &= this.lenientConstructorResolution == that.lenientConstructorResolution; - rtn &= ObjectUtils.nullSafeEquals(this.constructorArgumentValues, that.constructorArgumentValues); - rtn &= ObjectUtils.nullSafeEquals(this.propertyValues, that.propertyValues); - rtn &= ObjectUtils.nullSafeEquals(this.methodOverrides, that.methodOverrides); - rtn &= ObjectUtils.nullSafeEquals(this.factoryBeanName, that.factoryBeanName); - rtn &= ObjectUtils.nullSafeEquals(this.factoryMethodName, that.factoryMethodName); - rtn &= ObjectUtils.nullSafeEquals(this.initMethodName, that.initMethodName); - rtn &= this.enforceInitMethod == that.enforceInitMethod; - rtn &= ObjectUtils.nullSafeEquals(this.destroyMethodName, that.destroyMethodName); - rtn &= this.enforceDestroyMethod == that.enforceDestroyMethod; - rtn &= this.synthetic == that.synthetic; - rtn &= this.role == that.role; + rtn = rtn && ObjectUtils.nullSafeEquals(this.scope, that.scope); + rtn = rtn && this.abstractFlag == that.abstractFlag; + rtn = rtn && this.lazyInit == that.lazyInit; + rtn = rtn && this.autowireMode == that.autowireMode; + rtn = rtn && this.dependencyCheck == that.dependencyCheck; + rtn = rtn && Arrays.equals(this.dependsOn, that.dependsOn); + rtn = rtn && this.autowireCandidate == that.autowireCandidate; + rtn = rtn && ObjectUtils.nullSafeEquals(this.qualifiers, that.qualifiers); + rtn = rtn && this.primary == that.primary; + rtn = rtn && this.nonPublicAccessAllowed == that.nonPublicAccessAllowed; + rtn = rtn && this.lenientConstructorResolution == that.lenientConstructorResolution; + rtn = rtn && ObjectUtils.nullSafeEquals(this.constructorArgumentValues, that.constructorArgumentValues); + rtn = rtn && ObjectUtils.nullSafeEquals(this.propertyValues, that.propertyValues); + rtn = rtn && ObjectUtils.nullSafeEquals(this.methodOverrides, that.methodOverrides); + rtn = rtn && ObjectUtils.nullSafeEquals(this.factoryBeanName, that.factoryBeanName); + rtn = rtn && ObjectUtils.nullSafeEquals(this.factoryMethodName, that.factoryMethodName); + rtn = rtn && ObjectUtils.nullSafeEquals(this.initMethodName, that.initMethodName); + rtn = rtn && this.enforceInitMethod == that.enforceInitMethod; + rtn = rtn && ObjectUtils.nullSafeEquals(this.destroyMethodName, that.destroyMethodName); + rtn = rtn && this.enforceDestroyMethod == that.enforceDestroyMethod; + rtn = rtn && this.synthetic == that.synthetic; + rtn = rtn && this.role == that.role; return rtn && super.equals(other); } From 21b2fc1f0129420a8da521cd1e7f33f19beffbc1 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 22 Nov 2019 10:27:38 +0000 Subject: [PATCH 0099/2315] Improve HttpHandlerConnection completion Before this commit the connector waited for a completed response (via ServerHttpResponse#setComplete or ServerHttpResponse#writeWith) or an error signal in handling, but it didn't deal explicitly with the case where both can occur. This commit explicitly waits for the completion of handling (success or error) before passing the response downstream. If an error occurs after response completion, it is wrapped in a dedicated exception that also provides access to the completed response. Close gh-24051 --- .../reactive/MockClientHttpResponse.java | 6 +++ .../reactive/server/HttpHandlerConnector.java | 49 ++++++++++++++++--- .../reactive/test/MockClientHttpResponse.java | 8 ++- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/mock/http/client/reactive/MockClientHttpResponse.java b/spring-test/src/main/java/org/springframework/mock/http/client/reactive/MockClientHttpResponse.java index 9385899bff0c..739d8ba93537 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/client/reactive/MockClientHttpResponse.java +++ b/spring-test/src/main/java/org/springframework/mock/http/client/reactive/MockClientHttpResponse.java @@ -148,4 +148,10 @@ private Charset getCharset() { return (charset != null ? charset : StandardCharsets.UTF_8); } + + @Override + public String toString() { + HttpStatus code = HttpStatus.resolve(this.status); + return (code != null ? code.name() + "(" + this.status + ")" : "Status (" + this.status + ")") + this.headers; + } } diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/HttpHandlerConnector.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/HttpHandlerConnector.java index 792e3c530786..c5841c41ec2b 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/HttpHandlerConnector.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/HttpHandlerConnector.java @@ -83,7 +83,9 @@ public Mono connect(HttpMethod httpMethod, URI uri, private Mono doConnect( HttpMethod httpMethod, URI uri, Function> requestCallback) { - MonoProcessor result = MonoProcessor.create(); + MonoProcessor requestWriteCompletion = MonoProcessor.create(); + MonoProcessor handlerCompletion = MonoProcessor.create(); + ClientHttpResponse[] savedResponse = new ClientHttpResponse[1]; MockClientHttpRequest mockClientRequest = new MockClientHttpRequest(httpMethod, uri); MockServerHttpResponse mockServerResponse = new MockServerHttpResponse(); @@ -92,20 +94,26 @@ private Mono doConnect( log("Invoking HttpHandler for ", httpMethod, uri); ServerHttpRequest mockServerRequest = adaptRequest(mockClientRequest, requestBody); ServerHttpResponse responseToUse = prepareResponse(mockServerResponse, mockServerRequest); - this.handler.handle(mockServerRequest, responseToUse).subscribe(aVoid -> {}, result::onError); + this.handler.handle(mockServerRequest, responseToUse).subscribe(handlerCompletion); return Mono.empty(); }); mockServerResponse.setWriteHandler(responseBody -> Mono.fromRunnable(() -> { log("Creating client response for ", httpMethod, uri); - result.onNext(adaptResponse(mockServerResponse, responseBody)); + savedResponse[0] = adaptResponse(mockServerResponse, responseBody); })); log("Writing client request for ", httpMethod, uri); - requestCallback.apply(mockClientRequest).subscribe(aVoid -> {}, result::onError); - - return result; + requestCallback.apply(mockClientRequest).subscribe(requestWriteCompletion); + + return Mono.when(requestWriteCompletion, handlerCompletion) + .onErrorMap(ex -> { + ClientHttpResponse response = savedResponse[0]; + return response != null ? new FailureAfterResponseCompletedException(response, ex) : ex; + }) + .then(Mono.fromCallable(() -> savedResponse[0] != null ? + savedResponse[0] : adaptResponse(mockServerResponse, Flux.empty()))); } private void log(String message, HttpMethod httpMethod, URI uri) { @@ -135,4 +143,33 @@ private ClientHttpResponse adaptResponse(MockServerHttpResponse response, FluxWhat happens on an actual running server depends on when the server + * commits the response and the error may or may not change the response. + * Therefore in tests without a server the exception is wrapped and allowed + * to propagate so the application is alerted. + * @since 5.2.2 + */ + @SuppressWarnings("serial") + public static final class FailureAfterResponseCompletedException extends RuntimeException { + + private final ClientHttpResponse completedResponse; + + + private FailureAfterResponseCompletedException(ClientHttpResponse response, Throwable cause) { + super("Error occurred after response was completed: " + response, cause); + this.completedResponse = response; + } + + + public ClientHttpResponse getCompletedResponse() { + return this.completedResponse; + } + } + } diff --git a/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java b/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java index f7b772a74c8e..e757bfad7c46 100644 --- a/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java +++ b/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java @@ -64,7 +64,7 @@ public MockClientHttpResponse(HttpStatus status) { } public MockClientHttpResponse(int status) { - Assert.isTrue(status >= 100 && status < 600, "Status must be between 1xx and 5xx"); + Assert.isTrue(status > 99 && status < 1000, "Status must be between 100 and 999"); this.status = status; } @@ -148,4 +148,10 @@ private Charset getCharset() { return (charset != null ? charset : StandardCharsets.UTF_8); } + + @Override + public String toString() { + HttpStatus code = HttpStatus.resolve(this.status); + return (code != null ? code.name() + "(" + this.status + ")" : "Status (" + this.status + ")") + this.headers; + } } From 712eac2915f73e9a59940e8a6a62123d6cea38d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Fri, 22 Nov 2019 12:11:07 +0100 Subject: [PATCH 0100/2315] Refine Coroutines annotated controller support This commit refines Coroutines annotated controller support by considering Kotlin Unit as Java void and using the right ReactiveAdapter to support all use cases, including suspending functions that return Flow (usual when using APIs like WebClient). It also fixes RSocket fire and forget handling and adds related tests for that use case. Closes gh-24057 Closes gh-23866 --- .../springframework/core/CoroutinesUtils.kt | 32 ++++----- .../springframework/core/MethodParameter.java | 4 ++ .../reactive/InvocableHandlerMethod.java | 8 ++- ...lientToServerCoroutinesIntegrationTests.kt | 67 ++++++++++++++++++- .../result/method/InvocableHandlerMethod.java | 3 +- 5 files changed, 93 insertions(+), 21 deletions(-) diff --git a/spring-core/kotlin-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt b/spring-core/kotlin-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt index 64b1af36f0f3..edfd76d8c932 100644 --- a/spring-core/kotlin-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt +++ b/spring-core/kotlin-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt @@ -26,6 +26,7 @@ import kotlinx.coroutines.reactive.awaitFirstOrNull import kotlinx.coroutines.reactor.asFlux import kotlinx.coroutines.reactor.mono +import org.reactivestreams.Publisher import reactor.core.publisher.Mono import java.lang.reflect.InvocationTargetException import java.lang.reflect.Method @@ -51,28 +52,29 @@ internal fun monoToDeferred(source: Mono) = GlobalScope.async(Dispatchers.Unconfined) { source.awaitFirstOrNull() } /** - * Invoke a suspending function converting it to [Mono] or [reactor.core.publisher.Flux] - * if necessary. + * Return {@code true} if the method is a suspending function. + * + * @author Sebastien Deleuze + * @since 5.2.2 + */ +internal fun isSuspendingFunction(method: Method) = method.kotlinFunction!!.isSuspend + +/** + * Invoke a suspending function and converts it to [Mono] or [reactor.core.publisher.Flux]. * * @author Sebastien Deleuze * @since 5.2 */ @Suppress("UNCHECKED_CAST") -internal fun invokeSuspendingFunction(method: Method, bean: Any, vararg args: Any?): Any? { +internal fun invokeSuspendingFunction(method: Method, bean: Any, vararg args: Any?): Publisher<*> { val function = method.kotlinFunction!! - return if (function.isSuspend) { - val mono = mono(Dispatchers.Unconfined) { - function.callSuspend(bean, *args.sliceArray(0..(args.size-2))) - .let { if (it == Unit) null else it } - }.onErrorMap(InvocationTargetException::class.java) { it.targetException } - if (function.returnType.classifier == Flow::class) { - mono.flatMapMany { (it as Flow).asFlux() } - } - else { - mono - } + val mono = mono(Dispatchers.Unconfined) { + function.callSuspend(bean, *args.sliceArray(0..(args.size-2))).let { if (it == Unit) null else it } + }.onErrorMap(InvocationTargetException::class.java) { it.targetException } + return if (function.returnType.classifier == Flow::class) { + mono.flatMapMany { (it as Flow).asFlux() } } else { - function.call(bean, *args) + mono } } diff --git a/spring-core/src/main/java/org/springframework/core/MethodParameter.java b/spring-core/src/main/java/org/springframework/core/MethodParameter.java index e3ae0562bac8..bcb1a357ef92 100644 --- a/spring-core/src/main/java/org/springframework/core/MethodParameter.java +++ b/spring-core/src/main/java/org/springframework/core/MethodParameter.java @@ -30,6 +30,7 @@ import java.util.Optional; import java.util.function.Predicate; +import kotlin.Unit; import kotlin.reflect.KFunction; import kotlin.reflect.KParameter; import kotlin.reflect.jvm.ReflectJvmMapping; @@ -929,6 +930,9 @@ static private Class getReturnType(Method method) { KFunction function = ReflectJvmMapping.getKotlinFunction(method); if (function != null && function.isSuspend()) { Type paramType = ReflectJvmMapping.getJavaType(function.getReturnType()); + if (paramType == Unit.class) { + paramType = void.class; + } return ResolvableType.forType(paramType).resolve(method.getReturnType()); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java index 0db41014e4fb..8ded74c07d65 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java @@ -127,10 +127,13 @@ public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry) { public Mono invoke(Message message, Object... providedArgs) { return getMethodArgumentValues(message, providedArgs).flatMap(args -> { Object value; + boolean isSuspendingFunction = false; try { Method method = getBridgedMethod(); ReflectionUtils.makeAccessible(method); - if (KotlinDetector.isKotlinReflectPresent() && KotlinDetector.isKotlinType(method.getDeclaringClass())) { + if (KotlinDetector.isKotlinReflectPresent() && KotlinDetector.isKotlinType(method.getDeclaringClass()) + && CoroutinesUtils.isSuspendingFunction(method)) { + isSuspendingFunction = true; value = CoroutinesUtils.invokeSuspendingFunction(method, getBean(), args); } else { @@ -151,7 +154,8 @@ public Mono invoke(Message message, Object... providedArgs) { } MethodParameter returnType = getReturnType(); - ReactiveAdapter adapter = this.reactiveAdapterRegistry.getAdapter(returnType.getParameterType()); + Class reactiveType = (isSuspendingFunction ? value.getClass() : returnType.getParameterType()); + ReactiveAdapter adapter = this.reactiveAdapterRegistry.getAdapter(reactiveType); return (isAsyncVoidReturnType(returnType, adapter) ? Mono.from(adapter.toPublisher(value)) : Mono.justOrEmpty(value)); }); diff --git a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt index cbc5a5a77a73..d72da8a94fef 100644 --- a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt +++ b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt @@ -39,6 +39,7 @@ import org.springframework.messaging.handler.annotation.MessageMapping import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler import org.springframework.stereotype.Controller import reactor.core.publisher.Flux +import reactor.core.publisher.ReplayProcessor import reactor.test.StepVerifier import java.time.Duration @@ -50,6 +51,34 @@ import java.time.Duration */ class RSocketClientToServerCoroutinesIntegrationTests { + @Test + fun fireAndForget() { + Flux.range(1, 3) + .concatMap { requester.route("receive").data("Hello $it").send() } + .blockLast() + StepVerifier.create(context.getBean(ServerController::class.java).fireForgetPayloads) + .expectNext("Hello 1") + .expectNext("Hello 2") + .expectNext("Hello 3") + .thenAwait(Duration.ofMillis(50)) + .thenCancel() + .verify(Duration.ofSeconds(5)) + } + + @Test + fun fireAndForgetAsync() { + Flux.range(1, 3) + .concatMap { i: Int -> requester.route("receive-async").data("Hello $i").send() } + .blockLast() + StepVerifier.create(context.getBean(ServerController::class.java).fireForgetPayloads) + .expectNext("Hello 1") + .expectNext("Hello 2") + .expectNext("Hello 3") + .thenAwait(Duration.ofMillis(50)) + .thenCancel() + .verify(Duration.ofSeconds(5)) + } + @Test fun echoAsync() { val result = Flux.range(1, 3).concatMap { i -> requester.route("echo-async").data("Hello " + i!!).retrieveMono(String::class.java) } @@ -70,6 +99,16 @@ class RSocketClientToServerCoroutinesIntegrationTests { .verify(Duration.ofSeconds(5)) } + @Test + fun echoStreamAsync() { + val result = requester.route("echo-stream-async").data("Hello").retrieveFlux(String::class.java) + + StepVerifier.create(result) + .expectNext("Hello 0").expectNextCount(6).expectNext("Hello 7") + .thenCancel() + .verify(Duration.ofSeconds(5)) + } + @Test fun echoChannel() { val result = requester.route("echo-channel") @@ -106,6 +145,19 @@ class RSocketClientToServerCoroutinesIntegrationTests { @Controller class ServerController { + val fireForgetPayloads = ReplayProcessor.create() + + @MessageMapping("receive") + fun receive(payload: String) { + fireForgetPayloads.onNext(payload) + } + + @MessageMapping("receive-async") + suspend fun receiveAsync(payload: String) { + delay(10) + fireForgetPayloads.onNext(payload) + } + @MessageMapping("echo-async") suspend fun echoAsync(payload: String): String { delay(10) @@ -123,6 +175,18 @@ class RSocketClientToServerCoroutinesIntegrationTests { } } + @MessageMapping("echo-stream-async") + suspend fun echoStreamAsync(payload: String): Flow { + delay(10) + var i = 0 + return flow { + while(true) { + delay(10) + emit("$payload ${i++}") + } + } + } + @MessageMapping("echo-channel") fun echoChannel(payloads: Flow) = payloads.map { delay(10) @@ -185,8 +249,6 @@ class RSocketClientToServerCoroutinesIntegrationTests { private lateinit var server: CloseableChannel - private val interceptor = FireAndForgetCountingInterceptor() - private lateinit var requester: RSocketRequester @@ -196,7 +258,6 @@ class RSocketClientToServerCoroutinesIntegrationTests { context = AnnotationConfigApplicationContext(ServerConfig::class.java) server = RSocketFactory.receive() - .addResponderPlugin(interceptor) .frameDecoder(PayloadDecoder.ZERO_COPY) .acceptor(context.getBean(RSocketMessageHandler::class.java).responder()) .transport(TcpServerTransport.create("localhost", 7000)) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java index ada5628945eb..c419fb491ed9 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java @@ -139,7 +139,8 @@ public Mono invoke( try { ReflectionUtils.makeAccessible(getBridgedMethod()); Method method = getBridgedMethod(); - if (KotlinDetector.isKotlinReflectPresent() && KotlinDetector.isKotlinType(method.getDeclaringClass())) { + if (KotlinDetector.isKotlinReflectPresent() && KotlinDetector.isKotlinType(method.getDeclaringClass()) + && CoroutinesUtils.isSuspendingFunction(method)) { value = CoroutinesUtils.invokeSuspendingFunction(method, getBean(), args); } else { From dc0ebefc56cf507bfc3c13bc7383156b78366aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Fri, 22 Nov 2019 15:03:17 +0100 Subject: [PATCH 0101/2315] Add support for asyncDispatch to MockMvc Kotlin DSL Closes gh-23758 --- .../web/servlet/MockHttpServletRequestDsl.kt | 2 +- .../test/web/servlet/ResultActionsDsl.kt | 17 ++++++++++++++++- .../test/web/servlet/MockMvcExtensionsTests.kt | 13 +++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt index 643a32882cbf..7226d319b750 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt @@ -204,6 +204,6 @@ open class MockHttpServletRequestDsl(private val builder: MockHttpServletRequest flashAttrs?.also { builder.flashAttrs(flashAttrs!!) } session?.also { builder.session(session!!) } principal?.also { builder.principal(principal!!) } - return ResultActionsDsl(mockMvc.perform(builder)) + return ResultActionsDsl(mockMvc.perform(builder), mockMvc) } } diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/ResultActionsDsl.kt b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/ResultActionsDsl.kt index 43c639742a20..5c54df36d327 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/ResultActionsDsl.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/ResultActionsDsl.kt @@ -1,12 +1,14 @@ package org.springframework.test.web.servlet +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders + /** * Provide a [ResultActions] Kotlin DSL in order to be able to write idiomatic Kotlin code. * * @author Sebastien Deleuze * @since 5.2 */ -class ResultActionsDsl(private val actions: ResultActions) { +class ResultActionsDsl(private val actions: ResultActions, private val mockMvc: MockMvc) { /** * Provide access to [MockMvcResultMatchersDsl] Kotlin DSL. @@ -26,6 +28,19 @@ class ResultActionsDsl(private val actions: ResultActions) { return this } + /** + * Enable asynchronous dispatching. + * @see MockMvcRequestBuilders.asyncDispatch + * @since 5.2.2 + */ + fun asyncDispatch(): ResultActionsDsl { + return andExpect { + request { asyncStarted() } + }.andReturn().let { + ResultActionsDsl(mockMvc.perform(MockMvcRequestBuilders.asyncDispatch(it)), mockMvc) + } + } + /** * @see ResultActions.andReturn */ diff --git a/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt b/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt index 2ac5accb3af7..9729c10ec967 100644 --- a/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt +++ b/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt @@ -25,6 +25,7 @@ import org.springframework.http.MediaType.* import org.springframework.test.web.Person import org.springframework.test.web.servlet.setup.MockMvcBuilders import org.springframework.web.bind.annotation.* +import reactor.core.publisher.Mono import java.security.Principal import java.util.* @@ -153,6 +154,13 @@ class MockMvcExtensionsTests { } } + @Test + fun asyncDispatch() { + mockMvc.get("/async").asyncDispatch().andExpect { + status { isOk } + } + } + @RestController private class PersonController { @@ -166,5 +174,10 @@ class MockMvcExtensionsTests { @PostMapping("/person") @ResponseStatus(HttpStatus.CREATED) fun post(@RequestBody person: Person) {} + + @GetMapping("/async") + fun getAsync(): Mono { + return Mono.just(Person("foo")) + } } } From 6c7250b0ae6c7d4fae62c006392425a01a55fa3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Fri, 22 Nov 2019 16:10:42 +0100 Subject: [PATCH 0102/2315] Make Kotlin DSL class constructors internal Closes gh-24059 --- .../org/springframework/context/support/BeanDefinitionDsl.kt | 2 +- .../test/web/servlet/MockHttpServletRequestDsl.kt | 2 +- .../test/web/servlet/MockMultipartHttpServletRequestDsl.kt | 2 +- .../test/web/servlet/MockMvcResultHandlersDsl.kt | 2 +- .../test/web/servlet/MockMvcResultMatchersDsl.kt | 2 +- .../org/springframework/test/web/servlet/ResultActionsDsl.kt | 2 +- .../web/reactive/function/server/CoRouterFunctionDsl.kt | 2 +- .../web/reactive/function/server/RouterFunctionDsl.kt | 2 +- .../springframework/web/servlet/function/RouterFunctionDsl.kt | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spring-context/src/main/kotlin/org/springframework/context/support/BeanDefinitionDsl.kt b/spring-context/src/main/kotlin/org/springframework/context/support/BeanDefinitionDsl.kt index 02243ab8ba3e..19bf94c0384c 100644 --- a/spring-context/src/main/kotlin/org/springframework/context/support/BeanDefinitionDsl.kt +++ b/spring-context/src/main/kotlin/org/springframework/context/support/BeanDefinitionDsl.kt @@ -76,7 +76,7 @@ fun beans(init: BeanDefinitionDsl.() -> Unit) = BeanDefinitionDsl(init) * @author Sebastien Deleuze * @since 5.0 */ -open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit, +open class BeanDefinitionDsl internal constructor (private val init: BeanDefinitionDsl.() -> Unit, private val condition: (ConfigurableEnvironment) -> Boolean = { true }) : ApplicationContextInitializer { diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt index 7226d319b750..20bb0a0c9907 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt @@ -40,7 +40,7 @@ import javax.servlet.http.Cookie * @author Sebastien Deleuze * @since 5.2 */ -open class MockHttpServletRequestDsl(private val builder: MockHttpServletRequestBuilder) { +open class MockHttpServletRequestDsl internal constructor (private val builder: MockHttpServletRequestBuilder) { /** * @see [MockHttpServletRequestBuilder.contextPath] diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMultipartHttpServletRequestDsl.kt b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMultipartHttpServletRequestDsl.kt index 503cae568200..1a2e83745a7d 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMultipartHttpServletRequestDsl.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMultipartHttpServletRequestDsl.kt @@ -27,7 +27,7 @@ import javax.servlet.http.Part * @author Sebastien Deleuze * @since 5.2 */ -class MockMultipartHttpServletRequestDsl(private val builder: MockMultipartHttpServletRequestBuilder) : MockHttpServletRequestDsl(builder) { +class MockMultipartHttpServletRequestDsl internal constructor (private val builder: MockMultipartHttpServletRequestBuilder) : MockHttpServletRequestDsl(builder) { /** * @see [MockMultipartHttpServletRequestBuilder.file] diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMvcResultHandlersDsl.kt b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMvcResultHandlersDsl.kt index 72727ed14b20..c493b450de7d 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMvcResultHandlersDsl.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMvcResultHandlersDsl.kt @@ -26,7 +26,7 @@ import java.io.Writer * @author Sebastien Deleuze * @since 5.2 */ -class MockMvcResultHandlersDsl(private val actions: ResultActions) { +class MockMvcResultHandlersDsl internal constructor (private val actions: ResultActions) { /** * @see MockMvcResultHandlers.print diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMvcResultMatchersDsl.kt b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMvcResultMatchersDsl.kt index b34f158afa81..6a5d90902589 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMvcResultMatchersDsl.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockMvcResultMatchersDsl.kt @@ -25,7 +25,7 @@ import org.springframework.test.web.servlet.result.* * @author Sebastien Deleuze * @since 5.2 */ -class MockMvcResultMatchersDsl(private val actions: ResultActions) { +class MockMvcResultMatchersDsl internal constructor (private val actions: ResultActions) { /** * @see MockMvcResultMatchers.request diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/ResultActionsDsl.kt b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/ResultActionsDsl.kt index 5c54df36d327..128b9492b8c4 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/ResultActionsDsl.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/ResultActionsDsl.kt @@ -8,7 +8,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders * @author Sebastien Deleuze * @since 5.2 */ -class ResultActionsDsl(private val actions: ResultActions, private val mockMvc: MockMvc) { +class ResultActionsDsl internal constructor (private val actions: ResultActions, private val mockMvc: MockMvc) { /** * Provide access to [MockMvcResultMatchersDsl] Kotlin DSL. diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDsl.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDsl.kt index 2477e74475a9..e0724db28d01 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDsl.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDsl.kt @@ -63,7 +63,7 @@ fun coRouter(routes: (CoRouterFunctionDsl.() -> Unit)) = * @author Sebastien Deleuze * @since 5.2 */ -class CoRouterFunctionDsl(private val init: (CoRouterFunctionDsl.() -> Unit)) { +class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunctionDsl.() -> Unit)) { @PublishedApi internal val builder = RouterFunctions.route() diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDsl.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDsl.kt index 305ccabee49a..69ead9e87e7b 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDsl.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDsl.kt @@ -60,7 +60,7 @@ fun router(routes: RouterFunctionDsl.() -> Unit) = RouterFunctionDsl(routes).bui * @author Yevhenii Melnyk * @since 5.0 */ -class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { +class RouterFunctionDsl internal constructor (private val init: RouterFunctionDsl.() -> Unit) { @PublishedApi internal val builder = RouterFunctions.route() diff --git a/spring-webmvc/src/main/kotlin/org/springframework/web/servlet/function/RouterFunctionDsl.kt b/spring-webmvc/src/main/kotlin/org/springframework/web/servlet/function/RouterFunctionDsl.kt index 1ae9e0488a9f..d4cb76d638a6 100644 --- a/spring-webmvc/src/main/kotlin/org/springframework/web/servlet/function/RouterFunctionDsl.kt +++ b/spring-webmvc/src/main/kotlin/org/springframework/web/servlet/function/RouterFunctionDsl.kt @@ -58,7 +58,7 @@ fun router(routes: (RouterFunctionDsl.() -> Unit)) = RouterFunctionDsl(routes).b * @author Sebastien Deleuze * @since 5.2 */ -class RouterFunctionDsl(private val init: (RouterFunctionDsl.() -> Unit)) { +class RouterFunctionDsl internal constructor (private val init: (RouterFunctionDsl.() -> Unit)) { @PublishedApi internal val builder = RouterFunctions.route() From 51b35e64cfba8a46803e97632244251ea7ea2700 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 22 Nov 2019 15:55:44 +0000 Subject: [PATCH 0103/2315] Extra isReady-onWritePossible after last write Closes gh-24050 --- .../AbstractListenerWriteProcessor.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java index 4f05d5e1e091..3f37a9558068 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java @@ -62,8 +62,17 @@ public abstract class AbstractListenerWriteProcessor implements Processor void onNext(AbstractListenerWriteProcessor processor, T data) { } @Override public void onComplete(AbstractListenerWriteProcessor processor) { - processor.changeStateToComplete(this); + processor.readyToCompleteAfterLastWrite = true; + processor.changeStateToReceived(this); } }, @@ -352,7 +362,10 @@ public void onComplete(AbstractListenerWriteProcessor processor) { @SuppressWarnings("deprecation") @Override public void onWritePossible(AbstractListenerWriteProcessor processor) { - if (processor.changeState(this, WRITING)) { + if (processor.readyToCompleteAfterLastWrite) { + processor.changeStateToComplete(RECEIVED); + } + else if (processor.changeState(this, WRITING)) { T data = processor.currentData; Assert.state(data != null, "No data"); try { @@ -360,7 +373,8 @@ public void onWritePossible(AbstractListenerWriteProcessor processor) { if (processor.changeState(WRITING, REQUESTED)) { processor.currentData = null; if (processor.subscriberCompleted) { - processor.changeStateToComplete(REQUESTED); + processor.readyToCompleteAfterLastWrite = true; + processor.changeStateToReceived(REQUESTED); } else { processor.writingPaused(); From 7bed4f36da61ee6d729bbd59639d5be183655700 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 22 Nov 2019 16:38:43 +0000 Subject: [PATCH 0104/2315] Add missing verify() in Jackson2TokenizerTests Closes gh-24056 --- .../http/codec/json/Jackson2TokenizerTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java index aa92701eeb24..6f829a056ec2 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java @@ -210,8 +210,8 @@ public void testLimit() { .expectNext(expected) .verifyComplete(); - StepVerifier.create(decode(source, false, maxInMemorySize - 1)) - .expectError(DataBufferLimitException.class); + StepVerifier.create(decode(source, false, maxInMemorySize - 2)) + .verifyError(DataBufferLimitException.class); } @Test From 59e250c93c0fd780057ca1b5f39bec1badbdf4b4 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 24 Nov 2019 13:49:43 +0100 Subject: [PATCH 0105/2315] Consistent use of SCOPE_PROTOTYPE and SCOPE_SINGLETON constants Closes gh-19905 --- .../PrototypeBasedTargetSourceTests.java | 3 +- .../beans/factory/config/BeanDefinition.java | 6 +- .../config/ConfigurableBeanFactory.java | 10 +-- .../AbstractAutowireCapableBeanFactory.java | 10 +-- .../factory/support/AbstractBeanFactory.java | 2 +- .../PropertiesBeanDefinitionReader.java | 7 +- .../DefaultListableBeanFactoryTests.java | 47 ++++++------ ...wiredAnnotationBeanPostProcessorTests.java | 74 +++++++++---------- ...njectAnnotationBeanPostProcessorTests.java | 14 ++-- .../annotation/LookupAnnotationTests.java | 3 +- .../security/CallbacksSecurityTests.java | 4 +- .../support/StaticApplicationContext.java | 7 +- .../CustomScopeAnnotationBean.java | 4 +- .../example/scannable_scoped/MyScope.java | 4 +- .../AnnotationProcessorPerformanceTests.java | 9 ++- .../ClassPathBeanDefinitionScannerTests.java | 2 +- .../ConfigurationClassPostProcessorTests.java | 13 ++-- ...wiredAnnotationBeanPostProcessorTests.java | 9 ++- .../configuration/Spr12526Tests.java | 22 +++--- .../event/ApplicationContextEventTests.java | 3 +- .../ApplicationContextExpressionTests.java | 5 +- .../GenericApplicationContextTests.java | 3 +- .../annotation/AsyncExecutionTests.java | 3 +- 23 files changed, 138 insertions(+), 126 deletions(-) diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java index f051925ad3c6..a8b7d812ab22 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java @@ -20,6 +20,7 @@ import org.springframework.aop.TargetSource; import org.springframework.beans.MutablePropertyValues; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.tests.sample.beans.SerializablePerson; @@ -47,7 +48,7 @@ public void testSerializability() throws Exception { MutablePropertyValues pvs = new MutablePropertyValues(); RootBeanDefinition bd = new RootBeanDefinition(SerializablePerson.class); bd.setPropertyValues(pvs); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("ts", tsBd); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java index f22b60821288..01dd1f4f90a1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java @@ -41,16 +41,18 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement { /** - * Scope identifier for the standard singleton scope: "singleton". + * Scope identifier for the standard singleton scope: {@value}. *

Note that extended bean factories might support further scopes. * @see #setScope + * @see ConfigurableBeanFactory#SCOPE_SINGLETON */ String SCOPE_SINGLETON = ConfigurableBeanFactory.SCOPE_SINGLETON; /** - * Scope identifier for the standard prototype scope: "prototype". + * Scope identifier for the standard prototype scope: {@value}. *

Note that extended bean factories might support further scopes. * @see #setScope + * @see ConfigurableBeanFactory#SCOPE_PROTOTYPE */ String SCOPE_PROTOTYPE = ConfigurableBeanFactory.SCOPE_PROTOTYPE; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java index 98aa3a87ccfd..166fec179239 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -51,15 +51,15 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, SingletonBeanRegistry { /** - * Scope identifier for the standard singleton scope: "singleton". - * Custom scopes can be added via {@code registerScope}. + * Scope identifier for the standard singleton scope: {@value}. + *

Custom scopes can be added via {@code registerScope}. * @see #registerScope */ String SCOPE_SINGLETON = "singleton"; /** - * Scope identifier for the standard prototype scope: "prototype". - * Custom scopes can be added via {@code registerScope}. + * Scope identifier for the standard prototype scope: {@value}. + *

Custom scopes can be added via {@code registerScope}. * @see #registerScope */ String SCOPE_PROTOTYPE = "prototype"; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index 4990f4fdd591..516cb180c86d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -311,7 +311,7 @@ public T createBean(Class beanClass) throws BeansException { public void autowireBean(Object existingBean) { // Use non-singleton bean definition, to avoid registering bean as dependent bean. RootBeanDefinition bd = new RootBeanDefinition(ClassUtils.getUserClass(existingBean)); - bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(SCOPE_PROTOTYPE); bd.allowCaching = ClassUtils.isCacheSafe(bd.getBeanClass(), getBeanClassLoader()); BeanWrapper bw = new BeanWrapperImpl(existingBean); initBeanWrapper(bw); @@ -331,7 +331,7 @@ public Object configureBean(Object existingBean, String beanName) throws BeansEx bd = new RootBeanDefinition(mbd); } if (!bd.isPrototype()) { - bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(SCOPE_PROTOTYPE); bd.allowCaching = ClassUtils.isCacheSafe(ClassUtils.getUserClass(existingBean), getBeanClassLoader()); } BeanWrapper bw = new BeanWrapperImpl(existingBean); @@ -349,7 +349,7 @@ public Object configureBean(Object existingBean, String beanName) throws BeansEx public Object createBean(Class beanClass, int autowireMode, boolean dependencyCheck) throws BeansException { // Use non-singleton bean definition, to avoid registering bean as dependent bean. RootBeanDefinition bd = new RootBeanDefinition(beanClass, autowireMode, dependencyCheck); - bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(SCOPE_PROTOTYPE); return createBean(beanClass.getName(), bd, null); } @@ -357,7 +357,7 @@ public Object createBean(Class beanClass, int autowireMode, boolean dependenc public Object autowire(Class beanClass, int autowireMode, boolean dependencyCheck) throws BeansException { // Use non-singleton bean definition, to avoid registering bean as dependent bean. final RootBeanDefinition bd = new RootBeanDefinition(beanClass, autowireMode, dependencyCheck); - bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(SCOPE_PROTOTYPE); if (bd.getResolvedAutowireMode() == AUTOWIRE_CONSTRUCTOR) { return autowireConstructor(beanClass.getName(), bd, null, null).getWrappedInstance(); } @@ -387,7 +387,7 @@ public void autowireBeanProperties(Object existingBean, int autowireMode, boolea // Use non-singleton bean definition, to avoid registering bean as dependent bean. RootBeanDefinition bd = new RootBeanDefinition(ClassUtils.getUserClass(existingBean), autowireMode, dependencyCheck); - bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(SCOPE_PROTOTYPE); BeanWrapper bw = new BeanWrapperImpl(existingBean); initBeanWrapper(bw); populateBean(bd.getBeanClass().getName(), bd, bw); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index c8305b30cfb0..d5e0f96096f6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -1357,7 +1357,7 @@ protected RootBeanDefinition getMergedBeanDefinition( // Set default singleton scope, if not configured before. if (!StringUtils.hasLength(mbd.getScope())) { - mbd.setScope(RootBeanDefinition.SCOPE_SINGLETON); + mbd.setScope(SCOPE_SINGLETON); } // A bean contained in a non-singleton bean cannot be a singleton itself. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java index 2e620dc11a00..3e0e744dcbb2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java @@ -30,6 +30,7 @@ import org.springframework.beans.PropertyAccessor; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.CannotLoadBeanClassException; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.ConstructorArgumentValues; import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.core.io.Resource; @@ -414,7 +415,7 @@ protected void registerBeanDefinition(String beanName, Map map, String pre String className = null; String parent = null; - String scope = GenericBeanDefinition.SCOPE_SINGLETON; + String scope = BeanDefinition.SCOPE_SINGLETON; boolean isAbstract = false; boolean lazyInit = false; @@ -442,8 +443,8 @@ else if (SCOPE_KEY.equals(property)) { else if (SINGLETON_KEY.equals(property)) { // Spring 1.2 style String val = StringUtils.trimWhitespace((String) entry.getValue()); - scope = ("".equals(val) || TRUE_VALUE.equals(val) ? GenericBeanDefinition.SCOPE_SINGLETON : - GenericBeanDefinition.SCOPE_PROTOTYPE); + scope = ("".equals(val) || TRUE_VALUE.equals(val) ? BeanDefinition.SCOPE_SINGLETON : + BeanDefinition.SCOPE_PROTOTYPE); } else if (LAZY_INIT_KEY.equals(property)) { String val = StringUtils.trimWhitespace((String) entry.getValue()); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java index b10dd72eba69..2c38c122e687 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java @@ -62,7 +62,6 @@ import org.springframework.beans.factory.config.BeanExpressionContext; import org.springframework.beans.factory.config.BeanExpressionResolver; import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConstructorArgumentValues; import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter; import org.springframework.beans.factory.config.PropertiesFactoryBean; @@ -367,7 +366,7 @@ void staticFactoryMethodFoundByNonEagerTypeMatching() { @Test void staticPrototypeFactoryMethodFoundByNonEagerTypeMatching() { RootBeanDefinition rbd = new RootBeanDefinition(TestBeanFactory.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); rbd.setFactoryMethodName("createTestBean"); lbf.registerBeanDefinition("x1", rbd); @@ -423,7 +422,7 @@ void nonStaticPrototypeFactoryMethodFoundByNonEagerTypeMatching() { RootBeanDefinition rbd = new RootBeanDefinition(); rbd.setFactoryBeanName("factory"); rbd.setFactoryMethodName("createTestBeanNonStatic"); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); lbf.registerBeanDefinition("x1", rbd); TestBeanFactory.initialized = false; @@ -1181,11 +1180,11 @@ void registerExistingSingletonWithAlreadyBound() { @Test void reregisterBeanDefinition() { RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class); - bd1.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd1.setScope(BeanDefinition.SCOPE_PROTOTYPE); lbf.registerBeanDefinition("testBean", bd1); assertThat(lbf.getBean("testBean")).isInstanceOf(TestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(NestedTestBean.class); - bd2.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd2.setScope(BeanDefinition.SCOPE_PROTOTYPE); lbf.registerBeanDefinition("testBean", bd2); assertThat(lbf.getBean("testBean")).isInstanceOf(NestedTestBean.class); } @@ -1642,7 +1641,7 @@ void getBeanByTypeInstanceDefinedInParent() { void getBeanByTypeInstanceWithAmbiguity() { RootBeanDefinition bd1 = createConstructorDependencyBeanDefinition(99); RootBeanDefinition bd2 = new RootBeanDefinition(ConstructorDependency.class); - bd2.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd2.setScope(BeanDefinition.SCOPE_PROTOTYPE); bd2.getConstructorArgumentValues().addGenericArgumentValue("43"); lbf.registerBeanDefinition("bd1", bd1); lbf.registerBeanDefinition("bd2", bd2); @@ -1777,10 +1776,10 @@ void beanProviderSerialization() throws Exception { @Test void getBeanWithArgsNotCreatedForFactoryBeanChecking() { RootBeanDefinition bd1 = new RootBeanDefinition(ConstructorDependency.class); - bd1.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd1.setScope(BeanDefinition.SCOPE_PROTOTYPE); lbf.registerBeanDefinition("bd1", bd1); RootBeanDefinition bd2 = new RootBeanDefinition(ConstructorDependencyFactoryBean.class); - bd2.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd2.setScope(BeanDefinition.SCOPE_PROTOTYPE); lbf.registerBeanDefinition("bd2", bd2); ConstructorDependency bean = lbf.getBean(ConstructorDependency.class, 42); @@ -1797,7 +1796,7 @@ void getBeanWithArgsNotCreatedForFactoryBeanChecking() { private RootBeanDefinition createConstructorDependencyBeanDefinition(int age) { RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependency.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bd.getConstructorArgumentValues().addGenericArgumentValue(age); return bd; } @@ -2283,7 +2282,7 @@ void prototypeFactoryBeanNotEagerlyCalledInCaseOfBeanClassName() { @Test void prototypeStringCreatedRepeatedly() { RootBeanDefinition stringDef = new RootBeanDefinition(String.class); - stringDef.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + stringDef.setScope(BeanDefinition.SCOPE_PROTOTYPE); stringDef.getConstructorArgumentValues().addGenericArgumentValue(new TypedStringValue("value")); lbf.registerBeanDefinition("string", stringDef); String val1 = lbf.getBean("string", String.class); @@ -2299,7 +2298,7 @@ void prototypeWithArrayConversionForConstructor() { list.add("myName"); list.add("myBeanName"); RootBeanDefinition bd = new RootBeanDefinition(DerivedTestBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bd.getConstructorArgumentValues().addGenericArgumentValue(list); lbf.registerBeanDefinition("test", bd); DerivedTestBean tb = (DerivedTestBean) lbf.getBean("test"); @@ -2317,7 +2316,7 @@ void prototypeWithArrayConversionForFactoryMethod() { list.add("myName"); list.add("myBeanName"); RootBeanDefinition bd = new RootBeanDefinition(DerivedTestBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bd.setFactoryMethodName("create"); bd.getConstructorArgumentValues().addGenericArgumentValue(list); lbf.registerBeanDefinition("test", bd); @@ -2335,7 +2334,7 @@ void prototypeWithArrayConversionForFactoryMethod() { void prototypeCreationIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); lbf.registerBeanDefinition("test", rbd); lbf.freezeConfiguration(); StopWatch sw = new StopWatch(); @@ -2353,7 +2352,7 @@ void prototypeCreationIsFastEnough() { void prototypeCreationWithDependencyCheckIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); rbd.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS); lbf.registerBeanDefinition("test", rbd); lbf.addBeanPostProcessor(new LifecycleBean.PostProcessor()); @@ -2373,7 +2372,7 @@ void prototypeCreationWithDependencyCheckIsFastEnough() { void prototypeCreationWithConstructorArgumentsIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); rbd.getConstructorArgumentValues().addGenericArgumentValue("juergen"); rbd.getConstructorArgumentValues().addGenericArgumentValue("99"); lbf.registerBeanDefinition("test", rbd); @@ -2394,7 +2393,7 @@ void prototypeCreationWithConstructorArgumentsIsFastEnough() { void prototypeCreationWithResolvedConstructorArgumentsIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); rbd.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference("spouse")); lbf.registerBeanDefinition("test", rbd); lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); @@ -2416,7 +2415,7 @@ void prototypeCreationWithResolvedConstructorArgumentsIsFastEnough() { void prototypeCreationWithPropertiesIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("name", "juergen"); rbd.getPropertyValues().add("age", "99"); lbf.registerBeanDefinition("test", rbd); @@ -2438,7 +2437,7 @@ void prototypeCreationWithPropertiesIsFastEnough() { void prototypeCreationWithResolvedPropertiesIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse")); lbf.registerBeanDefinition("test", rbd); lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); @@ -2555,7 +2554,7 @@ void destroyMethodOnInnerBean() { @Test void destroyMethodOnInnerBeanAsPrototype() { RootBeanDefinition innerBd = new RootBeanDefinition(BeanWithDestroyMethod.class); - innerBd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + innerBd.setScope(BeanDefinition.SCOPE_PROTOTYPE); innerBd.setDestroyMethodName("close"); RootBeanDefinition bd = new RootBeanDefinition(BeanWithDestroyMethod.class); bd.setDestroyMethodName("close"); @@ -2599,7 +2598,7 @@ private void findTypeOfPrototypeFactoryMethodOnBeanInstance(boolean singleton) { factoryMethodDefinitionWithProperties.setFactoryBeanName("factoryBeanInstance"); factoryMethodDefinitionWithProperties.setFactoryMethodName("create"); if (!singleton) { - factoryMethodDefinitionWithProperties.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + factoryMethodDefinitionWithProperties.setScope(BeanDefinition.SCOPE_PROTOTYPE); } lbf.registerBeanDefinition("fmWithProperties", factoryMethodDefinitionWithProperties); @@ -2607,7 +2606,7 @@ private void findTypeOfPrototypeFactoryMethodOnBeanInstance(boolean singleton) { factoryMethodDefinitionGeneric.setFactoryBeanName("factoryBeanInstance"); factoryMethodDefinitionGeneric.setFactoryMethodName("createGeneric"); if (!singleton) { - factoryMethodDefinitionGeneric.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + factoryMethodDefinitionGeneric.setScope(BeanDefinition.SCOPE_PROTOTYPE); } lbf.registerBeanDefinition("fmGeneric", factoryMethodDefinitionGeneric); @@ -2618,7 +2617,7 @@ private void findTypeOfPrototypeFactoryMethodOnBeanInstance(boolean singleton) { cvals.addGenericArgumentValue(expectedNameFromArgs); factoryMethodDefinitionWithArgs.setConstructorArgumentValues(cvals); if (!singleton) { - factoryMethodDefinitionWithArgs.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + factoryMethodDefinitionWithArgs.setScope(BeanDefinition.SCOPE_PROTOTYPE); } lbf.registerBeanDefinition("fmWithArgs", factoryMethodDefinitionWithArgs); @@ -2676,7 +2675,7 @@ void explicitScopeInheritanceForChildBeanDefinitions() { String theChildScope = "bonanza!"; RootBeanDefinition parent = new RootBeanDefinition(); - parent.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + parent.setScope(BeanDefinition.SCOPE_PROTOTYPE); AbstractBeanDefinition child = BeanDefinitionBuilder.childBeanDefinition("parent").getBeanDefinition(); child.setBeanClass(TestBean.class); @@ -2757,7 +2756,7 @@ public boolean postProcessAfterInstantiation(Object bean, String beanName) throw @SuppressWarnings({ "unchecked", "rawtypes" }) void initSecurityAwarePrototypeBean() { RootBeanDefinition bd = new RootBeanDefinition(TestSecuredBean.class); - bd.setScope(ConfigurableBeanFactory.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bd.setInitMethodName("init"); lbf.registerBeanDefinition("test", bd); final Subject subject = new Subject(); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java index ce0add1cee8a..8f650ffc3601 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java @@ -120,7 +120,7 @@ public void testIncompleteBeanDefinition() { @Test public void testResourceInjection() { RootBeanDefinition bd = new RootBeanDefinition(ResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -137,7 +137,7 @@ public void testResourceInjection() { @Test public void testExtendedResourceInjection() { RootBeanDefinition bd = new RootBeanDefinition(TypedExtendedResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -255,7 +255,7 @@ public void testExtendedResourceInjectionWithDefaultMethod() { public void testExtendedResourceInjectionWithAtRequired() { bf.addBeanPostProcessor(new RequiredAnnotationBeanPostProcessor()); RootBeanDefinition bd = new RootBeanDefinition(TypedExtendedResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -300,7 +300,7 @@ public void testOptionalResourceInjection() { @Test public void testOptionalCollectionResourceInjection() { RootBeanDefinition rbd = new RootBeanDefinition(OptionalCollectionResourceInjectionBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", rbd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -333,7 +333,7 @@ public void testOptionalCollectionResourceInjection() { @Test public void testOptionalCollectionResourceInjectionWithSingleElement() { RootBeanDefinition rbd = new RootBeanDefinition(OptionalCollectionResourceInjectionBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", rbd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -441,7 +441,7 @@ public void testAnnotationOrderedResourceInjection() { @Test public void testOrderedCollectionResourceInjection() { RootBeanDefinition rbd = new RootBeanDefinition(OptionalCollectionResourceInjectionBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", rbd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -476,7 +476,7 @@ public void testOrderedCollectionResourceInjection() { @Test public void testAnnotationOrderedCollectionResourceInjection() { RootBeanDefinition rbd = new RootBeanDefinition(OptionalCollectionResourceInjectionBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", rbd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -509,7 +509,7 @@ public void testAnnotationOrderedCollectionResourceInjection() { @Test public void testConstructorResourceInjection() { RootBeanDefinition bd = new RootBeanDefinition(ConstructorResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -536,7 +536,7 @@ public void testConstructorResourceInjection() { @Test public void testConstructorResourceInjectionWithNullFromFactoryBean() { RootBeanDefinition bd = new RootBeanDefinition(ConstructorResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -563,7 +563,7 @@ public void testConstructorResourceInjectionWithNullFromFactoryBean() { @Test public void testConstructorResourceInjectionWithNullFromFactoryMethod() { RootBeanDefinition bd = new RootBeanDefinition(ConstructorResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); RootBeanDefinition tb = new RootBeanDefinition(NullFactoryMethods.class); tb.setFactoryMethodName("createTestBean"); @@ -818,7 +818,7 @@ public void testConstructorResourceInjectionWithMultipleCandidatesAndDefaultFall @Test public void testConstructorInjectionWithMap() { RootBeanDefinition bd = new RootBeanDefinition(MapConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb1 = new TestBean("tb1"); bf.registerSingleton("testBean1", tb1); @@ -840,7 +840,7 @@ public void testConstructorInjectionWithMap() { @Test public void testFieldInjectionWithMap() { RootBeanDefinition bd = new RootBeanDefinition(MapFieldInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb1 = new TestBean("tb1"); TestBean tb2 = new TestBean("tb2"); @@ -865,7 +865,7 @@ public void testFieldInjectionWithMap() { @Test public void testMethodInjectionWithMap() { RootBeanDefinition bd = new RootBeanDefinition(MapMethodInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -921,7 +921,7 @@ public void testMethodInjectionWithMapAndNoMatches() { @Test public void testConstructorInjectionWithTypedMapAsBean() { RootBeanDefinition bd = new RootBeanDefinition(MapConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); MyTestBeanMap tbm = new MyTestBeanMap(); tbm.put("testBean1", new TestBean("tb1")); @@ -938,7 +938,7 @@ public void testConstructorInjectionWithTypedMapAsBean() { @Test public void testConstructorInjectionWithPlainMapAsBean() { RootBeanDefinition bd = new RootBeanDefinition(MapConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); RootBeanDefinition tbm = new RootBeanDefinition(CollectionFactoryMethods.class); tbm.setUniqueFactoryMethodName("testBeanMap"); @@ -954,7 +954,7 @@ public void testConstructorInjectionWithPlainMapAsBean() { @Test public void testConstructorInjectionWithCustomMapAsBean() { RootBeanDefinition bd = new RootBeanDefinition(CustomMapConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); RootBeanDefinition tbm = new RootBeanDefinition(CustomCollectionFactoryMethods.class); tbm.setUniqueFactoryMethodName("testBeanMap"); @@ -971,7 +971,7 @@ public void testConstructorInjectionWithCustomMapAsBean() { @Test public void testConstructorInjectionWithPlainHashMapAsBean() { RootBeanDefinition bd = new RootBeanDefinition(QualifiedMapConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); bf.registerBeanDefinition("myTestBeanMap", new RootBeanDefinition(HashMap.class)); @@ -984,7 +984,7 @@ public void testConstructorInjectionWithPlainHashMapAsBean() { @Test public void testConstructorInjectionWithTypedSetAsBean() { RootBeanDefinition bd = new RootBeanDefinition(SetConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); MyTestBeanSet tbs = new MyTestBeanSet(); tbs.add(new TestBean("tb1")); @@ -1001,7 +1001,7 @@ public void testConstructorInjectionWithTypedSetAsBean() { @Test public void testConstructorInjectionWithPlainSetAsBean() { RootBeanDefinition bd = new RootBeanDefinition(SetConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); RootBeanDefinition tbs = new RootBeanDefinition(CollectionFactoryMethods.class); tbs.setUniqueFactoryMethodName("testBeanSet"); @@ -1017,7 +1017,7 @@ public void testConstructorInjectionWithPlainSetAsBean() { @Test public void testConstructorInjectionWithCustomSetAsBean() { RootBeanDefinition bd = new RootBeanDefinition(CustomSetConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); RootBeanDefinition tbs = new RootBeanDefinition(CustomCollectionFactoryMethods.class); tbs.setUniqueFactoryMethodName("testBeanSet"); @@ -1143,7 +1143,7 @@ public void testObjectFactorySerialization() throws Exception { public void testObjectProviderInjectionWithPrototype() { bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectProviderInjectionBean.class)); RootBeanDefinition tbd = new RootBeanDefinition(TestBean.class); - tbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + tbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("testBean", tbd); ObjectProviderInjectionBean bean = (ObjectProviderInjectionBean) bf.getBean("annotatedBean"); @@ -1515,7 +1515,7 @@ public void testBeanAutowiredWithFactoryBean() { @Test public void testGenericsBasedFieldInjection() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryFieldInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); String sv = "X"; bf.registerSingleton("stringValue", sv); @@ -1560,7 +1560,7 @@ public void testGenericsBasedFieldInjection() { @Test public void testGenericsBasedFieldInjectionWithSubstitutedVariables() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryFieldInjectionBeanWithSubstitutedVariables.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); String sv = "X"; bf.registerSingleton("stringValue", sv); @@ -1605,7 +1605,7 @@ public void testGenericsBasedFieldInjectionWithSubstitutedVariables() { @Test public void testGenericsBasedFieldInjectionWithQualifiers() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryFieldInjectionBeanWithQualifiers.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); StringRepository sr = new StringRepository(); bf.registerSingleton("stringRepo", sr); @@ -1632,7 +1632,7 @@ public void testGenericsBasedFieldInjectionWithQualifiers() { @Test public void testGenericsBasedFieldInjectionWithMocks() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryFieldInjectionBeanWithQualifiers.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); RootBeanDefinition rbd = new RootBeanDefinition(MocksControl.class); @@ -1671,7 +1671,7 @@ public void testGenericsBasedFieldInjectionWithMocks() { @Test public void testGenericsBasedFieldInjectionWithSimpleMatch() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryFieldInjectionBeanWithSimpleMatch.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); bf.registerSingleton("repo", new StringRepository()); @@ -1699,7 +1699,7 @@ public void testGenericsBasedFieldInjectionWithSimpleMatch() { @Test public void testGenericsBasedFactoryBeanInjectionWithBeanDefinition() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryFactoryBeanInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); bf.registerBeanDefinition("repoFactoryBean", new RootBeanDefinition(RepositoryFactoryBean.class)); @@ -1711,7 +1711,7 @@ public void testGenericsBasedFactoryBeanInjectionWithBeanDefinition() { @Test public void testGenericsBasedFactoryBeanInjectionWithSingletonBean() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryFactoryBeanInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); bf.registerSingleton("repoFactoryBean", new RepositoryFactoryBean<>()); @@ -1723,7 +1723,7 @@ public void testGenericsBasedFactoryBeanInjectionWithSingletonBean() { @Test public void testGenericsBasedFieldInjectionWithSimpleMatchAndMock() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryFieldInjectionBeanWithSimpleMatch.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); RootBeanDefinition rbd = new RootBeanDefinition(MocksControl.class); @@ -1755,7 +1755,7 @@ public void testGenericsBasedFieldInjectionWithSimpleMatchAndMock() { @Test public void testGenericsBasedFieldInjectionWithSimpleMatchAndMockito() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryFieldInjectionBeanWithSimpleMatch.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); RootBeanDefinition rbd = new RootBeanDefinition(); @@ -1786,7 +1786,7 @@ public void testGenericsBasedFieldInjectionWithSimpleMatchAndMockito() { @Test public void testGenericsBasedMethodInjection() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryMethodInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); String sv = "X"; bf.registerSingleton("stringValue", sv); @@ -1831,7 +1831,7 @@ public void testGenericsBasedMethodInjection() { @Test public void testGenericsBasedMethodInjectionWithSubstitutedVariables() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryMethodInjectionBeanWithSubstitutedVariables.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); String sv = "X"; bf.registerSingleton("stringValue", sv); @@ -1876,7 +1876,7 @@ public void testGenericsBasedMethodInjectionWithSubstitutedVariables() { @Test public void testGenericsBasedConstructorInjection() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); StringRepository sr = new StringRepository(); bf.registerSingleton("stringRepo", sr); @@ -1904,7 +1904,7 @@ public void testGenericsBasedConstructorInjection() { @SuppressWarnings("rawtypes") public void testGenericsBasedConstructorInjectionWithNonTypedTarget() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); GenericRepository gr = new GenericRepository(); bf.registerSingleton("genericRepo", gr); @@ -1929,7 +1929,7 @@ public void testGenericsBasedConstructorInjectionWithNonTypedTarget() { @Test public void testGenericsBasedConstructorInjectionWithNonGenericTarget() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); SimpleRepository ngr = new SimpleRepository(); bf.registerSingleton("simpleRepo", ngr); @@ -1955,7 +1955,7 @@ public void testGenericsBasedConstructorInjectionWithNonGenericTarget() { @SuppressWarnings("rawtypes") public void testGenericsBasedConstructorInjectionWithMixedTargets() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); StringRepository sr = new StringRepository(); bf.registerSingleton("stringRepo", sr); @@ -1982,7 +1982,7 @@ public void testGenericsBasedConstructorInjectionWithMixedTargets() { @Test public void testGenericsBasedConstructorInjectionWithMixedTargetsIncludingNonGeneric() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); StringRepository sr = new StringRepository(); bf.registerSingleton("stringRepo", sr); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java index af5e0258e6b2..8f498f3889e9 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java @@ -94,7 +94,7 @@ public void testIncompleteBeanDefinition() { @Test public void testResourceInjection() { RootBeanDefinition bd = new RootBeanDefinition(ResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -111,7 +111,7 @@ public void testResourceInjection() { @Test public void testExtendedResourceInjection() { RootBeanDefinition bd = new RootBeanDefinition(TypedExtendedResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -160,7 +160,7 @@ public void testExtendedResourceInjectionWithOverriding() { public void testExtendedResourceInjectionWithAtRequired() { bf.addBeanPostProcessor(new RequiredAnnotationBeanPostProcessor()); RootBeanDefinition bd = new RootBeanDefinition(TypedExtendedResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -179,7 +179,7 @@ public void testExtendedResourceInjectionWithAtRequired() { @Test public void testConstructorResourceInjection() { RootBeanDefinition bd = new RootBeanDefinition(ConstructorResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); @@ -236,7 +236,7 @@ public void testConstructorResourceInjectionWithMultipleCandidatesAndFallback() @Test public void testConstructorInjectionWithMap() { RootBeanDefinition bd = new RootBeanDefinition(MapConstructorInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb1 = new TestBean(); TestBean tb2 = new TestBean(); @@ -261,7 +261,7 @@ public void testConstructorInjectionWithMap() { @Test public void testFieldInjectionWithMap() { RootBeanDefinition bd = new RootBeanDefinition(MapFieldInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb1 = new TestBean(); TestBean tb2 = new TestBean(); @@ -286,7 +286,7 @@ public void testFieldInjectionWithMap() { @Test public void testMethodInjectionWithMap() { RootBeanDefinition bd = new RootBeanDefinition(MapMethodInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); TestBean tb = new TestBean(); bf.registerSingleton("testBean", tb); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java index 388b4a8bfa80..a2bf1a162627 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.tests.sample.beans.TestBean; @@ -44,7 +45,7 @@ public void setup() { beanFactory.registerBeanDefinition("abstractBean", new RootBeanDefinition(AbstractBean.class)); beanFactory.registerBeanDefinition("beanConsumer", new RootBeanDefinition(BeanConsumer.class)); RootBeanDefinition tbd = new RootBeanDefinition(TestBean.class); - tbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + tbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); beanFactory.registerBeanDefinition("testBean", tbd); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java index 8561abef9f87..df5071cf632e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java @@ -45,7 +45,7 @@ import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.SmartFactoryBean; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.SecurityContextProvider; @@ -442,7 +442,7 @@ public void testInitSecurityAwarePrototypeBean() { final DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); BeanDefinitionBuilder bdb = BeanDefinitionBuilder .genericBeanDefinition(NonPrivilegedBean.class).setScope( - ConfigurableBeanFactory.SCOPE_PROTOTYPE) + BeanDefinition.SCOPE_PROTOTYPE) .setInitMethodName("init").setDestroyMethodName("destroy") .addConstructorArgValue("user1"); lbf.registerBeanDefinition("test", bdb.getBeanDefinition()); diff --git a/spring-context/src/main/java/org/springframework/context/support/StaticApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/StaticApplicationContext.java index 4f1ba68db88f..8559b368170c 100644 --- a/spring-context/src/main/java/org/springframework/context/support/StaticApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/StaticApplicationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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. @@ -20,6 +20,7 @@ import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.context.ApplicationContext; import org.springframework.lang.Nullable; @@ -115,7 +116,7 @@ public void registerSingleton(String name, Class clazz, MutablePropertyValues */ public void registerPrototype(String name, Class clazz) throws BeansException { GenericBeanDefinition bd = new GenericBeanDefinition(); - bd.setScope(GenericBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bd.setBeanClass(clazz); getDefaultListableBeanFactory().registerBeanDefinition(name, bd); } @@ -127,7 +128,7 @@ public void registerPrototype(String name, Class clazz) throws BeansException */ public void registerPrototype(String name, Class clazz, MutablePropertyValues pvs) throws BeansException { GenericBeanDefinition bd = new GenericBeanDefinition(); - bd.setScope(GenericBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bd.setBeanClass(clazz); bd.setPropertyValues(pvs); getDefaultListableBeanFactory().registerBeanDefinition(name, bd); diff --git a/spring-context/src/test/java/example/scannable_scoped/CustomScopeAnnotationBean.java b/spring-context/src/test/java/example/scannable_scoped/CustomScopeAnnotationBean.java index fee1cbe9d736..beb55311b907 100644 --- a/spring-context/src/test/java/example/scannable_scoped/CustomScopeAnnotationBean.java +++ b/spring-context/src/test/java/example/scannable_scoped/CustomScopeAnnotationBean.java @@ -16,10 +16,10 @@ package example.scannable_scoped; -import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.stereotype.Component; @Component -@MyScope(BeanDefinition.SCOPE_PROTOTYPE) +@MyScope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class CustomScopeAnnotationBean { } diff --git a/spring-context/src/test/java/example/scannable_scoped/MyScope.java b/spring-context/src/test/java/example/scannable_scoped/MyScope.java index b21fc4d0e11d..8f58d6c65d41 100644 --- a/spring-context/src/test/java/example/scannable_scoped/MyScope.java +++ b/spring-context/src/test/java/example/scannable_scoped/MyScope.java @@ -19,11 +19,11 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.ScopedProxyMode; @Retention(RetentionPolicy.RUNTIME) public @interface MyScope { - String value() default BeanDefinition.SCOPE_SINGLETON; + String value() default ConfigurableBeanFactory.SCOPE_SINGLETON; ScopedProxyMode proxyMode() default ScopedProxyMode.DEFAULT; } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java index d109cc93b4cc..db76843b48a7 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; @@ -63,7 +64,7 @@ public void prototypeCreationWithResourcePropertiesIsFastEnough() { GenericApplicationContext ctx = createContext(); RootBeanDefinition rbd = new RootBeanDefinition(ResourceAnnotatedTestBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); @@ -75,7 +76,7 @@ public void prototypeCreationWithOverriddenResourcePropertiesIsFastEnough() { GenericApplicationContext ctx = createContext(); RootBeanDefinition rbd = new RootBeanDefinition(ResourceAnnotatedTestBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse")); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); @@ -88,7 +89,7 @@ public void prototypeCreationWithAutowiredPropertiesIsFastEnough() { GenericApplicationContext ctx = createContext(); RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); @@ -100,7 +101,7 @@ public void prototypeCreationWithOverriddenAutowiredPropertiesIsFastEnough() { GenericApplicationContext ctx = createContext(); RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse")); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java index e26c281ae3b9..22a2d8f21968 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java @@ -176,7 +176,7 @@ public void testSimpleScanWithDefaultFiltersAndOverriddenEqualNamedBean() { public void testSimpleScanWithDefaultFiltersAndOverriddenCompatibleNamedBean() { GenericApplicationContext context = new GenericApplicationContext(); RootBeanDefinition bd = new RootBeanDefinition(NamedStubDao.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); context.registerBeanDefinition("myNamedDao", bd); int initialBeanCount = context.getBeanDefinitionCount(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java index b5f61029539c..cacdc161af96 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java @@ -45,6 +45,7 @@ import org.springframework.beans.factory.annotation.Lookup; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.BeanDefinitionRegistry; @@ -482,7 +483,7 @@ public void genericsBasedInjection() { bpp.setBeanFactory(beanFactory); beanFactory.addBeanPostProcessor(bpp); RootBeanDefinition bd = new RootBeanDefinition(RepositoryInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); beanFactory.registerBeanDefinition("annotatedBean", bd); beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(RepositoryConfiguration.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); @@ -499,7 +500,7 @@ public void genericsBasedInjectionWithScoped() { bpp.setBeanFactory(beanFactory); beanFactory.addBeanPostProcessor(bpp); RootBeanDefinition bd = new RootBeanDefinition(RepositoryInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); beanFactory.registerBeanDefinition("annotatedBean", bd); beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(ScopedRepositoryConfiguration.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); @@ -516,7 +517,7 @@ public void genericsBasedInjectionWithScopedProxy() { bpp.setBeanFactory(beanFactory); beanFactory.addBeanPostProcessor(bpp); RootBeanDefinition bd = new RootBeanDefinition(RepositoryInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); beanFactory.registerBeanDefinition("annotatedBean", bd); beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(ScopedProxyRepositoryConfiguration.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); @@ -536,7 +537,7 @@ public void genericsBasedInjectionWithScopedProxyUsingAsm() { bpp.setBeanFactory(beanFactory); beanFactory.addBeanPostProcessor(bpp); RootBeanDefinition bd = new RootBeanDefinition(RepositoryInjectionBean.class.getName()); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); beanFactory.registerBeanDefinition("annotatedBean", bd); beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(ScopedProxyRepositoryConfiguration.class.getName())); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); @@ -556,7 +557,7 @@ public void genericsBasedInjectionWithImplTypeAtInjectionPoint() { bpp.setBeanFactory(beanFactory); beanFactory.addBeanPostProcessor(bpp); RootBeanDefinition bd = new RootBeanDefinition(SpecificRepositoryInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); beanFactory.registerBeanDefinition("annotatedBean", bd); beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(SpecificRepositoryConfiguration.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); @@ -573,7 +574,7 @@ public void genericsBasedInjectionWithFactoryBean() { bpp.setBeanFactory(beanFactory); beanFactory.addBeanPostProcessor(bpp); RootBeanDefinition bd = new RootBeanDefinition(RepositoryFactoryBeanInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); beanFactory.registerBeanDefinition("annotatedBean", bd); beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(RepositoryFactoryBeanConfiguration.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java index ca79a4c60bc1..d68d8e48606f 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.tests.sample.beans.TestBean; @@ -41,7 +42,7 @@ public class LazyAutowiredAnnotationBeanPostProcessorTests { private void doTestLazyResourceInjection(Class annotatedBeanClass) { AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(); RootBeanDefinition abd = new RootBeanDefinition(annotatedBeanClass); - abd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + abd.setScope(BeanDefinition.SCOPE_PROTOTYPE); ac.registerBeanDefinition("annotatedBean", abd); RootBeanDefinition tbd = new RootBeanDefinition(TestBean.class); tbd.setLazyInit(true); @@ -64,7 +65,7 @@ public void testLazyResourceInjectionWithField() { AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(); RootBeanDefinition abd = new RootBeanDefinition(FieldResourceInjectionBean.class); - abd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + abd.setScope(BeanDefinition.SCOPE_PROTOTYPE); ac.registerBeanDefinition("annotatedBean", abd); RootBeanDefinition tbd = new RootBeanDefinition(TestBean.class); tbd.setLazyInit(true); @@ -124,7 +125,7 @@ public void testLazyResourceInjectionWithNonExistingTarget() { bpp.setBeanFactory(bf); bf.addBeanPostProcessor(bpp); RootBeanDefinition bd = new RootBeanDefinition(FieldResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); FieldResourceInjectionBean bean = (FieldResourceInjectionBean) bf.getBean("annotatedBean"); @@ -141,7 +142,7 @@ public void testLazyOptionalResourceInjectionWithNonExistingTarget() { bpp.setBeanFactory(bf); bf.addBeanPostProcessor(bpp); RootBeanDefinition bd = new RootBeanDefinition(OptionalFieldResourceInjectionBean.class); - bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", bd); OptionalFieldResourceInjectionBean bean = (OptionalFieldResourceInjectionBean) bf.getBean("annotatedBean"); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr12526Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr12526Tests.java index 17260535e405..8c069e16add0 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr12526Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr12526Tests.java @@ -26,17 +26,17 @@ import org.springframework.context.annotation.Scope; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE; -import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_SINGLETON; +import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE; +import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_SINGLETON; /** * @author Marcin Piela * @author Juergen Hoeller */ -public class Spr12526Tests { +class Spr12526Tests { @Test - public void testInjection() { + void testInjection() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(TestContext.class); CustomCondition condition = ctx.getBean(CustomCondition.class); @@ -47,33 +47,33 @@ public void testInjection() { condition.setCondition(false); SecondService secondService = (SecondService) ctx.getBean(Service.class); assertThat(secondService.getDependency()).as("SecondService.dependency is null").isNotNull(); + + ctx.close(); } @Configuration - public static class TestContext { + static class TestContext { @Bean @Scope(SCOPE_SINGLETON) - public CustomCondition condition() { + CustomCondition condition() { return new CustomCondition(); } - @Bean @Scope(SCOPE_PROTOTYPE) - public Service service(CustomCondition condition) { + Service service(CustomCondition condition) { return (condition.check() ? new FirstService() : new SecondService()); } @Bean - public DependencyOne dependencyOne() { + DependencyOne dependencyOne() { return new DependencyOne(); } - @Bean - public DependencyTwo dependencyTwo() { + DependencyTwo dependencyTwo() { return new DependencyTwo(); } } diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java index e0e5f7d5a5a8..1366cb6bdde1 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java @@ -27,6 +27,7 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.RootBeanDefinition; @@ -355,7 +356,7 @@ public void listenersInApplicationContextWithNestedChild() { public void nonSingletonListenerInApplicationContext() { StaticApplicationContext context = new StaticApplicationContext(); RootBeanDefinition listener = new RootBeanDefinition(MyNonSingletonListener.class); - listener.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + listener.setScope(BeanDefinition.SCOPE_PROTOTYPE); context.registerBeanDefinition("listener", listener); context.refresh(); diff --git a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java index 441a6fdc0a39..adf27cd2db63 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java @@ -36,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.Scope; import org.springframework.beans.factory.config.TypedStringValue; import org.springframework.beans.factory.support.AutowireCandidateQualifier; @@ -219,7 +220,7 @@ void prototypeCreationReevaluatesExpressions() { cs.addConverter(String.class, String.class, String::trim); ac.getBeanFactory().registerSingleton(GenericApplicationContext.CONVERSION_SERVICE_BEAN_NAME, cs); RootBeanDefinition rbd = new RootBeanDefinition(PrototypeTestBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("country", "#{systemProperties.country}"); rbd.getPropertyValues().add("country2", new TypedStringValue("-#{systemProperties.country}-")); ac.registerBeanDefinition("test", rbd); @@ -252,7 +253,7 @@ void prototypeCreationIsFastEnough() { Assume.notLogging(factoryLog); GenericApplicationContext ac = new GenericApplicationContext(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); - rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); rbd.getConstructorArgumentValues().addGenericArgumentValue("#{systemProperties.name}"); rbd.getPropertyValues().add("country", "#{systemProperties.country}"); ac.registerBeanDefinition("test", rbd); diff --git a/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java index 8cd441aa88de..e82592da680b 100644 --- a/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.NoUniqueBeanDefinitionException; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -64,7 +65,7 @@ public void withSingletonSupplier() { public void withScopedSupplier() { GenericApplicationContext ac = new GenericApplicationContext(); ac.registerBeanDefinition("testBean", - new RootBeanDefinition(String.class, RootBeanDefinition.SCOPE_PROTOTYPE, ac::toString)); + new RootBeanDefinition(String.class, BeanDefinition.SCOPE_PROTOTYPE, ac::toString)); ac.refresh(); assertThat(ac.getBean("testBean")).isNotSameAs(ac.getBean("testBean")); diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java index bf9d831ee6a8..9fb8494cd436 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java @@ -36,6 +36,7 @@ import org.springframework.aop.support.DefaultIntroductionAdvisor; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; @@ -383,7 +384,7 @@ public void asyncPrototypeClassListener() throws Exception { listenerConstructed = 0; GenericApplicationContext context = new GenericApplicationContext(); RootBeanDefinition listenerDef = new RootBeanDefinition(AsyncClassListener.class); - listenerDef.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); + listenerDef.setScope(BeanDefinition.SCOPE_PROTOTYPE); context.registerBeanDefinition("asyncTest", listenerDef); context.registerBeanDefinition("autoProxyCreator", new RootBeanDefinition(DefaultAdvisorAutoProxyCreator.class)); context.registerBeanDefinition("asyncAdvisor", new RootBeanDefinition(AsyncAnnotationAdvisor.class)); From 88fd90c3574ed01988059bfc3247f6620d233807 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 24 Nov 2019 19:58:19 +0100 Subject: [PATCH 0106/2315] Upgrade to Tomcat 9.0.29, Jetty 9.4.24, RxJava 2.2.15 --- build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 8122d0e95261..3072f866095f 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ configure(allprojects) { project -> mavenBom "io.netty:netty-bom:4.1.43.Final" mavenBom "io.projectreactor:reactor-bom:Dysprosium-BUILD-SNAPSHOT" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" - mavenBom "org.eclipse.jetty:jetty-bom:9.4.23.v20191118" + mavenBom "org.eclipse.jetty:jetty-bom:9.4.24.v20191120" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.60" mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.2" mavenBom "org.junit:junit-bom:5.5.2" @@ -78,7 +78,7 @@ configure(allprojects) { project -> dependency "io.reactivex:rxjava:1.3.8" dependency "io.reactivex:rxjava-reactive-streams:1.2.1" - dependency "io.reactivex.rxjava2:rxjava:2.2.14" + dependency "io.reactivex.rxjava2:rxjava:2.2.15" dependency "com.caucho:hessian:4.0.62" dependency "com.fasterxml:aalto-xml:1.2.2" @@ -137,14 +137,14 @@ configure(allprojects) { project -> dependency "org.webjars:webjars-locator-core:0.43" dependency "org.webjars:underscorejs:1.8.3" - dependencySet(group: 'org.apache.tomcat', version: '9.0.27') { + dependencySet(group: 'org.apache.tomcat', version: '9.0.29') { entry 'tomcat-util' entry('tomcat-websocket') { exclude group: "org.apache.tomcat", name: "tomcat-websocket-api" exclude group: "org.apache.tomcat", name: "tomcat-servlet-api" } } - dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.27') { + dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.29') { entry 'tomcat-embed-core' entry 'tomcat-embed-websocket' } From b234c77b67a44c3c28e2679f7031d9a401fc159a Mon Sep 17 00:00:00 2001 From: Christoph Dreis Date: Fri, 22 Nov 2019 20:01:49 +0100 Subject: [PATCH 0107/2315] Add missing verify() in EncoderHttpMessageWriterTests Closes gh-24062 --- .../http/codec/EncoderHttpMessageWriterTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java index 07bb4de0e2bf..5fbc2866d82f 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java @@ -180,7 +180,7 @@ void emptyBodyWritten() { configureEncoder(MimeTypeUtils.TEXT_PLAIN); HttpMessageWriter writer = new EncoderHttpMessageWriter<>(this.encoder); writer.write(Mono.empty(), forClass(String.class), TEXT_PLAIN, this.response, NO_HINTS).block(); - StepVerifier.create(this.response.getBody()).expectComplete(); + StepVerifier.create(this.response.getBody()).verifyComplete(); assertThat(this.response.getHeaders().getContentLength()).isEqualTo(0); } From 6ed1b5835b84bab0fda48956cdad143080c063ae Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 25 Nov 2019 11:47:41 +0000 Subject: [PATCH 0108/2315] Separate step for retrieve in RSocketRequester Closes gh-24073 --- .../messaging/rsocket/RSocketRequester.java | 63 +++++++++++-------- .../rsocket/RSocketRequesterExtensions.kt | 6 +- .../rsocket/DefaultRSocketRequesterTests.java | 5 +- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java index d2981ef41b76..320b45f3510b 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java @@ -238,9 +238,9 @@ interface Builder { } /** - * Spec for providing input data for an RSocket request and triggering the exchange. + * Spec to declare the input for an RSocket request. */ - interface RequestSpec extends MetadataSpec { + interface RequestSpec extends MetadataSpec, RetrieveSpec { /** * Append additional metadata entries through a {@code Consumer}. @@ -262,7 +262,7 @@ interface RequestSpec extends MetadataSpec { * @param data the Object value for the payload data * @return spec to declare the expected response */ - RequestSpec data(Object data); + RetrieveSpec data(Object data); /** * Variant of {@link #data(Object)} that also accepts a hint for the @@ -274,7 +274,7 @@ interface RequestSpec extends MetadataSpec { * @param elementClass the type of values to be produced * @return spec to declare the expected response */ - RequestSpec data(Object producer, Class elementClass); + RetrieveSpec data(Object producer, Class elementClass); /** * Variant of {@link #data(Object, Class)} for when the type hint has @@ -285,7 +285,38 @@ interface RequestSpec extends MetadataSpec { * @param elementTypeRef the type of values to be produced * @return spec to declare the expected response */ - RequestSpec data(Object producer, ParameterizedTypeReference elementTypeRef); + RetrieveSpec data(Object producer, ParameterizedTypeReference elementTypeRef); + } + + + /** + * Spec for providing additional composite metadata entries. + * + * @param a self reference to the spec type + */ + interface MetadataSpec> { + + /** + * Use this to append additional metadata entries when using composite + * metadata. An {@link IllegalArgumentException} is raised if this + * method is used when not using composite metadata. + * The metadata value be a concrete value or any producer of a single + * value that can be adapted to a {@link Publisher} via + * {@link ReactiveAdapterRegistry}. + * @param metadata an Object to be encoded with a suitable + * {@link org.springframework.core.codec.Encoder Encoder}, or a + * {@link org.springframework.core.io.buffer.DataBuffer DataBuffer} + * @param mimeType the mime type that describes the metadata + */ + S metadata(Object metadata, MimeType mimeType); + } + + + /** + * Spec to declare the expected output for an RSocket request. + * @since 5.2.2 + */ + interface RetrieveSpec { /** * Perform a {@link RSocket#fireAndForget fireAndForget}. @@ -330,26 +361,4 @@ interface RequestSpec extends MetadataSpec { Flux retrieveFlux(ParameterizedTypeReference dataTypeRef); } - /** - * Spec for specifying the metadata. - * - * @param a self reference to the spec type - */ - interface MetadataSpec> { - - /** - * Use this to append additional metadata entries when using composite - * metadata. An {@link IllegalArgumentException} is raised if this - * method is used when not using composite metadata. - * The metadata value be a concrete value or any producer of a single - * value that can be adapted to a {@link Publisher} via - * {@link ReactiveAdapterRegistry}. - * @param metadata an Object to be encoded with a suitable - * {@link org.springframework.core.codec.Encoder Encoder}, or a - * {@link org.springframework.core.io.buffer.DataBuffer DataBuffer} - * @param mimeType the mime type that describes the metadata - */ - S metadata(Object metadata, MimeType mimeType); - } - } diff --git a/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt b/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt index a51a69e55252..63029eb6110e 100644 --- a/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt +++ b/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt @@ -65,7 +65,7 @@ suspend fun RSocketRequester.Builder.connectWebSocketAndAwait(uri: URI): RSocket * @author Sebastien Deleuze * @since 5.2 */ -inline fun RSocketRequester.RequestSpec.dataWithType(producer: Any): RSocketRequester.RequestSpec = +inline fun RSocketRequester.RequestSpec.dataWithType(producer: Any): RSocketRequester.RetrieveSpec = data(producer, object : ParameterizedTypeReference() {}) /** @@ -77,7 +77,7 @@ inline fun RSocketRequester.RequestSpec.dataWithType(producer: * @author Sebastien Deleuze * @since 5.2 */ -inline fun RSocketRequester.RequestSpec.dataWithType(publisher: Publisher): RSocketRequester.RequestSpec = +inline fun RSocketRequester.RequestSpec.dataWithType(publisher: Publisher): RSocketRequester.RetrieveSpec = data(publisher, object : ParameterizedTypeReference() {}) /** @@ -89,7 +89,7 @@ inline fun RSocketRequester.RequestSpec.dataWithType(publisher * @author Sebastien Deleuze * @since 5.2 */ -inline fun RSocketRequester.RequestSpec.dataWithType(flow: Flow): RSocketRequester.RequestSpec = +inline fun RSocketRequester.RequestSpec.dataWithType(flow: Flow): RSocketRequester.RetrieveSpec = data(flow, object : ParameterizedTypeReference() {}) diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java index 532e1d76b31e..7392d901eeb3 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java @@ -40,6 +40,7 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.lang.Nullable; import org.springframework.messaging.rsocket.RSocketRequester.RequestSpec; +import org.springframework.messaging.rsocket.RSocketRequester.RetrieveSpec; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; @@ -90,7 +91,7 @@ public void sendMono() { testSendMono(spec -> spec.data(Mono.delay(MILLIS_10).then(), Void.class), ""); } - private void testSendMono(Function mapper, String expectedValue) { + private void testSendMono(Function mapper, String expectedValue) { mapper.apply(this.requester.route("toA")).send().block(Duration.ofSeconds(5)); assertThat(this.rsocket.getSavedMethodName()).isEqualTo("fireAndForget"); @@ -114,7 +115,7 @@ public void sendFlux() { testSendFlux(spec -> spec.data(stringFlux.cast(Object.class), Object.class), values); } - private void testSendFlux(Function mapper, String... expectedValues) { + private void testSendFlux(Function mapper, String... expectedValues) { this.rsocket.reset(); mapper.apply(this.requester.route("toA")).retrieveFlux(String.class).blockLast(Duration.ofSeconds(5)); From a79eaded5d25b43c8db5c60711f0ea0c4f6331ac Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 25 Nov 2019 11:37:55 +0100 Subject: [PATCH 0109/2315] Javadoc --- .../springframework/web/reactive/function/BodyInserters.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java index 0d9004d09961..56f1b41d78a6 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java @@ -112,7 +112,7 @@ public static BodyInserter fromValue(T body) { * {@link #fromProducer(Object, Class)} should be used. * @see #fromPublisher(Publisher, Class) * @see #fromProducer(Object, Class) - * @deprecated As of Spring Framework 5.2, in favor of {@link #fromValue(T)}. + * @deprecated As of Spring Framework 5.2, in favor of {@link #fromValue(Object)} */ @Deprecated public static BodyInserter fromObject(T body) { From 5f3c7ca559ac5f7d4d37917d568001579b596f2b Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 25 Nov 2019 11:40:53 +0100 Subject: [PATCH 0110/2315] Fix NullPointerException in Jackson2SmileDecoder Fix uncommon case in Jackson2SmileDecoder, where a null token, incicating a document separator in streaming mode, is followed by NOT_AVAILABLE. Closes gh-24009 --- .../http/codec/json/Jackson2Tokenizer.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java index 1846d3e3bf3f..438ca49f7939 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java @@ -122,13 +122,18 @@ private Flux endOfInput() { private List parseTokenBufferFlux() throws IOException { List result = new ArrayList<>(); - while (true) { + // SPR-16151: Smile data format uses null to separate documents + boolean previousNull = false; + while (!this.parser.isClosed()) { JsonToken token = this.parser.nextToken(); - // SPR-16151: Smile data format uses null to separate documents if (token == JsonToken.NOT_AVAILABLE || - (token == null && (token = this.parser.nextToken()) == null)) { + token == null && previousNull) { break; } + else if (token == null ) { // !previousNull + previousNull = true; + continue; + } updateDepth(token); if (!this.tokenizeArrayElements) { processTokenNormal(token, result); @@ -169,6 +174,9 @@ private void processTokenNormal(JsonToken token, List result) throw private void processTokenArray(JsonToken token, List result) throws IOException { if (!isTopLevelArrayToken(token)) { + if (!this.parser.hasCurrentToken()) { + System.out.println("NO CURRENT TOKEN: " + token); + } this.tokenBuffer.copyCurrentEvent(this.parser); } From 2d86f221ce9e4df99aec801ae226ed228f5b64ac Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 25 Nov 2019 18:27:34 +0100 Subject: [PATCH 0111/2315] Remove println --- .../org/springframework/http/codec/json/Jackson2Tokenizer.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java index 438ca49f7939..1c110c49a8be 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java @@ -174,9 +174,6 @@ private void processTokenNormal(JsonToken token, List result) throw private void processTokenArray(JsonToken token, List result) throws IOException { if (!isTopLevelArrayToken(token)) { - if (!this.parser.hasCurrentToken()) { - System.out.println("NO CURRENT TOKEN: " + token); - } this.tokenBuffer.copyCurrentEvent(this.parser); } From ddb38eefeea1506bbf5bdefda4fd0c354381d79f Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Tue, 26 Nov 2019 10:50:08 +0100 Subject: [PATCH 0112/2315] Expose method to determine form content type This commit exposes the method that returns the media type used to write forms. By default, it includes the charset in the content type, which can cause issues with certain consumers. This commit changes the method from a private to a protected method, so that users can override the default behavior. Closes: gh-22971 --- .../converter/FormHttpMessageConverter.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java index ced2ae1767f9..76496f583291 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java @@ -384,7 +384,7 @@ private boolean isMultipart(MultiValueMap map, @Nullable MediaType co private void writeForm(MultiValueMap formData, @Nullable MediaType contentType, HttpOutputMessage outputMessage) throws IOException { - contentType = getMediaType(contentType); + contentType = getFormContentType(contentType); outputMessage.getHeaders().setContentType(contentType); Charset charset = contentType.getCharset(); @@ -402,15 +402,27 @@ private void writeForm(MultiValueMap formData, @Nullable MediaTy } } - private MediaType getMediaType(@Nullable MediaType mediaType) { - if (mediaType == null) { + /** + * Return the content type used to write forms, given the preferred content type. + * By default, this method returns the given content type, but adds the + * {@linkplain #setCharset(Charset) charset} if it does not have one. + * If {@code contentType} is {@code null}, + * {@code application/x-www-form-urlencoded; charset=UTF-8} is returned. + * + *

Subclasses can override this method to change this behavior. + * @param contentType the preferred content type, can be {@code null} + * @return the content type to be used + * @since 5.2.2 + */ + protected MediaType getFormContentType(@Nullable MediaType contentType) { + if (contentType == null) { return DEFAULT_FORM_DATA_MEDIA_TYPE; } - else if (mediaType.getCharset() == null) { - return new MediaType(mediaType, this.charset); + else if (contentType.getCharset() == null) { + return new MediaType(contentType, this.charset); } else { - return mediaType; + return contentType; } } From 70a3dbff24e7e39b8be9861a6fcb0cd05eb52bb2 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 26 Nov 2019 10:44:09 +0000 Subject: [PATCH 0113/2315] WebSession creation does not block Closes gh-24027 --- .../session/InMemoryWebSessionStore.java | 10 +++++++-- .../session/InMemoryWebSessionStoreTests.java | 11 ++++++++++ .../annotation/ModelInitializerTests.java | 21 +++++++++++-------- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java b/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java index cb23bb313d50..09eb47560e0f 100644 --- a/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java +++ b/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -29,6 +29,7 @@ import java.util.concurrent.locks.ReentrantLock; import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; import org.springframework.util.Assert; import org.springframework.util.IdGenerator; @@ -111,9 +112,14 @@ public Map getSessions() { @Override public Mono createWebSession() { + + // Opportunity to clean expired sessions Instant now = this.clock.instant(); this.expiredSessionChecker.checkIfNecessary(now); - return Mono.fromSupplier(() -> new InMemoryWebSession(now)); + + return Mono.fromSupplier(() -> new InMemoryWebSession(now)) + .subscribeOn(Schedulers.boundedElastic()) + .cast(WebSession.class); } @Override diff --git a/spring-web/src/test/java/org/springframework/web/server/session/InMemoryWebSessionStoreTests.java b/spring-web/src/test/java/org/springframework/web/server/session/InMemoryWebSessionStoreTests.java index d2ab0de61d95..998f22dccc11 100644 --- a/spring-web/src/test/java/org/springframework/web/server/session/InMemoryWebSessionStoreTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/session/InMemoryWebSessionStoreTests.java @@ -22,7 +22,10 @@ import java.util.Map; import java.util.stream.IntStream; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; import org.springframework.beans.DirectFieldAccessor; import org.springframework.web.server.WebSession; @@ -56,6 +59,14 @@ public void startsSessionImplicitly() { assertThat(session.isStarted()).isTrue(); } + @Disabled // TODO: remove if/when Blockhound is enabled + @Test // gh-24027 + public void createSessionDoesNotBlock() { + Mono.defer(() -> this.store.createWebSession()) + .subscribeOn(Schedulers.parallel()) + .block(); + } + @Test public void retrieveExpiredSession() { WebSession session = this.store.createWebSession().block(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java index a8a5ef0d0fa7..0a388a1ca568 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java @@ -64,6 +64,9 @@ */ public class ModelInitializerTests { + private static final Duration TIMEOUT = Duration.ofMillis(5000); + + private ModelInitializer modelInitializer; private final ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path")); @@ -93,7 +96,7 @@ public void initBinderMethod() { Method method = ResolvableMethod.on(TestController.class).annotPresent(GetMapping.class).resolveMethod(); HandlerMethod handlerMethod = new HandlerMethod(controller, method); - this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(Duration.ofMillis(5000)); + this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(TIMEOUT); WebExchangeDataBinder binder = context.createDataBinder(this.exchange, "name"); assertThat(binder.getValidators()).isEqualTo(Collections.singletonList(validator)); @@ -107,7 +110,7 @@ public void modelAttributeMethods() { Method method = ResolvableMethod.on(TestController.class).annotPresent(GetMapping.class).resolveMethod(); HandlerMethod handlerMethod = new HandlerMethod(controller, method); - this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(Duration.ofMillis(5000)); + this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(TIMEOUT); Map model = context.getModel().asMap(); assertThat(model.size()).isEqualTo(5); @@ -116,7 +119,7 @@ public void modelAttributeMethods() { assertThat(((TestBean) value).getName()).isEqualTo("Bean"); value = model.get("monoBean"); - assertThat(((Mono) value).block(Duration.ofMillis(5000)).getName()).isEqualTo("Mono Bean"); + assertThat(((Mono) value).block(TIMEOUT).getName()).isEqualTo("Mono Bean"); value = model.get("singleBean"); assertThat(((Single) value).toBlocking().value().getName()).isEqualTo("Single Bean"); @@ -135,7 +138,7 @@ public void saveModelAttributeToSession() { Method method = ResolvableMethod.on(TestController.class).annotPresent(GetMapping.class).resolveMethod(); HandlerMethod handlerMethod = new HandlerMethod(controller, method); - this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(Duration.ofMillis(5000)); + this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(TIMEOUT); WebSession session = this.exchange.getSession().block(Duration.ZERO); assertThat(session).isNotNull(); @@ -148,7 +151,7 @@ public void saveModelAttributeToSession() { @Test public void retrieveModelAttributeFromSession() { - WebSession session = this.exchange.getSession().block(Duration.ZERO); + WebSession session = this.exchange.getSession().block(TIMEOUT); assertThat(session).isNotNull(); TestBean testBean = new TestBean("Session Bean"); @@ -159,7 +162,7 @@ public void retrieveModelAttributeFromSession() { Method method = ResolvableMethod.on(TestController.class).annotPresent(GetMapping.class).resolveMethod(); HandlerMethod handlerMethod = new HandlerMethod(controller, method); - this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(Duration.ofMillis(5000)); + this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(TIMEOUT); context.saveModel(); assertThat(session.getAttributes().size()).isEqualTo(1); @@ -174,13 +177,13 @@ public void requiredSessionAttributeMissing() { Method method = ResolvableMethod.on(TestController.class).annotPresent(PostMapping.class).resolveMethod(); HandlerMethod handlerMethod = new HandlerMethod(controller, method); assertThatIllegalArgumentException().isThrownBy(() -> - this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(Duration.ofMillis(5000))) + this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(TIMEOUT)) .withMessage("Required attribute 'missing-bean' is missing."); } @Test public void clearModelAttributeFromSession() { - WebSession session = this.exchange.getSession().block(Duration.ZERO); + WebSession session = this.exchange.getSession().block(TIMEOUT); assertThat(session).isNotNull(); TestBean testBean = new TestBean("Session Bean"); @@ -191,7 +194,7 @@ public void clearModelAttributeFromSession() { Method method = ResolvableMethod.on(TestController.class).annotPresent(GetMapping.class).resolveMethod(); HandlerMethod handlerMethod = new HandlerMethod(controller, method); - this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(Duration.ofMillis(5000)); + this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(TIMEOUT); context.getSessionStatus().setComplete(); context.saveModel(); From 526d89e1e61807faffdb3686e4243ffa4c2831f0 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 26 Nov 2019 12:04:00 +0000 Subject: [PATCH 0114/2315] Refine Throwable handling in spring-websocket This commit lowers the level of Throwable handling in parts of spring-websocket which now handle Exception instead and allow any Error to propagate. Closes gh-24075 --- .../jetty/JettyWebSocketHandlerAdapter.java | 14 +++++++------- .../standard/StandardWebSocketHandlerAdapter.java | 14 +++++++------- .../ExceptionWebSocketHandlerDecorator.java | 10 +++++----- .../server/support/AbstractHandshakeHandler.java | 4 ++-- .../server/support/HandshakeInterceptorChain.java | 2 +- .../support/WebSocketHttpRequestHandler.java | 2 +- .../sockjs/client/AbstractClientSockJsSession.java | 6 +++--- .../sockjs/client/RestTemplateXhrTransport.java | 2 +- .../web/socket/sockjs/client/SockJsClient.java | 4 ++-- .../sockjs/support/SockJsHttpRequestHandler.java | 4 ++-- .../transport/TransportHandlingSockJsService.java | 8 ++++---- .../AbstractHttpReceivingTransportHandler.java | 4 ++-- .../handler/WebSocketTransportHandler.java | 2 +- .../transport/session/AbstractSockJsSession.java | 4 ++-- .../session/WebSocketServerSockJsSession.java | 4 ++-- 15 files changed, 42 insertions(+), 42 deletions(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapter.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapter.java index e819f6050257..0c414a6b11eb 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapter.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -71,7 +71,7 @@ public void onWebSocketConnect(Session session) { this.wsSession.initializeNativeSession(session); this.webSocketHandler.afterConnectionEstablished(this.wsSession); } - catch (Throwable ex) { + catch (Exception ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } } @@ -82,7 +82,7 @@ public void onWebSocketText(String payload) { try { this.webSocketHandler.handleMessage(this.wsSession, message); } - catch (Throwable ex) { + catch (Exception ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } } @@ -93,7 +93,7 @@ public void onWebSocketBinary(byte[] payload, int offset, int length) { try { this.webSocketHandler.handleMessage(this.wsSession, message); } - catch (Throwable ex) { + catch (Exception ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } } @@ -106,7 +106,7 @@ public void onWebSocketFrame(Frame frame) { try { this.webSocketHandler.handleMessage(this.wsSession, message); } - catch (Throwable ex) { + catch (Exception ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } } @@ -118,7 +118,7 @@ public void onWebSocketClose(int statusCode, String reason) { try { this.webSocketHandler.afterConnectionClosed(this.wsSession, closeStatus); } - catch (Throwable ex) { + catch (Exception ex) { if (logger.isWarnEnabled()) { logger.warn("Unhandled exception after connection closed for " + this, ex); } @@ -130,7 +130,7 @@ public void onWebSocketError(Throwable cause) { try { this.webSocketHandler.handleTransportError(this.wsSession, cause); } - catch (Throwable ex) { + catch (Exception ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapter.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapter.java index 787511f18d65..c4c11a30d963 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapter.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -103,7 +103,7 @@ public void onMessage(javax.websocket.PongMessage message) { try { this.handler.afterConnectionEstablished(this.wsSession); } - catch (Throwable ex) { + catch (Exception ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } } @@ -113,7 +113,7 @@ private void handleTextMessage(javax.websocket.Session session, String payload, try { this.handler.handleMessage(this.wsSession, textMessage); } - catch (Throwable ex) { + catch (Exception ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } } @@ -123,7 +123,7 @@ private void handleBinaryMessage(javax.websocket.Session session, ByteBuffer pay try { this.handler.handleMessage(this.wsSession, binaryMessage); } - catch (Throwable ex) { + catch (Exception ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } } @@ -133,7 +133,7 @@ private void handlePongMessage(javax.websocket.Session session, ByteBuffer paylo try { this.handler.handleMessage(this.wsSession, pongMessage); } - catch (Throwable ex) { + catch (Exception ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } } @@ -144,7 +144,7 @@ public void onClose(javax.websocket.Session session, CloseReason reason) { try { this.handler.afterConnectionClosed(this.wsSession, closeStatus); } - catch (Throwable ex) { + catch (Exception ex) { if (logger.isWarnEnabled()) { logger.warn("Unhandled on-close exception for " + this.wsSession, ex); } @@ -156,7 +156,7 @@ public void onError(javax.websocket.Session session, Throwable exception) { try { this.handler.handleTransportError(this.wsSession, exception); } - catch (Throwable ex) { + catch (Exception ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecorator.java b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecorator.java index 104e70371b39..96d7a2d697b2 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecorator.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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,7 +47,7 @@ public void afterConnectionEstablished(WebSocketSession session) { try { getDelegate().afterConnectionEstablished(session); } - catch (Throwable ex) { + catch (Exception ex) { tryCloseWithError(session, ex, logger); } } @@ -57,7 +57,7 @@ public void handleMessage(WebSocketSession session, WebSocketMessage message) try { getDelegate().handleMessage(session, message); } - catch (Throwable ex) { + catch (Exception ex) { tryCloseWithError(session, ex, logger); } } @@ -67,7 +67,7 @@ public void handleTransportError(WebSocketSession session, Throwable exception) try { getDelegate().handleTransportError(session, exception); } - catch (Throwable ex) { + catch (Exception ex) { tryCloseWithError(session, ex, logger); } } @@ -77,7 +77,7 @@ public void afterConnectionClosed(WebSocketSession session, CloseStatus closeSta try { getDelegate().afterConnectionClosed(session, closeStatus); } - catch (Throwable ex) { + catch (Exception ex) { if (logger.isWarnEnabled()) { logger.warn("Unhandled exception after connection closed for " + this, ex); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java index b0d8828f8b3d..47384d84b498 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -157,7 +157,7 @@ else if (websphereWsPresent) { Class clazz = ClassUtils.forName(className, AbstractHandshakeHandler.class.getClassLoader()); return (RequestUpgradeStrategy) ReflectionUtils.accessibleConstructor(clazz).newInstance(); } - catch (Throwable ex) { + catch (Exception ex) { throw new IllegalStateException( "Failed to instantiate RequestUpgradeStrategy: " + className, ex); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeInterceptorChain.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeInterceptorChain.java index f853aa51f339..5484a5229824 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeInterceptorChain.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeInterceptorChain.java @@ -77,7 +77,7 @@ public void applyAfterHandshake( try { interceptor.afterHandshake(request, response, this.wsHandler, failure); } - catch (Throwable ex) { + catch (Exception ex) { if (logger.isWarnEnabled()) { logger.warn(interceptor + " threw exception in afterHandshake: " + ex); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java index 279cf8f9f60b..d4abeba3ace9 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java @@ -171,7 +171,7 @@ public void handleRequest(HttpServletRequest servletRequest, HttpServletResponse catch (HandshakeFailureException ex) { failure = ex; } - catch (Throwable ex) { + catch (Exception ex) { failure = new HandshakeFailureException("Uncaught failure for request " + request.getURI(), ex); } finally { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractClientSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractClientSockJsSession.java index 974ee2680455..03338f9bfae1 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractClientSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractClientSockJsSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -244,7 +244,7 @@ private void handleOpenFrame() { this.webSocketHandler.afterConnectionEstablished(this); this.connectFuture.set(this); } - catch (Throwable ex) { + catch (Exception ex) { if (logger.isErrorEnabled()) { logger.error("WebSocketHandler.afterConnectionEstablished threw exception in " + this, ex); } @@ -293,7 +293,7 @@ private void handleMessageFrame(SockJsFrame frame) { try { this.webSocketHandler.handleMessage(this, new TextMessage(message)); } - catch (Throwable ex) { + catch (Exception ex) { logger.error("WebSocketHandler.handleMessage threw an exception on " + frame + " in " + this, ex); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransport.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransport.java index b8c7ff362093..ba8deed6e498 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransport.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransport.java @@ -118,7 +118,7 @@ protected void connectInternal(final TransportRequest transportRequest, final We getRestTemplate().execute(receiveUrl, HttpMethod.POST, requestCallback, responseExtractor); requestCallback = requestCallbackAfterHandshake; } - catch (Throwable ex) { + catch (Exception ex) { if (!connectFuture.isDone()) { connectFuture.setException(ex); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java index f9eac2bd4166..88d81e71586f 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -260,7 +260,7 @@ public final ListenableFuture doHandshake( ServerInfo serverInfo = getServerInfo(sockJsUrlInfo, getHttpRequestHeaders(headers)); createRequest(sockJsUrlInfo, headers, serverInfo).connect(handler, connectFuture); } - catch (Throwable exception) { + catch (Exception exception) { if (logger.isErrorEnabled()) { logger.error("Initial SockJS \"Info\" request to server failed, url=" + url, exception); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/SockJsHttpRequestHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/SockJsHttpRequestHandler.java index c158d3bb502f..887864d570aa 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/SockJsHttpRequestHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/SockJsHttpRequestHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2019 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. @@ -133,7 +133,7 @@ public void handleRequest(HttpServletRequest servletRequest, HttpServletResponse try { this.sockJsService.handleRequest(request, response, getSockJsPath(servletRequest), this.webSocketHandler); } - catch (Throwable ex) { + catch (Exception ex) { throw new SockJsException("Uncaught failure in SockJS request, uri=" + request.getURI(), ex); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java index fc13a2ef5ab3..40a19881077c 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -215,10 +215,10 @@ protected void handleRawWebSocketRequest(ServerHttpRequest request, ServerHttpRe catch (HandshakeFailureException ex) { failure = ex; } - catch (Throwable ex) { + catch (Exception ex) { failure = new HandshakeFailureException("Uncaught failure for request " + request.getURI(), ex); } - finally { + finally { if (failure != null) { chain.applyAfterHandshake(request, response, failure); throw failure; @@ -316,7 +316,7 @@ else if (transportType.supportsCors()) { catch (SockJsException ex) { failure = ex; } - catch (Throwable ex) { + catch (Exception ex) { failure = new SockJsException("Uncaught failure for request " + request.getURI(), sessionId, ex); } finally { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java index 60e396368807..1e3e933dac86 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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. @@ -72,7 +72,7 @@ protected void handleRequestInternal(ServerHttpRequest request, ServerHttpRespon } return; } - catch (Throwable ex) { + catch (Exception ex) { logger.error("Failed to read message", ex); handleReadError(response, "Failed to read message(s)", sockJsSession.getId()); return; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java index 60423319dc6d..77e7bbe2f0c9 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java @@ -124,7 +124,7 @@ public void handleRequest(ServerHttpRequest request, ServerHttpResponse response wsHandler = new SockJsWebSocketHandler(getServiceConfig(), wsHandler, sockJsSession); this.handshakeHandler.doHandshake(request, response, wsHandler, sockJsSession.getAttributes()); } - catch (Throwable ex) { + catch (Exception ex) { sockJsSession.tryCloseWithSockJsTransportError(ex, CloseStatus.SERVER_ERROR); throw new SockJsTransportFailureException("WebSocket handshake failure", wsSession.getId(), ex); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java index 9115f64d9b85..cc950ea4870d 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java @@ -324,7 +324,7 @@ protected void writeFrame(SockJsFrame frame) throws SockJsTransportFailureExcept try { writeFrameInternal(frame); } - catch (Throwable ex) { + catch (Exception ex) { logWriteFrameFailure(ex); try { // Force disconnect (so we won't try to send close frame) @@ -388,7 +388,7 @@ public void delegateMessages(String... messages) throws SockJsMessageDeliveryExc undelivered.remove(0); } } - catch (Throwable ex) { + catch (Exception ex) { throw new SockJsMessageDeliveryException(this.id, undelivered, ex); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSession.java index 35d73332b577..a8ed9363270d 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSession.java @@ -166,7 +166,7 @@ public void initializeDelegateSession(WebSocketSession session) { scheduleHeartbeat(); this.openFrameSent = true; } - catch (Throwable ex) { + catch (Exception ex) { tryCloseWithSockJsTransportError(ex, CloseStatus.SERVER_ERROR); } } @@ -186,7 +186,7 @@ public void handleMessage(TextMessage message, WebSocketSession wsSession) throw try { messages = getSockJsServiceConfig().getMessageCodec().decode(payload); } - catch (Throwable ex) { + catch (Exception ex) { logger.error("Broken data received. Terminating WebSocket connection abruptly", ex); tryCloseWithSockJsTransportError(ex, CloseStatus.BAD_DATA); return; From f57f33710458ea982e00d71b3c885c461fe779ea Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 26 Nov 2019 12:08:22 +0000 Subject: [PATCH 0115/2315] Protected method to decorate WebSocketHandler See gh-24075 --- .../server/support/WebSocketHttpRequestHandler.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java index d4abeba3ace9..1399bf7617cb 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java @@ -77,10 +77,20 @@ public WebSocketHttpRequestHandler(WebSocketHandler wsHandler) { public WebSocketHttpRequestHandler(WebSocketHandler wsHandler, HandshakeHandler handshakeHandler) { Assert.notNull(wsHandler, "wsHandler must not be null"); Assert.notNull(handshakeHandler, "handshakeHandler must not be null"); - this.wsHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(wsHandler)); + this.wsHandler = decorate(wsHandler); this.handshakeHandler = handshakeHandler; } + /** + * Decorate the {@code WebSocketHandler} passed into the constructor. + *

By default, {@link LoggingWebSocketHandlerDecorator} and + * {@link ExceptionWebSocketHandlerDecorator} are added. + * @since 5.2.2 + */ + protected WebSocketHandler decorate(WebSocketHandler handler) { + return new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(handler)); + } + /** * Return the WebSocketHandler. From db97dac86dd1b3023d87e6093ae0bcecdf4afd78 Mon Sep 17 00:00:00 2001 From: jasdeepgill <51393196+jasdeepgill@users.noreply.github.com> Date: Sun, 24 Nov 2019 20:35:19 -0800 Subject: [PATCH 0116/2315] Improve readability of CONTRIBUTING.md Closes gh-24068 --- CONTRIBUTING.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7b0031d87d61..0aa7c360ee35 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,10 +28,11 @@ If you have a question, check Stack Overflow using [this list of tags](https://spring.io/questions), organized by Spring project. Find an existing discussion, or start a new one if necessary. -If you suspect an issue, perform a search in the +If you find an issue, perform a search in the [GitHub issue tracker](https://github.com/spring-projects/spring-framework/issues), using a few different keywords. -When you find related issues and discussions, prior or current, it helps you to learn, and -it helps us to make a decision. +If you find discussions related to your issue either past or current, read them as it helps you learn about the issue +and helps us make a decision on the issue. + #### Create a Ticket From 08669cc7c38463de628c604f22c1434c2d0701bb Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 26 Nov 2019 15:56:37 +0000 Subject: [PATCH 0117/2315] Updates to CONTRIBUTING.md Closes gh-22892 --- CONTRIBUTING.md | 64 ++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0aa7c360ee35..c10a282cbafa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,8 +7,8 @@ First off, thank you for taking the time to contribute! :+1: :tada: * [Code of Conduct](#code-of-conduct) * [How to Contribute](#how-to-contribute) * [Discuss](#discuss) - * [Create a Ticket](#create-a-ticket) - * [Ticket Lifecycle](#ticket-lifecycle) + * [Create an Issue](#create-an-issue) + * [Issue Lifecycle](#issue-lifecycle) * [Submit a Pull Request](#submit-a-pull-request) * [Build from Source](#build-from-source) * [Source Code Style](#source-code-style) @@ -28,56 +28,55 @@ If you have a question, check Stack Overflow using [this list of tags](https://spring.io/questions), organized by Spring project. Find an existing discussion, or start a new one if necessary. -If you find an issue, perform a search in the -[GitHub issue tracker](https://github.com/spring-projects/spring-framework/issues), using a few different keywords. -If you find discussions related to your issue either past or current, read them as it helps you learn about the issue -and helps us make a decision on the issue. +If you believe there is an issue, search through +[existing issues](https://github.com/spring-projects/spring-framework/issues) trying a +few different ways to find discussions, past or current, that are related to the issue. +Reading those discussions helps you to learn about the issue, and helps us to make a +decision. -#### Create a Ticket +#### Create an Issue Reporting an issue or making a feature request is a great way to contribute. Your feedback -and the conversations that result from it provide a continuous flow of ideas. +and the conversations that result from it provide a continuous flow of ideas. However, +before creating a ticket, please take the time to [discuss and research](#discuss) first. -Before you create a ticket, please take the time to [research first](#discuss). +If creating an issue after a discussion on Stack Overflow, please provide a description +in the issue instead of simply referring to Stack Overflow. The issue tracker is an +important place of record for design discussions and should be self-sufficient. -If creating a ticket after a discussion on Stack Overflow, please provide a self-sufficient description in the ticket, independent of the details on Stack Overflow. We understand this is extra work, but the issue tracker is an important place of record for design discussions and decisions that can often be referenced long after the fix version — for example to revisit decisions, to understand the origin of a feature, and so on. +Once you're ready, create an issue on +[GitHub](https://github.com/spring-projects/spring-framework/issues). -Once you're ready, create a ticket in the [GitHub issue tracker](https://github.com/spring-projects/spring-framework/issues). - -#### Ticket Lifecycle +#### Issue Lifecycle When an issue is first created, it is flagged `waiting-for-triage` waiting for a team -member to triage it. Within a day or two, the issue will then be reviewed, and the team -may ask for further information if needed. Based on the findings, the issue is either -assigned a fix version or declined. +member to triage it. Once the issue has been reviewed, the team may ask for further +information if needed, and based on the findings, the issue is either assigned a target +milestone or is closed with a specific status. -When a fix is ready, the issue is closed and may still be re-opened. Once a fix is -released, the issue can't be reopened. If necessary, you will need to create a new, -related ticket with a fresh description. +When a fix is ready, the issue is closed and may still be re-opened until the fix is +released. After that the issue will typically no longer be reopened. In rare cases if the +issue was not at all fixed, the issue may be re-opened. In most cases however any +follow-up reports will need to be created as new issues with a fresh description. #### Submit a Pull Request -You can contribute a source code change by submitting a pull request. - 1. If you have not previously done so, please sign the -[Contributor License Agreement](https://cla.pivotal.io/sign/spring). You will also be reminded -automatically when you submit a pull request. +[Contributor License Agreement](https://cla.pivotal.io/sign/spring). You will be reminded +automatically when you submit the PR. -1. Should you create a ticket first? The answer is no. Just create the pull request and use -the description to provide context and motivation, as you would for an issue. If you want -to start a discussion first or have already created an issue, once a pull request is created, -we will close the issue as superseded by the pull request, and the discussion of the issue -will continue under the pull request. +1. Should you create an issue first? No, just create the pull request and use the +description to provide context and motivation, as you would for an issue. If you want +to start a discussion first or have already created an issue, once a pull request is +created, we will close the issue as superseded by the pull request, and the discussion +about the issue will continue under the pull request. 1. Always check out the `master` branch and submit pull requests against it (for target version see [settings.gradle](settings.gradle)). Backports to prior versions will be considered on a case-by-case basis and reflected as the fix version in the issue tracker. -1. Use short branch names, preferably based on the GitHub issue (e.g. `22276`), or -otherwise using succinct, lower-case, dash (-) delimited names, such as `fix-warnings`. - 1. Choose the granularity of your commits consciously and squash commits that represent multiple edits or corrections of the same logical change. See [Rewriting History section of Pro Git](https://git-scm.com/book/en/Git-Tools-Rewriting-History) @@ -88,7 +87,8 @@ for the description, followed by the issue fixed, e.g. `Closes gh-22276`. See th [Commit Guidelines section of Pro Git](https://git-scm.com/book/en/Distributed-Git-Contributing-to-a-Project#Commit-Guidelines) for best practices around commit messages, and use `git log` to see some examples. -1. List the GitHub issue number in the PR description. +1. If there is a prior issue, reference the GitHub issue number in the description of the +pull request. If accepted, your contribution may be heavily modified as needed prior to merging. You will likely retain author attribution for your Git commits granted that the bulk of From 30d68f2de78ef70ebcb02c2d40c85587f384f618 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 26 Nov 2019 16:21:48 +0000 Subject: [PATCH 0118/2315] Reject user names with "%2F" in STOMP Closes gh-23836 --- .../messaging/simp/SimpMessagingTemplate.java | 3 ++- .../simp/user/DefaultUserDestinationResolver.java | 3 ++- .../messaging/simp/SimpMessagingTemplateTests.java | 7 +++++++ .../simp/user/DefaultUserDestinationResolverTests.java | 10 ++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessagingTemplate.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessagingTemplate.java index c3ddf8a894a1..bd157bd5f80a 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessagingTemplate.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessagingTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -224,6 +224,7 @@ public void convertAndSendToUser(String user, String destination, Object payload throws MessagingException { Assert.notNull(user, "User must not be null"); + Assert.isTrue(!user.contains("%2F"), "Invalid sequence \"%2F\" in user name: " + user); user = StringUtils.replace(user, "/", "%2F"); destination = destination.startsWith("/") ? destination : "/" + destination; super.convertAndSend(this.destinationPrefix + user + destination, payload, headers, postProcessor); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java index 5f71ec962ba0..62729df07e93 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -203,6 +203,7 @@ private ParseResult parseSubscriptionMessage(Message message, String sourceDe } Principal principal = SimpMessageHeaderAccessor.getUser(headers); String user = (principal != null ? principal.getName() : null); + Assert.isTrue(user == null || !user.contains("%2F"), "Invalid sequence \"%2F\" in user name: " + user); Set sessionIds = Collections.singleton(sessionId); return new ParseResult(sourceDestination, actualDestination, sourceDestination, sessionIds, user); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java index 7b4343aac88c..2062f7ceafaa 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java @@ -36,6 +36,7 @@ import org.springframework.util.LinkedMultiValueMap; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; /** * Unit tests for {@link org.springframework.messaging.simp.SimpMessagingTemplate}. @@ -86,6 +87,12 @@ public void convertAndSendToUserWithEncoding() { assertThat(headerAccessor.getDestination()).isEqualTo("/user/https:%2F%2Fjoe.openid.example.org%2F/queue/foo"); } + @Test // gh-23836 + public void convertAndSendToUserWithInvalidSequence() { + assertThatIllegalArgumentException().isThrownBy(() -> + this.messagingTemplate.convertAndSendToUser("joe%2F", "/queue/foo", "data")); + } + @Test public void convertAndSendWithCustomHeader() { Map headers = Collections.singletonMap("key", "value"); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java index c2887f5d1b25..888afe23960e 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java @@ -29,6 +29,7 @@ import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -113,6 +114,15 @@ public void handleSubscribeNoUser() { assertThat(actual.getUser()).isNull(); } + @Test // gh-23836 + public void handleSubscribeInvalidUserName() { + TestPrincipal user = new TestPrincipal("joe%2F"); + String sourceDestination = "/user/queue/foo"; + + Message message = createMessage(SimpMessageType.SUBSCRIBE, user, "123", sourceDestination); + assertThatIllegalArgumentException().isThrownBy(() -> this.resolver.resolveDestination(message)); + } + @Test public void handleUnsubscribe() { TestPrincipal user = new TestPrincipal("joe"); From 5a552f16708192334de3b4d4a3cbf8a1c9027ebe Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 26 Nov 2019 21:50:01 +0000 Subject: [PATCH 0119/2315] Update links between WebFlux and Web MVC --- src/docs/asciidoc/integration.adoc | 2 +- src/docs/asciidoc/web/webflux-cors.adoc | 12 +- src/docs/asciidoc/web/webflux-functional.adoc | 12 +- src/docs/asciidoc/web/webflux-view.adoc | 22 +-- src/docs/asciidoc/web/webflux.adoc | 140 +++++++++--------- src/docs/asciidoc/web/webmvc-cors.adoc | 14 +- src/docs/asciidoc/web/webmvc-functional.adoc | 12 +- src/docs/asciidoc/web/webmvc-view.adoc | 24 +-- src/docs/asciidoc/web/webmvc.adoc | 140 +++++++++--------- src/docs/asciidoc/web/websocket.adoc | 12 +- 10 files changed, 195 insertions(+), 195 deletions(-) diff --git a/src/docs/asciidoc/integration.adoc b/src/docs/asciidoc/integration.adoc index 6fbe67b051ae..0ca100c30de3 100644 --- a/src/docs/asciidoc/integration.adoc +++ b/src/docs/asciidoc/integration.adoc @@ -1113,7 +1113,7 @@ converters to use explicitly. [[rest-message-conversion]] ===== Message Conversion -[.small]#<># +[.small]#<># The `spring-web` module contains the `HttpMessageConverter` contract for reading and writing the body of HTTP requests and responses through `InputStream` and `OutputStream`. diff --git a/src/docs/asciidoc/web/webflux-cors.adoc b/src/docs/asciidoc/web/webflux-cors.adoc index 33bd4b0e403d..7d48a60e7a81 100644 --- a/src/docs/asciidoc/web/webflux-cors.adoc +++ b/src/docs/asciidoc/web/webflux-cors.adoc @@ -1,6 +1,6 @@ [[webflux-cors]] = CORS -[.small]#<># +[.small]#<># Spring WebFlux lets you handle CORS (Cross-Origin Resource Sharing). This section describes how to do so. @@ -10,7 +10,7 @@ describes how to do so. [[webflux-cors-intro]] == Introduction -[.small]#<># +[.small]#<># For security reasons, browsers prohibit AJAX calls to resources outside the current origin. For example, you could have your bank account in one tab and evil.com in another. Scripts @@ -27,7 +27,7 @@ powerful workarounds based on IFRAME or JSONP. [[webflux-cors-processing]] == Processing -[.small]#<># +[.small]#<># The CORS specification distinguishes between preflight, simple, and actual requests. To learn how CORS works, you can read @@ -77,7 +77,7 @@ To learn more from the source or to make advanced customizations, see: [[webflux-cors-controller]] == `@CrossOrigin` -[.small]#<># +[.small]#<># The {api-spring-framework}/web/bind/annotation/CrossOrigin.html[`@CrossOrigin`] annotation enables cross-origin requests on annotated controller methods, as the @@ -230,7 +230,7 @@ as the following example shows: [[webflux-cors-global]] == Global Configuration -[.small]#<># +[.small]#<># In addition to fine-grained, controller method-level configuration, you probably want to define some global CORS configuration, too. You can set URL-based `CorsConfiguration` @@ -299,7 +299,7 @@ as the following example shows: [[webflux-cors-webfilter]] == CORS `WebFilter` -[.small]#<># +[.small]#<># You can apply CORS support through the built-in {api-spring-framework}/web/cors/reactive/CorsWebFilter.html[`CorsWebFilter`], which is a diff --git a/src/docs/asciidoc/web/webflux-functional.adoc b/src/docs/asciidoc/web/webflux-functional.adoc index c79290b13989..a69c98976c35 100644 --- a/src/docs/asciidoc/web/webflux-functional.adoc +++ b/src/docs/asciidoc/web/webflux-functional.adoc @@ -1,6 +1,6 @@ [[webflux-fn]] = Functional Endpoints -[.small]#<># +[.small]#<># Spring WebFlux includes WebFlux.fn, a lightweight functional programming model in which functions are used to route and handle requests and contracts are designed for immutability. @@ -12,7 +12,7 @@ the same <> foundation. [[webflux-fn-overview]] == Overview -[.small]#<># +[.small]#<># In WebFlux.fn, an HTTP request is handled with a `HandlerFunction`: a function that takes `ServerRequest` and returns a delayed `ServerResponse` (i.e. `Mono`). @@ -112,7 +112,7 @@ Most applications can run through the WebFlux Java configuration, see <># +[.small]#<># `ServerRequest` and `ServerResponse` are immutable interfaces that offer JDK 8-friendly access to the HTTP request and response. @@ -440,7 +440,7 @@ See <>. [[webflux-fn-router-functions]] == `RouterFunction` -[.small]#<># +[.small]#<># Router functions are used to route the requests to the corresponding `HandlerFunction`. Typically, you do not write router functions yourself, but rather use a method on the @@ -639,7 +639,7 @@ We can further improve by using the `nest` method together with `accept`: [[webflux-fn-running]] == Running a Server -[.small]#<># +[.small]#<># How do you run a router function in an HTTP server? A simple option is to convert a router function to an `HttpHandler` by using one of the following: @@ -745,7 +745,7 @@ The following example shows a WebFlux Java configuration (see [[webflux-fn-handler-filter-function]] == Filtering Handler Functions -[.small]#<># +[.small]#<># You can filter handler functions by using the `before`, `after`, or `filter` methods on the routing function builder. diff --git a/src/docs/asciidoc/web/webflux-view.adoc b/src/docs/asciidoc/web/webflux-view.adoc index 9ab7ec1c1ec1..0321f1fd1dfe 100644 --- a/src/docs/asciidoc/web/webflux-view.adoc +++ b/src/docs/asciidoc/web/webflux-view.adoc @@ -1,6 +1,6 @@ [[webflux-view]] = View Technologies -[.small]#<># +[.small]#<># The use of view technologies in Spring WebFlux is pluggable. Whether you decide to use Thymeleaf, FreeMarker, or some other view technology is primarily a matter of a @@ -12,7 +12,7 @@ WebFlux. We assume you are already familiar with <>. [[webflux-view-thymeleaf]] == Thymeleaf -[.small]#<># +[.small]#<># Thymeleaf is a modern server-side Java template engine that emphasizes natural HTML templates that can be previewed in a browser by double-clicking, which is very @@ -33,7 +33,7 @@ http://forum.thymeleaf.org/Thymeleaf-3-0-8-JUST-PUBLISHED-td4030687.html[announc [[webflux-view-freemarker]] == FreeMarker -[.small]#<># +[.small]#<># https://freemarker.apache.org/[Apache FreeMarker] is a template engine for generating any kind of text output from HTML to email and others. The Spring Framework has built-in @@ -43,7 +43,7 @@ integration for using Spring WebFlux with FreeMarker templates. [[webflux-view-freemarker-contextconfig]] === View Configuration -[.small]#<># +[.small]#<># The following example shows how to configure FreeMarker as a view technology: @@ -98,7 +98,7 @@ returns the view name, `welcome`, the resolver looks for the [[webflux-views-freemarker]] === FreeMarker Configuration -[.small]#<># +[.small]#<># You can pass FreeMarker 'Settings' and 'SharedVariables' directly to the FreeMarker `Configuration` object (which is managed by Spring) by setting the appropriate bean @@ -151,7 +151,7 @@ the `Configuration` object. [[webflux-view-freemarker-forms]] === Form Handling -[.small]#<># +[.small]#<># Spring provides a tag library for use in JSPs that contains, among others, a `` element. This element primarily lets forms display values from @@ -162,7 +162,7 @@ with additional convenience macros for generating form input elements themselves [[webflux-view-bind-macros]] ==== The Bind Macros -[.small]#<># +[.small]#<># A standard set of macros are maintained within the `spring-webflux.jar` file for FreeMarker, so they are always available to a suitably configured application. @@ -193,7 +193,7 @@ sections of the Spring MVC documentation. [[webflux-view-script]] == Script Views -[.small]#<># +[.small]#<># The Spring Framework has a built-in integration for using Spring WebFlux with any templating library that can run on top of the @@ -219,7 +219,7 @@ TIP: The basic rule for integrating any other script engine is that it must impl [[webflux-view-script-dependencies]] === Requirements -[.small]#<># +[.small]#<># You need to have the script engine on your classpath, the details of which vary by script engine: @@ -239,7 +239,7 @@ through https://www.webjars.org/[WebJars]. [[webflux-view-script-integrate]] === Script Templates -[.small]#<># +[.small]#<># You can declare a `ScriptTemplateConfigurer` bean to specify the script engine to use, the script files to load, what function to call to render templates, and so on. @@ -389,7 +389,7 @@ for more configuration examples. [[webflux-view-httpmessagewriter]] == JSON and XML -[.small]#<># +[.small]#<># For <> purposes, it is useful to be able to alternate between rendering a model with an HTML template or as other formats (such as JSON or XML), diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index 00f71a50baa5..b27d5d09143a 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -594,7 +594,7 @@ The `DefaultServerWebExchange` uses the configured `HttpMessageReader` to parse [[webflux-multipart]] ==== Multipart Data -[.small]#<># +[.small]#<># `ServerWebExchange` exposes the following method for access to multipart data: @@ -626,7 +626,7 @@ content to `Flux` without collecting to a `MultiValueMap`. [[webflux-forwarded-headers]] ==== Forwarded Headers -[.small]#<># +[.small]#<># As a request goes through proxies (such as load balancers), the host, port, and scheme may change, and that makes it a challenge, from a client perspective, to create links that point to the correct @@ -657,7 +657,7 @@ filters, and `ForwardedHeaderTransformer` is used instead. [[webflux-filters]] === Filters -[.small]#<># +[.small]#<># In the <>, you can use a `WebFilter` to apply interception-style logic before and after the rest of the processing chain of filters and the target @@ -668,7 +668,7 @@ the bean declaration or by implementing `Ordered`. [[webflux-filters-cors]] ==== CORS -[.small]#<># +[.small]#<># Spring WebFlux provides fine-grained support for CORS configuration through annotations on controllers. However, when you use it with Spring Security, we advise relying on the built-in @@ -680,7 +680,7 @@ See the section on <> and the <> for more [[webflux-exception-handler]] === Exceptions -[.small]#<># +[.small]#<># In the <>, you can use a `WebExceptionHandler` to handle exceptions from the chain of `WebFilter` instances and the target `WebHandler`. When using the @@ -711,7 +711,7 @@ The following table describes the available `WebExceptionHandler` implementation [[webflux-codecs]] === Codecs -[.small]#<># +[.small]#<># The `spring-web` and `spring-core` modules provide support for serializing and deserializing byte content to and from higher level objects through non-blocking I/O with @@ -847,7 +847,7 @@ To configure all 3 in WebFlux, you'll need to supply a pre-configured instance o [[webflux-codecs-streaming]] ==== Streaming -[.small]#<># +[.small]#<># When streaming to the HTTP response (for example, `text/event-stream`, `application/stream+json`), it is important to send data periodically, in order to @@ -875,7 +875,7 @@ especially the section on <>. [[webflux-logging]] === Logging -[.small]#<># +[.small]#<># DEBUG level logging in Spring WebFlux is designed to be compact, minimal, and human-friendly. It focuses on high value bits of information that are useful over and @@ -907,7 +907,7 @@ while a fully formatted prefix based on that ID is available from [[webflux-logging-sensitive-data]] ==== Sensitive Data -[.small]#<># +[.small]#<># `DEBUG` and `TRACE` logging can log sensitive information. This is why form parameters and headers are masked by default and you must explicitly enable their logging in full. @@ -967,7 +967,7 @@ The following example shows how to do so for client-side requests: [[webflux-dispatcher-handler]] == `DispatcherHandler` -[.small]#<># +[.small]#<># Spring WebFlux, similarly to Spring MVC, is designed around the front controller pattern, where a central `WebHandler`, the `DispatcherHandler`, provides a shared algorithm for @@ -1010,7 +1010,7 @@ The resulting `HttpHandler` is ready for use with a <># +[.small]#<># The `DispatcherHandler` delegates to special beans to process requests and render the appropriate responses. By "`special beans,`" we mean Spring-managed `Object` instances that @@ -1052,7 +1052,7 @@ there are also some other beans detected at a lower level (see [[webflux-framework-config]] === WebFlux Config -[.small]#<># +[.small]#<># Applications can declare the infrastructure beans (listed under <> and @@ -1067,7 +1067,7 @@ many extra convenient options. [[webflux-dispatcher-handler-sequence]] === Processing -[.small]#<># +[.small]#<># `DispatcherHandler` processes requests as follows: @@ -1118,7 +1118,7 @@ as a `HandlerResult`, along with some additional context, and passed to the firs [[webflux-dispatcher-exceptions]] === Exceptions -[.small]#<># +[.small]#<># The `HandlerResult` returned from a `HandlerAdapter` can expose a function for error handling based on some handler-specific mechanism. This error function is called if: @@ -1141,7 +1141,7 @@ See also <> in the "`Annotated Controller`" s [[webflux-viewresolution]] === View Resolution -[.small]#<># +[.small]#<># View resolution enables rendering to a browser with an HTML template and a model without tying you to a specific view technology. In Spring WebFlux, view resolution is @@ -1152,7 +1152,7 @@ instance. The `View` is then used to render the response. [[webflux-viewresolution-handling]] ==== Handling -[.small]#<># +[.small]#<># The `HandlerResult` passed into `ViewResolutionResultHandler` contains the return value from the handler and the model that contains attributes added during request @@ -1188,7 +1188,7 @@ See <> for more on the view technologies integrated with Spring We [[webflux-redirecting-redirect-prefix]] ==== Redirecting -[.small]#<># +[.small]#<># The special `redirect:` prefix in a view name lets you perform a redirect. The `UrlBasedViewResolver` (and sub-classes) recognize this as an instruction that a @@ -1203,7 +1203,7 @@ operate in terms of logical view names. A view name such as [[webflux-multiple-representations]] ==== Content Negotiation -[.small]#<># +[.small]#<># `ViewResolutionResultHandler` supports content negotiation. It compares the request media types with the media types supported by each selected `View`. The first `View` @@ -1220,7 +1220,7 @@ always selected and used if they match the requested media type. [[webflux-controller]] == Annotated Controllers -[.small]#<># +[.small]#<># Spring WebFlux provides an annotation-based programming model, where `@Controller` and `@RestController` components use annotations to express request mappings, request input, @@ -1258,7 +1258,7 @@ In the preceding example, the method returns a `String` to be written to the res [[webflux-ann-controller]] === `@Controller` -[.small]#<># +[.small]#<># You can define controller beans by using a standard Spring bean definition. The `@Controller` stereotype allows for auto-detection and is aligned with Spring general support @@ -1302,7 +1302,7 @@ directly to the response body versus view resolution and rendering with an HTML [[webflux-ann-requestmapping]] === Request Mapping -[.small]#<># +[.small]#<># The `@RequestMapping` annotation is used to map requests to controllers methods. It has various attributes to match by URL, HTTP method, request parameters, headers, and media @@ -1366,7 +1366,7 @@ The following example uses type and method level mappings: [[webflux-ann-requestmapping-uri-templates]] ==== URI Patterns -[.small]#<># +[.small]#<># You can map requests by using glob patterns and wildcards: @@ -1480,7 +1480,7 @@ explicit, and less vulnerable to URL path based exploits. [[webflux-ann-requestmapping-pattern-comparison]] ==== Pattern Comparison -[.small]#<># +[.small]#<># When multiple patterns match a URL, they must be compared to find the best match. This is done with `PathPattern.SPECIFICITY_COMPARATOR`, which looks for patterns that are more specific. @@ -1495,7 +1495,7 @@ sorted last instead. If two patterns are both catch-all, the longer is chosen. [[webflux-ann-requestmapping-consumes]] ==== Consumable Media Types -[.small]#<># +[.small]#<># You can narrow the request mapping based on the `Content-Type` of the request, as the following example shows: @@ -1530,7 +1530,7 @@ TIP: `MediaType` provides constants for commonly used media types -- for example [[webflux-ann-requestmapping-produces]] ==== Producible Media Types -[.small]#<># +[.small]#<># You can narrow the request mapping based on the `Accept` request header and the list of content types that a controller method produces, as the following example shows: @@ -1567,7 +1567,7 @@ TIP: `MediaType` provides constants for commonly used media types -- e.g. [[webflux-ann-requestmapping-params-and-headers]] ==== Parameters and Headers -[.small]#<># +[.small]#<># You can narrow request mappings based on query parameter conditions. You can test for the presence of a query parameter (`myParam`), for its absence (`!myParam`), or for a @@ -1619,7 +1619,7 @@ You can also use the same with request header conditions, as the follwing exampl [[webflux-ann-requestmapping-head-options]] ==== HTTP HEAD, OPTIONS -[.small]#<># +[.small]#<># `@GetMapping` and `@RequestMapping(method=HttpMethod.GET)` support HTTP HEAD transparently for request mapping purposes. Controller methods need not change. @@ -1640,7 +1640,7 @@ is not necessary in the common case. [[webflux-ann-requestmapping-composed]] ==== Custom Annotations -[.small]#<># +[.small]#<># Spring WebFlux supports the use of <> for request mapping. Those are annotations that are themselves meta-annotated with @@ -1661,7 +1661,7 @@ you can check the custom attribute and return your own `RequestCondition`. [[webflux-ann-requestmapping-registration]] ==== Explicit Registrations -[.small]#<># +[.small]#<># You can programmatically register Handler methods, which can be used for dynamic registrations or for advanced cases, such as different instances of the same handler @@ -1718,7 +1718,7 @@ under different URLs. The following example shows how to do so: [[webflux-ann-methods]] === Handler Methods -[.small]#<># +[.small]#<># `@RequestMapping` handler methods have a flexible signature and can choose from a range of supported controller method arguments and return values. @@ -1726,7 +1726,7 @@ supported controller method arguments and return values. [[webflux-ann-arguments]] ==== Method Arguments -[.small]#<># +[.small]#<># The following table shows the supported controller method arguments. @@ -1847,7 +1847,7 @@ and others) and is equivalent to `required=false`. [[webflux-ann-return-types]] ==== Return Values -[.small]#<># +[.small]#<># The following table shows the supported controller method return values. Note that reactive types from libraries such as Reactor, RxJava, <> are @@ -1921,7 +1921,7 @@ generally supported for all return values. [[webflux-ann-typeconversion]] ==== Type Conversion -[.small]#<># +[.small]#<># Some annotated controller method arguments that represent String-based request input (for example, `@RequestParam`, `@RequestHeader`, `@PathVariable`, `@MatrixVariable`, and `@CookieValue`) @@ -1935,7 +1935,7 @@ can be customized through a `WebDataBinder` (see <>) or by r [[webflux-ann-matrix-variables]] ==== Matrix Variables -[.small]#<># +[.small]#<># https://tools.ietf.org/html/rfc3986#section-3.3[RFC 3986] discusses name-value pairs in path segments. In Spring WebFlux, we refer to those as "`matrix variables`" based on an @@ -2070,7 +2070,7 @@ To get all matrix variables, use a `MultiValueMap`, as the following example sho [[webflux-ann-requestparam]] ==== `@RequestParam` -[.small]#<># +[.small]#<># You can use the `@RequestParam` annotation to bind query parameters to a method argument in a controller. The following code snippet shows the usage: @@ -2145,7 +2145,7 @@ with `@RequestParam`. [[webflux-ann-requestheader]] ==== `@RequestHeader` -[.small]#<># +[.small]#<># You can use the `@RequestHeader` annotation to bind a request header to a method argument in a controller. @@ -2206,7 +2206,7 @@ example, a method parameter annotated with `@RequestHeader("Accept")` may be of [[webflux-ann-cookievalue]] ==== `@CookieValue` -[.small]#<># +[.small]#<># You can use the `@CookieValue` annotation to bind the value of an HTTP cookie to a method argument in a controller. @@ -2247,7 +2247,7 @@ Type conversion is applied automatically if the target method parameter type is [[webflux-ann-modelattrib-method-args]] ==== `@ModelAttribute` -[.small]#<># +[.small]#<># You can use the `@ModelAttribute` annotation on a method argument to access an attribute from the model or have it instantiated if not present. The model attribute is also overlain with @@ -2394,7 +2394,7 @@ with `@ModelAttribute`. [[webflux-ann-sessionattributes]] ==== `@SessionAttributes` -[.small]#<># +[.small]#<># `@SessionAttributes` is used to store model attributes in the `WebSession` between requests. It is a type-level annotation that declares session attributes used by a @@ -2479,7 +2479,7 @@ as the following example shows: [[webflux-ann-sessionattribute]] ==== `@SessionAttribute` -[.small]#<># +[.small]#<># If you need access to pre-existing session attributes that are managed globally (that is, outside the controller -- for example, by a filter) and may or may not be present, @@ -2515,7 +2515,7 @@ workflow, consider using `SessionAttributes`, as described in [[webflux-ann-requestattrib]] ==== `@RequestAttribute` -[.small]#<># +[.small]#<># Similarly to `@SessionAttribute`, you can use the `@RequestAttribute` annotation to access pre-existing request attributes created earlier (for example, by a `WebFilter`), @@ -2544,7 +2544,7 @@ as the following example shows: [[webflux-multipart-forms]] ==== Multipart Content -[.small]#<># +[.small]#<># As explained in <>, `ServerWebExchange` provides access to multipart content. The best way to handle a file upload form (for example, from a browser) in a controller @@ -2745,7 +2745,7 @@ To access multipart data sequentially, in streaming fashion, you can use `@Reque [[webflux-ann-requestbody]] ==== `@RequestBody` -[.small]#<># +[.small]#<># You can use the `@RequestBody` annotation to have the request body read and deserialized into an `Object` through an <>. @@ -2819,7 +2819,7 @@ example uses a `BindingResult` argument`: [[webflux-ann-httpentity]] ==== `HttpEntity` -[.small]#<># +[.small]#<># `HttpEntity` is more or less identical to using <> but is based on a container object that exposes request headers and the body. The following example uses an @@ -2845,7 +2845,7 @@ container object that exposes request headers and the body. The following exampl [[webflux-ann-responsebody]] ==== `@ResponseBody` -[.small]#<># +[.small]#<># You can use the `@ResponseBody` annotation on a method to have the return serialized to the response body through an <>. The following @@ -2888,7 +2888,7 @@ configure or customize message writing. [[webflux-ann-responseentity]] ==== `ResponseEntity` -[.small]#<># +[.small]#<># `ResponseEntity` is like <> but with status and headers. For example: @@ -2925,7 +2925,7 @@ Spring offers support for the Jackson JSON library. [[webflux-ann-jsonview]] ===== JSON Views -[.small]#<># +[.small]#<># Spring WebFlux provides built-in support for https://www.baeldung.com/jackson-json-view-annotation[Jackson's Serialization Views], @@ -3003,7 +3003,7 @@ controller method. Use a composite interface if you need to activate multiple vi [[webflux-ann-modelattrib-methods]] === `Model` -[.small]#<># +[.small]#<># You can use the `@ModelAttribute` annotation: @@ -3142,7 +3142,7 @@ as the following example shows: [[webflux-ann-initbinder]] === `DataBinder` -[.small]#<># +[.small]#<># `@Controller` or `@ControllerAdvice` classes can have `@InitBinder` methods, to initialize instances of `WebDataBinder`. Those, in turn, are used to: @@ -3237,7 +3237,7 @@ controller-specific `Formatter` instances, as the following example shows: [[webflux-ann-controller-exceptions]] === Managing Exceptions -[.small]#<># +[.small]#<># `@Controller` and <> classes can have `@ExceptionHandler` methods to handle exceptions from controller methods. The following @@ -3298,7 +3298,7 @@ for more detail. [[webflux-ann-rest-exceptions]] ==== REST API exceptions -[.small]#<># +[.small]#<># A common requirement for REST services is to include error details in the body of the response. The Spring Framework does not automatically do so, because the representation @@ -3316,7 +3316,7 @@ an HTTP status code. [[webflux-ann-controller-advice]] === Controller Advice -[.small]#<># +[.small]#<># Typically, the `@ExceptionHandler`, `@InitBinder`, and `@ModelAttribute` methods apply within the `@Controller` class (or class hierarchy) in which they are declared. If you @@ -3384,7 +3384,7 @@ include::webflux-functional.adoc[leveloffset=+1] [[webflux-uri-building]] == URI Links -[.small]#<># +[.small]#<># This section describes various options available in the Spring Framework to prepare URIs. @@ -3397,7 +3397,7 @@ include::webflux-cors.adoc[leveloffset=+1] [[webflux-web-security]] == Web Security -[.small]#<># +[.small]#<># The https://projects.spring.io/spring-security/[Spring Security] project provides support for protecting web applications from malicious exploits. See the Spring Security @@ -3415,7 +3415,7 @@ include::webflux-view.adoc[leveloffset=+1] [[webflux-caching]] == HTTP Caching -[.small]#<># +[.small]#<># HTTP caching can significantly improve the performance of a web application. HTTP caching revolves around the `Cache-Control` response header and subsequent conditional request @@ -3431,7 +3431,7 @@ This section describes the HTTP caching related options available in Spring WebF [[webflux-caching-cachecontrol]] === `CacheControl` -[.small]#<># +[.small]#<># {api-spring-framework}/http/CacheControl.html[`CacheControl`] provides support for configuring settings related to the `Cache-Control` header and is accepted as an argument @@ -3479,7 +3479,7 @@ use case-oriented approach that focuses on the common scenarios, as the followin [[webflux-caching-etag-lastmodified]] === Controllers -[.small]#<># +[.small]#<># Controllers can add explicit support for HTTP caching. We recommend doing so, since the `lastModified` or `ETag` value for a resource needs to be calculated before it can be compared @@ -3576,7 +3576,7 @@ to 409 (PRECONDITION_FAILED) to prevent concurrent modification. [[webflux-caching-static-resources]] === Static Resources -[.small]#<># +[.small]#<># You should serve static resources with a `Cache-Control` and conditional response headers for optimal performance. See the section on configuring <>. @@ -3586,7 +3586,7 @@ for optimal performance. See the section on configuring <># +[.small]#<># The WebFlux Java configuration declares the components that are required to process requests with annotated controllers or functional endpoints, and it offers an API to @@ -3603,7 +3603,7 @@ gain full control over the configuration through the [[webflux-config-enable]] === Enabling WebFlux Config -[.small]#<># +[.small]#<># You can use the `@EnableWebFlux` annotation in your Java config, as the following example shows: @@ -3632,7 +3632,7 @@ available on the classpath -- for JSON, XML, and others. [[webflux-config-customize]] === WebFlux config API -[.small]#<># +[.small]#<># In your Java configuration, you can implement the `WebFluxConfigurer` interface, as the following example shows: @@ -3663,7 +3663,7 @@ class WebConfig : WebFluxConfigurer { [[webflux-config-conversion]] === Conversion, formatting -[.small]#<># +[.small]#<># By default, formatters for `Number` and `Date` types are installed, including support for the `@NumberFormat` and `@DateTimeFormat` annotations. Full support for the Joda-Time @@ -3706,7 +3706,7 @@ use `FormatterRegistrar` implementations. [[webflux-config-validation]] === Validation -[.small]#<># +[.small]#<># By default, if <> is present on the classpath (for example, the Hibernate Validator), the `LocalValidatorFactoryBean` @@ -3781,7 +3781,7 @@ mark it with `@Primary` in order to avoid conflict with the one declared in the [[webflux-config-content-negotiation]] === Content Type Resolvers -[.small]#<># +[.small]#<># You can configure how Spring WebFlux determines the requested media types for `@Controller` instances from the request. By default, only the `Accept` header is checked, @@ -3819,7 +3819,7 @@ The following example shows how to customize the requested content type resoluti [[webflux-config-message-codecs]] === HTTP message codecs -[.small]#<># +[.small]#<># The following example shows how to customize how the request and response body are read and written: @@ -3870,7 +3870,7 @@ It also automatically registers the following well-known modules if they are det [[webflux-config-view-resolvers]] === View Resolvers -[.small]#<># +[.small]#<># The following example shows how to configure view resolution: @@ -4027,7 +4027,7 @@ See <> for more on the view technologies that are integrated with [[webflux-config-static-resources]] === Static Resources -[.small]#<># +[.small]#<># This option provides a convenient way to serve static resources from a list of {api-spring-framework}/core/io/Resource.html[`Resource`]-based locations. @@ -4142,7 +4142,7 @@ without versions -- for example, from `/jquery/jquery.min.js` to [[webflux-config-path-matching]] === Path Matching -[.small]#<># +[.small]#<># You can customize options related to path matching. For details on the individual options, see the {api-spring-framework}/web/reactive/config/PathMatchConfigurer.html[`PathMatchConfigurer`] javadoc. @@ -4200,7 +4200,7 @@ reliance on it. [[webflux-config-advanced-java]] === Advanced Configuration Mode -[.small]#<># +[.small]#<># `@EnableWebFlux` imports `DelegatingWebFluxConfiguration` that: @@ -4240,7 +4240,7 @@ the classpath. [[webflux-http2]] == HTTP/2 -[.small]#<># +[.small]#<># Servlet 4 containers are required to support HTTP/2, and Spring Framework 5 is compatible with Servlet API 4. From a programming model perspective, there is nothing specific that diff --git a/src/docs/asciidoc/web/webmvc-cors.adoc b/src/docs/asciidoc/web/webmvc-cors.adoc index ada37bb93d75..a5c60e03dffa 100644 --- a/src/docs/asciidoc/web/webmvc-cors.adoc +++ b/src/docs/asciidoc/web/webmvc-cors.adoc @@ -1,6 +1,6 @@ [[mvc-cors]] = CORS -[.small]#<># +[.small]#<># Spring MVC lets you handle CORS (Cross-Origin Resource Sharing). This section describes how to do so. @@ -10,7 +10,7 @@ describes how to do so. [[mvc-cors-intro]] == Introduction -[.small]#<># +[.small]#<># For security reasons, browsers prohibit AJAX calls to resources outside the current origin. For example, you could have your bank account in one tab and evil.com in another. Scripts @@ -27,7 +27,7 @@ powerful workarounds based on IFRAME or JSONP. [[mvc-cors-processing]] == Processing -[.small]#<># +[.small]#<># The CORS specification distinguishes between preflight, simple, and actual requests. To learn how CORS works, you can read @@ -77,7 +77,7 @@ To learn more from the source or make advanced customizations, check the code be [[mvc-cors-controller]] == `@CrossOrigin` -[.small]#<># +[.small]#<># The {api-spring-framework}/web/bind/annotation/CrossOrigin.html[`@CrossOrigin`] annotation enables cross-origin requests on annotated controller methods, @@ -224,7 +224,7 @@ as the following example shows: [[mvc-cors-global]] == Global Configuration -[.small]#<># +[.small]#<># In addition to fine-grained, controller method level configuration, you probably want to define some global CORS configuration, too. You can set URL-based `CorsConfiguration` @@ -248,7 +248,7 @@ should only be used where appropriate. [[mvc-cors-global-java]] === Java Configuration -[.small]#<># +[.small]#<># To enable CORS in the MVC Java config, you can use the `CorsRegistry` callback, as the following example shows: @@ -325,7 +325,7 @@ as the following example shows: [[mvc-cors-filter]] == CORS Filter -[.small]#<># +[.small]#<># You can apply CORS support through the built-in {api-spring-framework}/web/filter/CorsFilter.html[`CorsFilter`]. diff --git a/src/docs/asciidoc/web/webmvc-functional.adoc b/src/docs/asciidoc/web/webmvc-functional.adoc index 0df2d09d7c75..51d8b2b2b05d 100644 --- a/src/docs/asciidoc/web/webmvc-functional.adoc +++ b/src/docs/asciidoc/web/webmvc-functional.adoc @@ -1,6 +1,6 @@ [[webmvc-fn]] = Functional Endpoints -[.small]#<># +[.small]#<># Spring Web MVC includes WebMvc.fn, a lightweight functional programming model in which functions are used to route and handle requests and contracts are designed for immutability. @@ -12,7 +12,7 @@ the same <>. [[webmvc-fn-overview]] == Overview -[.small]#<># +[.small]#<># In WebMvc.fn, an HTTP request is handled with a `HandlerFunction`: a function that takes `ServerRequest` and returns a `ServerResponse`. @@ -110,7 +110,7 @@ If you register the `RouterFunction` as a bean, for instance by exposing it in a [[webmvc-fn-handler-functions]] == HandlerFunction -[.small]#<># +[.small]#<># `ServerRequest` and `ServerResponse` are immutable interfaces that offer JDK 8-friendly access to the HTTP request and response, including headers, body, method, and status code. @@ -375,7 +375,7 @@ See <>. [[webmvc-fn-router-functions]] == `RouterFunction` -[.small]#<># +[.small]#<># Router functions are used to route the requests to the corresponding `HandlerFunction`. Typically, you do not write router functions yourself, but rather use a method on the @@ -581,7 +581,7 @@ We can further improve by using the `nest` method together with `accept`: [[webmvc-fn-running]] == Running a Server -[.small]#<># +[.small]#<># You typically run router functions in a <>-based setup through the <>, which uses Spring configuration to declare the @@ -674,7 +674,7 @@ The following example shows a WebFlux Java configuration: [[webmvc-fn-handler-filter-function]] == Filtering Handler Functions -[.small]#<># +[.small]#<># You can filter handler functions by using the `before`, `after`, or `filter` methods on the routing function builder. diff --git a/src/docs/asciidoc/web/webmvc-view.adoc b/src/docs/asciidoc/web/webmvc-view.adoc index c3e2571bcbf2..92c4ce955040 100644 --- a/src/docs/asciidoc/web/webmvc-view.adoc +++ b/src/docs/asciidoc/web/webmvc-view.adoc @@ -1,6 +1,6 @@ [[mvc-view]] = View Technologies -[.small]#<># +[.small]#<># The use of view technologies in Spring MVC is pluggable, whether you decide to use Thymeleaf, Groovy Markup Templates, JSPs, or other technologies, is primarily a matter @@ -12,7 +12,7 @@ Spring MVC. We assume you are already familiar with <>. [[mvc-view-thymeleaf]] == Thymeleaf -[.small]#<># +[.small]#<># Thymeleaf is a modern server-side Java template engine that emphasizes natural HTML templates that can be previewed in a browser by double-clicking, which is very helpful @@ -32,7 +32,7 @@ See https://www.thymeleaf.org/documentation.html[Thymeleaf+Spring] for more deta [[mvc-view-freemarker]] == FreeMarker -[.small]#<># +[.small]#<># https://freemarker.apache.org/[Apache FreeMarker] is a template engine for generating any kind of text output from HTML to email and others. The Spring Framework has built-in @@ -42,7 +42,7 @@ integration for using Spring MVC with FreeMarker templates. [[mvc-view-freemarker-contextconfig]] === View Configuration -[.small]#<># +[.small]#<># The following example shows how to configure FreeMarker as a view technology: @@ -123,7 +123,7 @@ returns a view name of `welcome`, the resolver looks for the [[mvc-views-freemarker]] === FreeMarker Configuration -[.small]#<># +[.small]#<># You can pass FreeMarker 'Settings' and 'SharedVariables' directly to the FreeMarker `Configuration` object (which is managed by Spring) by setting the appropriate bean @@ -162,7 +162,7 @@ with additional convenience macros for generating form input elements themselves [[mvc-view-bind-macros]] ==== The Bind Macros -[.small]#<># +[.small]#<># A standard set of macros are maintained within the `spring-webmvc.jar` file for FreeMarker, so they are always available to a suitably configured application. @@ -574,7 +574,7 @@ syntax. The following example shows a sample template for an HTML page: [[mvc-view-script]] == Script Views -[.small]#<># +[.small]#<># The Spring Framework has a built-in integration for using Spring MVC with any templating library that can run on top of the @@ -600,7 +600,7 @@ TIP: The basic rule for integrating any other script engine is that it must impl [[mvc-view-script-dependencies]] === Requirements -[.small]#<># +[.small]#<># You need to have the script engine on your classpath, the details of which vary by script engine: @@ -620,7 +620,7 @@ through https://www.webjars.org/[WebJars]. [[mvc-view-script-integrate]] === Script Templates -[.small]#<># +[.small]#<># You can declare a `ScriptTemplateConfigurer` bean to specify the script engine to use, the script files to load, what function to call to render templates, and so on. @@ -2020,7 +2020,7 @@ an external definition (by name) or as a `View` instance from the handler method [[mvc-view-jackson]] == Jackson -[.small]#<># +[.small]#<># Spring offers support for the Jackson JSON library. @@ -2028,7 +2028,7 @@ Spring offers support for the Jackson JSON library. [[mvc-view-json-mapping]] === Jackson-based JSON MVC Views -[.small]#<># +[.small]#<># The `MappingJackson2JsonView` uses the Jackson library's `ObjectMapper` to render the response content as JSON. By default, the entire contents of the model map (with the exception of @@ -2047,7 +2047,7 @@ serializers and deserializers for specific types. [[mvc-view-xml-mapping]] === Jackson-based XML Views -[.small]#<># +[.small]#<># `MappingJackson2XmlView` uses the https://github.com/FasterXML/jackson-dataformat-xml[Jackson XML extension's] `XmlMapper` diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index 71909cf617d5..41be1354b260 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -23,7 +23,7 @@ https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Versio [[mvc-servlet]] == DispatcherServlet -[.small]#<># +[.small]#<># Spring MVC, as many other web frameworks, is designed around the front controller pattern where a central `Servlet`, the `DispatcherServlet`, provides a shared algorithm @@ -237,7 +237,7 @@ TIP: If an application context hierarchy is not required, applications may confi [[mvc-servlet-special-bean-types]] === Special Bean Types -[.small]#<># +[.small]#<># The `DispatcherServlet` delegates to special beans to process requests and render the appropriate responses. By "`special beans`" we mean Spring-managed `Object` instances that @@ -297,7 +297,7 @@ The following table lists the special beans detected by the `DispatcherServlet`: [[mvc-servlet-config]] === Web MVC Config -[.small]#<># +[.small]#<># Applications can declare the infrastructure beans listed in <> that are required to process requests. The `DispatcherServlet` checks the @@ -500,7 +500,7 @@ override the `createDispatcherServlet` method. [[mvc-servlet-sequence]] === Processing -[.small]#<># +[.small]#<># The `DispatcherServlet` processes requests as follows: @@ -610,7 +610,7 @@ declare it as an <> bean or configure it directly on [[mvc-exceptionhandlers]] === Exceptions -[.small]#<># +[.small]#<># If an exception occurs during request mapping or is thrown from a request handler (such as a `@Controller`), the `DispatcherServlet` delegates to a chain of `HandlerExceptionResolver` @@ -721,7 +721,7 @@ however, use both a `WebApplicationInitializer` and a minimal `web.xml`. [[mvc-viewresolver]] === View Resolution -[.small]#<># +[.small]#<># Spring MVC defines the `ViewResolver` and `View` interfaces that let you render models in a browser without tying you to a specific view technology. `ViewResolver` @@ -779,7 +779,7 @@ The following table provides more details on the `ViewResolver` hierarchy: [[mvc-viewresolver-handling]] ==== Handling -[.small]#<># +[.small]#<># You can chain view resolvers by declaring more than one resolver bean and, if necessary, by setting the `order` property to specify ordering. Remember, the higher the order property, @@ -800,7 +800,7 @@ rendering without controller logic. [[mvc-redirecting-redirect-prefix]] ==== Redirecting -[.small]#<># +[.small]#<># The special `redirect:` prefix in a view name lets you perform a redirect. The `UrlBasedViewResolver` (and its subclasses) recognize this as an instruction that a @@ -830,7 +830,7 @@ Servlet/JSP engine. Note that you may also chain multiple view resolvers, instea [[mvc-multiple-representations]] ==== Content Negotiation -[.small]#<># +[.small]#<># {api-spring-framework}/web/servlet/view/ContentNegotiatingViewResolver.html[`ContentNegotiatingViewResolver`] does not resolve views itself but rather delegates @@ -1089,7 +1089,7 @@ request with a simple request parameter. [[mvc-multipart]] === Multipart Resolver -[.small]#<># +[.small]#<># `MultipartResolver` from the `org.springframework.web.multipart` package is a strategy for parsing multipart requests including file uploads. There is one implementation @@ -1162,7 +1162,7 @@ Once the Servlet 3.0 configuration is in place, you can add a bean of type [[mvc-logging]] === Logging -[.small]#<># +[.small]#<># DEBUG-level logging in Spring MVC is designed to be compact, minimal, and human-friendly. It focuses on high-value bits of information that are useful over and @@ -1178,7 +1178,7 @@ not meet the stated goals, please let us know. [[mvc-logging-sensitive-data]] ==== Sensitive Data -[.small]#<># +[.small]#<># DEBUG and TRACE logging may log sensitive information. This is why request parameters and headers are masked by default and their logging in full must be enabled explicitly @@ -1242,7 +1242,7 @@ public class MyInitializer [[filters]] == Filters -[.small]#<># +[.small]#<># The `spring-web` module provides some useful filters: @@ -1269,7 +1269,7 @@ available through the `ServletRequest.getParameter{asterisk}()` family of method [[filters-forwarded-headers]] === Forwarded Headers -[.small]#<># +[.small]#<># As a request goes through proxies (such as load balancers) the host, port, and scheme may change, and that makes it a challenge to create links that point to the correct @@ -1330,7 +1330,7 @@ the filter via `web.xml` or in Spring Boot via a `FilterRegistrationBean` be sur [[filters-cors]] === CORS -[.small]#<># +[.small]#<># Spring MVC provides fine-grained support for CORS configuration through annotations on controllers. However, when used with Spring Security, we advise relying on the built-in @@ -1343,7 +1343,7 @@ See the sections on <> and the <> for more details. [[mvc-controller]] == Annotated Controllers -[.small]#<># +[.small]#<># Spring MVC provides an annotation-based programming model where `@Controller` and `@RestController` components use annotations to express request mappings, request input, @@ -1390,7 +1390,7 @@ programming model described in this section. [[mvc-ann-controller]] === Declaration -[.small]#<># +[.small]#<># You can define controller beans by using a standard Spring bean definition in the Servlet's `WebApplicationContext`. The `@Controller` stereotype allows for auto-detection, @@ -1468,7 +1468,7 @@ change to ``, and with [[mvc-ann-requestmapping]] === Request Mapping -[.small]#<># +[.small]#<># You can use the `@RequestMapping` annotation to map requests to controllers methods. It has various attributes to match by URL, HTTP method, request parameters, headers, and media @@ -1533,7 +1533,7 @@ The following example has type and method level mappings: [[mvc-ann-requestmapping-uri-templates]] ==== URI patterns -[.small]#<># +[.small]#<># You can map requests by using the following global patterns and wildcards: @@ -1633,7 +1633,7 @@ NOTE: Spring MVC uses the `PathMatcher` contract and the `AntPathMatcher` implem [[mvc-ann-requestmapping-pattern-comparison]] ==== Pattern Comparison -[.small]#<># +[.small]#<># When multiple patterns match a URL, they must be compared to find the best match. This is done by using `AntPathMatcher.getPatternComparator(String path)`, which looks for patterns that are more @@ -1714,7 +1714,7 @@ recommendations related to RFD. [[mvc-ann-requestmapping-consumes]] ==== Consumable Media Types -[.small]#<># +[.small]#<># You can narrow the request mapping based on the `Content-Type` of the request, as the following example shows: @@ -1752,7 +1752,7 @@ TIP: `MediaType` provides constants for commonly used media types, such as [[mvc-ann-requestmapping-produces]] ==== Producible Media Types -[.small]#<># +[.small]#<># You can narrow the request mapping based on the `Accept` request header and the list of content types that a controller method produces, as the following example shows: @@ -1792,7 +1792,7 @@ TIP: `MediaType` provides constants for commonly used media types, such as [[mvc-ann-requestmapping-params-and-headers]] ==== Parameters, headers -[.small]#<># +[.small]#<># You can narrow request mappings based on request parameter conditions. You can test for the presence of a request parameter (`myParam`), for the absence of one (`!myParam`), or for a @@ -1846,7 +1846,7 @@ instead. [[mvc-ann-requestmapping-head-options]] ==== HTTP HEAD, OPTIONS -[.small]#<># +[.small]#<># `@GetMapping` (and `@RequestMapping(method=HttpMethod.GET)`) support HTTP HEAD transparently for request mapping. Controller methods do not need to change. @@ -1872,7 +1872,7 @@ is not necessary in the common case. [[mvc-ann-requestmapping-composed]] ==== Custom Annotations -[.small]#<># +[.small]#<># Spring MVC supports the use of <> for request mapping. Those are annotations that are themselves meta-annotated with @@ -1893,7 +1893,7 @@ you can check the custom attribute and return your own `RequestCondition`. [[mvc-ann-requestmapping-registration]] ==== Explicit Registrations -[.small]#<># +[.small]#<># You can programmatically register handler methods, which you can use for dynamic registrations or for advanced cases, such as different instances of the same handler @@ -1946,7 +1946,7 @@ under different URLs. The following example registers a handler method: [[mvc-ann-methods]] === Handler Methods -[.small]#<># +[.small]#<># `@RequestMapping` handler methods have a flexible signature and can choose from a range of supported controller method arguments and return values. @@ -1954,7 +1954,7 @@ supported controller method arguments and return values. [[mvc-ann-arguments]] ==== Method Arguments -[.small]#<># +[.small]#<># The next table describes the supported controller method arguments. Reactive types are not supported for any arguments. @@ -2089,7 +2089,7 @@ and others) and is equivalent to `required=false`. [[mvc-ann-return-types]] ==== Return Values -[.small]#<># +[.small]#<># The next table describes the supported controller method return values. Reactive types are supported for all return values. @@ -2190,7 +2190,7 @@ supported for all return values. [[mvc-ann-typeconversion]] ==== Type Conversion -[.small]#<># +[.small]#<># Some annotated controller method arguments that represent `String`-based request input (such as `@RequestParam`, `@RequestHeader`, `@PathVariable`, `@MatrixVariable`, and `@CookieValue`) @@ -2205,7 +2205,7 @@ See <>. [[mvc-ann-matrix-variables]] ==== Matrix Variables -[.small]#<># +[.small]#<># https://tools.ietf.org/html/rfc3986#section-3.3[RFC 3986] discusses name-value pairs in path segments. In Spring MVC, we refer to those as "`matrix variables`" based on an @@ -2345,7 +2345,7 @@ you need to set a `UrlPathHelper` with `removeSemicolonContent=false` through [[mvc-ann-requestparam]] ==== `@RequestParam` -[.small]#<># +[.small]#<># You can use the `@RequestParam` annotation to bind Servlet request parameters (that is, query parameters or form data) to a method argument in a controller. @@ -2421,7 +2421,7 @@ with `@RequestParam`. [[mvc-ann-requestheader]] ==== `@RequestHeader` -[.small]#<># +[.small]#<># You can use the `@RequestHeader` annotation to bind a request header to a method argument in a controller. @@ -2482,7 +2482,7 @@ example, a method parameter annotated with `@RequestHeader("Accept")` can be of [[mvc-ann-cookievalue]] ==== `@CookieValue` -[.small]#<># +[.small]#<># You can use the `@CookieValue` annotation to bind the value of an HTTP cookie to a method argument in a controller. @@ -2522,7 +2522,7 @@ See <>. [[mvc-ann-modelattrib-method-args]] ==== `@ModelAttribute` -[.small]#<># +[.small]#<># You can use the `@ModelAttribute` annotation on a method argument to access an attribute from the model or have it be instantiated if not present. The model attribute is also overlain with @@ -2701,7 +2701,7 @@ with `@ModelAttribute`. [[mvc-ann-sessionattributes]] ==== `@SessionAttributes` -[.small]#<># +[.small]#<># `@SessionAttributes` is used to store model attributes in the HTTP Servlet session between requests. It is a type-level annotation that declares the session attributes used by a @@ -2786,7 +2786,7 @@ class EditPetForm { [[mvc-ann-sessionattribute]] ==== `@SessionAttribute` -[.small]#<># +[.small]#<># If you need access to pre-existing session attributes that are managed globally (that is, outside the controller -- for example, by a filter) and may or may not be present, @@ -2823,7 +2823,7 @@ workflow, consider using `@SessionAttributes` as described in [[mvc-ann-requestattrib]] ==== `@RequestAttribute` -[.small]#<># +[.small]#<># Similar to `@SessionAttribute`, you can use the `@RequestAttribute` annotations to access pre-existing request attributes created earlier (for example, by a Servlet `Filter` @@ -2950,7 +2950,7 @@ Therefore, we recommend that you use flash attributes mainly for redirect scenar [[mvc-multipart-forms]] ==== Multipart -[.small]#<># +[.small]#<># After a `MultipartResolver` has been <>, the content of POST requests with `multipart/form-data` is parsed and accessible as regular request @@ -3135,7 +3135,7 @@ as the following example shows: [[mvc-ann-requestbody]] ==== `@RequestBody` -[.small]#<># +[.small]#<># You can use the `@RequestBody` annotation to have the request body read and deserialized into an `Object` through an <>. @@ -3189,7 +3189,7 @@ as the following example shows: [[mvc-ann-httpentity]] ==== HttpEntity -[.small]#<># +[.small]#<># `HttpEntity` is more or less identical to using <> but is based on a container object that exposes request headers and body. The following listing shows an example: @@ -3215,7 +3215,7 @@ container object that exposes request headers and body. The following listing sh [[mvc-ann-responsebody]] ==== `@ResponseBody` -[.small]#<># +[.small]#<># You can use the `@ResponseBody` annotation on a method to have the return serialized to the response body through an @@ -3257,7 +3257,7 @@ See <> for details. [[mvc-ann-responseentity]] ==== ResponseEntity -[.small]#<># +[.small]#<># `ResponseEntity` is like <> but with status and headers. For example: @@ -3294,7 +3294,7 @@ Spring offers support for the Jackson JSON library. [[mvc-ann-jsonview]] ===== JSON Views -[.small]#<># +[.small]#<># Spring MVC provides built-in support for https://www.baeldung.com/jackson-json-view-annotation[Jackson's Serialization Views], @@ -3403,7 +3403,7 @@ to the model, as the following example shows: [[mvc-ann-modelattrib-methods]] === Model -[.small]#<># +[.small]#<># You can use the `@ModelAttribute` annotation: @@ -3501,7 +3501,7 @@ unless the return value is a `String` that would otherwise be interpreted as a v [[mvc-ann-initbinder]] === `DataBinder` -[.small]#<># +[.small]#<># `@Controller` or `@ControllerAdvice` classes can have `@InitBinder` methods that initialize instances of `WebDataBinder`, and those, in turn, can: @@ -3595,7 +3595,7 @@ controller-specific `Formatter` implementations, as the following example shows: [[mvc-ann-exceptionhandler]] === Exceptions -[.small]#<># +[.small]#<># `@Controller` and <> classes can have `@ExceptionHandler` methods to handle exceptions from controller methods, as the following example shows: @@ -3844,7 +3844,7 @@ level, <> mechanism. [[mvc-ann-rest-exceptions]] ==== REST API exceptions -[.small]#<># +[.small]#<># A common requirement for REST services is to include error details in the body of the response. The Spring Framework does not automatically do this because the representation @@ -3865,7 +3865,7 @@ necessary methods, and declare it as a Spring bean. [[mvc-ann-controller-advice]] === Controller Advice -[.small]#<># +[.small]#<># Typically `@ExceptionHandler`, `@InitBinder`, and `@ModelAttribute` methods apply within the `@Controller` class (or class hierarchy) in which they are declared. If you want such @@ -3931,7 +3931,7 @@ include::webmvc-functional.adoc[leveloffset=+1] [[mvc-uri-building]] == URI Links -[.small]#<># +[.small]#<># This section describes various options available in the Spring Framework to work with URI's. @@ -4400,7 +4400,7 @@ Spring WebFlux does support all that. [[mvc-ann-async-http-streaming]] === HTTP Streaming -[.small]#<># +[.small]#<># You can use `DeferredResult` and `Callable` for a single asynchronous return value. What if you want to produce multiple asynchronous values and have those written to the @@ -4553,7 +4553,7 @@ customize the status and headers of the response. [[mvc-ann-async-reactive-types]] === Reactive Types -[.small]#<># +[.small]#<># Spring MVC supports use of reactive client libraries in a controller (also read <> in the WebFlux section). @@ -4588,7 +4588,7 @@ suitable under load. If you plan to stream with a reactive type, you should use [[mvc-ann-async-disconnects]] === Disconnects -[.small]#<># +[.small]#<># The Servlet API does not provide any notification when a remote client goes away. Therefore, while streaming to the response, whether through <> @@ -4656,7 +4656,7 @@ include::webmvc-cors.adoc[leveloffset=+1] [[mvc-web-security]] == Web Security -[.small]#<># +[.small]#<># The https://projects.spring.io/spring-security/[Spring Security] project provides support for protecting web applications from malicious exploits. See the Spring Security @@ -4674,7 +4674,7 @@ https://hdiv.org/[HDIV] is another web security framework that integrates with S [[mvc-caching]] == HTTP Caching -[.small]#<># +[.small]#<># HTTP caching can significantly improve the performance of a web application. HTTP caching revolves around the `Cache-Control` response header and, subsequently, conditional request @@ -4690,7 +4690,7 @@ This section describes the HTTP caching-related options that are available in Sp [[mvc-caching-cachecontrol]] === `CacheControl` -[.small]#<># +[.small]#<># {api-spring-framework}/http/CacheControl.html[`CacheControl`] provides support for configuring settings related to the `Cache-Control` header and is accepted as an argument @@ -4746,7 +4746,7 @@ works as follows: [[mvc-caching-etag-lastmodified]] === Controllers -[.small]#<># +[.small]#<># Controllers can add explicit support for HTTP caching. We recommended doing so, since the `lastModified` or `ETag` value for a resource needs to be calculated before it can be compared @@ -4843,7 +4843,7 @@ to 412 (PRECONDITION_FAILED), to prevent concurrent modification. [[mvc-caching-static-resources]] === Static Resources -[.small]#<># +[.small]#<># You should serve static resources with a `Cache-Control` and conditional response headers for optimal performance. See the section on configuring <>. @@ -4863,7 +4863,7 @@ include::webmvc-view.adoc[leveloffset=+1] [[mvc-config]] == MVC Config -[.small]#<># +[.small]#<># The MVC Java configuration and the MVC XML namespace provide default configuration suitable for most applications and a configuration API to customize it. @@ -4879,7 +4879,7 @@ and <>. [[mvc-config-enable]] === Enable MVC Configuration -[.small]#<># +[.small]#<># In Java configuration, you can use the `@EnableWebMvc` annotation to enable MVC configuration, as the following example shows: @@ -4928,7 +4928,7 @@ available on the classpath (for example, payload converters for JSON, XML, and o [[mvc-config-customize]] === MVC Config API -[.small]#<># +[.small]#<># In Java configuration, you can implement the `WebMvcConfigurer` interface, as the following example shows: @@ -4963,7 +4963,7 @@ sub-elements are available. [[mvc-config-conversion]] === Type Conversion -[.small]#<># +[.small]#<># By default formatters, for `Number` and `Date` types are installed, including support for the `@NumberFormat` and `@DateTimeFormat` annotations. Full support for the Joda-Time @@ -5045,7 +5045,7 @@ FormatterRegistrar implementations. [[mvc-config-validation]] === Validation -[.small]#<># +[.small]#<># By default, if <> is present on the classpath (for example, Hibernate Validator), the `LocalValidatorFactoryBean` is @@ -5191,7 +5191,7 @@ The following example shows how to achieve the same configuration in XML: [[mvc-config-content-negotiation]] === Content Types -[.small]#<># +[.small]#<># You can configure how Spring MVC determines the requested media types from the request (for example, `Accept` header, URL path extension, query parameter, and others). @@ -5257,7 +5257,7 @@ The following example shows how to achieve the same configuration in XML: [[mvc-config-message-converters]] === Message Converters -[.small]#<># +[.small]#<># You can customize `HttpMessageConverter` in Java configuration by overriding {api-spring-framework}/web/servlet/config/annotation/WebMvcConfigurer.html#configureMessageConverters-java.util.List-[`configureMessageConverters()`] @@ -5403,7 +5403,7 @@ using the `` element: [[mvc-config-view-resolvers]] === View Resolvers -[.small]#<># +[.small]#<># The MVC configuration simplifies the registration of view resolvers. @@ -5523,7 +5523,7 @@ as the following example shows: [[mvc-config-static-resources]] === Static Resources -[.small]#<># +[.small]#<># This option provides a convenient way to serve static resources from a list of {api-spring-framework}/core/io/Resource.html[`Resource`]-based locations. @@ -5754,7 +5754,7 @@ The following example shows how to achieve the same configuration in XML: [[mvc-config-path-matching]] === Path Matching -[.small]#<># +[.small]#<># You can customize options related to path matching and treatment of the URL. For details on the individual options, see the @@ -5843,7 +5843,7 @@ The following example shows how to achieve the same configuration in XML: [[mvc-config-advanced-java]] === Advanced Java Config -[.small]#<># +[.small]#<># `@EnableWebMvc` imports `DelegatingWebMvcConfiguration`, which: @@ -5918,7 +5918,7 @@ by letting it be detected through a `` declaration. [[mvc-http2]] == HTTP/2 -[.small]#<># +[.small]#<># Servlet 4 containers are required to support HTTP/2, and Spring Framework 5 is compatible with Servlet API 4. From a programming model perspective, there is nothing specific that diff --git a/src/docs/asciidoc/web/websocket.adoc b/src/docs/asciidoc/web/websocket.adoc index ca9dfa19b11d..feaebc0d3ccf 100644 --- a/src/docs/asciidoc/web/websocket.adoc +++ b/src/docs/asciidoc/web/websocket.adoc @@ -1,7 +1,7 @@ [[websocket]] = WebSockets :doc-spring-security: {doc-root}/spring-security/site/docs/current/reference -[.small]#<># +[.small]#<># This part of the reference documentation covers support for Servlet stack, WebSocket messaging that includes raw WebSocket interactions, WebSocket emulation through SockJS, and @@ -14,7 +14,7 @@ include::websocket-intro.adoc[leveloffset=+1] [[websocket-server]] == WebSocket API -[.small]#<># +[.small]#<># The Spring Framework provides a WebSocket API that you can use to write client- and server-side applications that handle WebSocket messages. @@ -23,7 +23,7 @@ server-side applications that handle WebSocket messages. [[websocket-server-handler]] === `WebSocketHandler` -[.small]#<># +[.small]#<># Creating a WebSocket server is as simple as implementing `WebSocketHandler` or, more likely, extending either `TextWebSocketHandler` or `BinaryWebSocketHandler`. The following @@ -112,7 +112,7 @@ sending. One option is to wrap the `WebSocketSession` with [[websocket-server-handshake]] === WebSocket Handshake -[.small]#<># +[.small]#<># The easiest way to customize the initial HTTP WebSocket handshake request is through a `HandshakeInterceptor`, which exposes methods for "`before`" and "`after`" the handshake. @@ -258,7 +258,7 @@ Java initialization API. The following example shows how to do so: [[websocket-server-runtime-configuration]] === Server Configuration -[.small]#<># +[.small]#<># Each underlying WebSocket engine exposes configuration properties that control runtime characteristics, such as the size of message buffer sizes, idle timeout, @@ -385,7 +385,7 @@ The following example shows the XML configuration equivalent of the preceding ex [[websocket-server-allowed-origins]] === Allowed Origins -[.small]#<># +[.small]#<># As of Spring Framework 4.1.5, the default behavior for WebSocket and SockJS is to accept only same-origin requests. It is also possible to allow all or a specified list of origins. From 26d800cc936a9e1f6d326c3b48022267bb30ed0f Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 27 Nov 2019 07:35:45 +0000 Subject: [PATCH 0120/2315] Fix empty payload handling in RSocketRequester Closes gh-24088 --- .../rsocket/DefaultRSocketRequester.java | 51 ++++++++++--------- .../rsocket/DefaultRSocketRequesterTests.java | 29 +++++++---- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java index 249ce6106e7b..be879bbcfbeb 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequester.java @@ -57,7 +57,7 @@ final class DefaultRSocketRequester implements RSocketRequester { private final RSocketStrategies strategies; - private final DataBuffer emptyDataBuffer; + private final Mono emptyBufferMono; DefaultRSocketRequester( @@ -73,7 +73,7 @@ final class DefaultRSocketRequester implements RSocketRequester { this.dataMimeType = dataMimeType; this.metadataMimeType = metadataMimeType; this.strategies = strategies; - this.emptyDataBuffer = this.strategies.dataBufferFactory().wrap(new byte[0]); + this.emptyBufferMono = Mono.just(this.strategies.dataBufferFactory().wrap(new byte[0])); } @@ -193,7 +193,7 @@ else if (adapter != null) { } if (isVoid(elementType) || (adapter != null && adapter.isNoValue())) { - this.payloadMono = firstPayload(Mono.when(publisher).then(Mono.just(emptyDataBuffer))); + this.payloadMono = Mono.when(publisher).then(firstPayload(emptyBufferMono)); this.payloadFlux = null; return; } @@ -204,7 +204,7 @@ else if (adapter != null) { if (adapter != null && !adapter.isMultiValue()) { Mono data = Mono.from(publisher) .map(value -> encodeData(value, elementType, encoder)) - .defaultIfEmpty(emptyDataBuffer); + .switchIfEmpty(emptyBufferMono); this.payloadMono = firstPayload(data); this.payloadFlux = null; return; @@ -213,7 +213,7 @@ else if (adapter != null) { this.payloadMono = null; this.payloadFlux = Flux.from(publisher) .map(value -> encodeData(value, elementType, encoder)) - .defaultIfEmpty(emptyDataBuffer) + .switchIfEmpty(emptyBufferMono) .switchOnFirst((signal, inner) -> { DataBuffer data = signal.get(); if (data != null) { @@ -250,12 +250,7 @@ private Mono firstPayload(Mono encodedData) { @Override public Mono send() { - return getPayloadMonoRequired().flatMap(rsocket::fireAndForget); - } - - private Mono getPayloadMonoRequired() { - Assert.state(this.payloadFlux == null, "No RSocket interaction model for Flux request to Mono response."); - return this.payloadMono != null ? this.payloadMono : firstPayload(Mono.just(emptyDataBuffer)); + return getPayloadMono().flatMap(rsocket::fireAndForget); } @Override @@ -268,19 +263,9 @@ public Mono retrieveMono(ParameterizedTypeReference dataTypeRef) { return retrieveMono(ResolvableType.forType(dataTypeRef)); } - @Override - public Flux retrieveFlux(Class dataType) { - return retrieveFlux(ResolvableType.forClass(dataType)); - } - - @Override - public Flux retrieveFlux(ParameterizedTypeReference dataTypeRef) { - return retrieveFlux(ResolvableType.forType(dataTypeRef)); - } - @SuppressWarnings("unchecked") private Mono retrieveMono(ResolvableType elementType) { - Mono payloadMono = getPayloadMonoRequired().flatMap(rsocket::requestResponse); + Mono payloadMono = getPayloadMono().flatMap(rsocket::requestResponse); if (isVoid(elementType)) { return (Mono) payloadMono.then(); @@ -291,11 +276,22 @@ private Mono retrieveMono(ResolvableType elementType) { .map(dataBuffer -> decoder.decode(dataBuffer, elementType, dataMimeType, EMPTY_HINTS)); } + @Override + public Flux retrieveFlux(Class dataType) { + return retrieveFlux(ResolvableType.forClass(dataType)); + } + + @Override + public Flux retrieveFlux(ParameterizedTypeReference dataTypeRef) { + return retrieveFlux(ResolvableType.forType(dataTypeRef)); + } + @SuppressWarnings("unchecked") private Flux retrieveFlux(ResolvableType elementType) { - Flux payloadFlux = this.payloadMono != null ? - this.payloadMono.flatMapMany(rsocket::requestStream) : - rsocket.requestChannel(this.payloadFlux); + + Flux payloadFlux = (this.payloadFlux != null ? + rsocket.requestChannel(this.payloadFlux) : + getPayloadMono().flatMapMany(rsocket::requestStream)); if (isVoid(elementType)) { return payloadFlux.thenMany(Flux.empty()); @@ -306,6 +302,11 @@ private Flux retrieveFlux(ResolvableType elementType) { (T) decoder.decode(dataBuffer, elementType, dataMimeType, EMPTY_HINTS)); } + private Mono getPayloadMono() { + Assert.state(this.payloadFlux == null, "No RSocket interaction with Flux request and Mono response."); + return this.payloadMono != null ? this.payloadMono : firstPayload(emptyBufferMono); + } + private DataBuffer retainDataAndReleasePayload(Payload payload) { return PayloadUtils.retainDataAndReleasePayload(payload, bufferFactory()); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java index 7392d901eeb3..878f3776c76f 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java @@ -145,15 +145,6 @@ public void sendWithoutData() { assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEqualTo(""); } - @Test - public void sendMonoWithoutData() { - this.requester.route("toA").retrieveMono(String.class).block(Duration.ofSeconds(5)); - - assertThat(this.rsocket.getSavedMethodName()).isEqualTo("requestResponse"); - assertThat(this.rsocket.getSavedPayload().getMetadataUtf8()).isEqualTo("toA"); - assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEqualTo(""); - } - @Test public void testSendWithAsyncMetadata() { @@ -205,6 +196,15 @@ public void retrieveMonoVoid() { assertThat(this.rsocket.getSavedMethodName()).isEqualTo("requestResponse"); } + @Test + public void retrieveMonoWithoutData() { + this.requester.route("toA").retrieveMono(String.class).block(Duration.ofSeconds(5)); + + assertThat(this.rsocket.getSavedMethodName()).isEqualTo("requestResponse"); + assertThat(this.rsocket.getSavedPayload().getMetadataUtf8()).isEqualTo("toA"); + assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEqualTo(""); + } + @Test public void retrieveFlux() { String[] values = new String[] {"bodyA", "bodyB", "bodyC"}; @@ -227,11 +227,20 @@ public void retrieveFluxVoid() { assertThat(this.rsocket.getSavedMethodName()).isEqualTo("requestStream"); } + @Test + public void retrieveFluxWithoutData() { + this.requester.route("toA").retrieveFlux(String.class).blockLast(Duration.ofSeconds(5)); + + assertThat(this.rsocket.getSavedMethodName()).isEqualTo("requestStream"); + assertThat(this.rsocket.getSavedPayload().getMetadataUtf8()).isEqualTo("toA"); + assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEqualTo(""); + } + @Test public void fluxToMonoIsRejected() { assertThatIllegalStateException() .isThrownBy(() -> this.requester.route("").data(Flux.just("a", "b")).retrieveMono(String.class)) - .withMessage("No RSocket interaction model for Flux request to Mono response."); + .withMessage("No RSocket interaction with Flux request and Mono response."); } private Payload toPayload(String value) { From 40331eaca3e2fee23e7d7e563f9e73c67a2e7d83 Mon Sep 17 00:00:00 2001 From: ryenus Date: Wed, 27 Nov 2019 10:08:36 +0800 Subject: [PATCH 0121/2315] Fix consecutive-word duplications in documentation See gh-24089 --- src/docs/asciidoc/core/core-aop-api.adoc | 2 +- src/docs/asciidoc/rsocket.adoc | 2 +- src/docs/asciidoc/web/webflux-webclient.adoc | 2 +- src/docs/asciidoc/web/webflux.adoc | 2 +- src/docs/asciidoc/web/webmvc-view.adoc | 2 +- src/docs/asciidoc/web/webmvc.adoc | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/docs/asciidoc/core/core-aop-api.adoc b/src/docs/asciidoc/core/core-aop-api.adoc index 570fc830b68b..02b766898671 100644 --- a/src/docs/asciidoc/core/core-aop-api.adoc +++ b/src/docs/asciidoc/core/core-aop-api.adoc @@ -576,7 +576,7 @@ methods can be combined in a single class. The following listing shows the final NOTE: If a throws-advice method throws an exception itself, it overrides the original exception (that is, it changes the exception thrown to the user). The overriding -exception is typically a RuntimeException, which is is compatible with any method +exception is typically a RuntimeException, which is compatible with any method signature. However, if a throws-advice method throws a checked exception, it must match the declared exceptions of the target method and is, hence, to some degree coupled to specific target method signatures. _Do not throw an undeclared checked diff --git a/src/docs/asciidoc/rsocket.adoc b/src/docs/asciidoc/rsocket.adoc index 752699289eb9..29c24ed38b48 100644 --- a/src/docs/asciidoc/rsocket.adoc +++ b/src/docs/asciidoc/rsocket.adoc @@ -79,7 +79,7 @@ The responder may then return `PAYLOAD` frames with response messages, and in th of `REQUEST_CHANNEL` the requester may also send `PAYLOAD` frames with more request messages. -When a request involves a stream of messages such as as `Request-Stream` and `Channel`, +When a request involves a stream of messages such as `Request-Stream` and `Channel`, the responder must respect demand signals from the requester. Demand is expressed as a number of messages. Initial demand is specified in `REQUEST_STREAM` and `REQUEST_CHANNEL` frames. Subsequent demand is signaled via `REQUEST_N` frames. diff --git a/src/docs/asciidoc/web/webflux-webclient.adoc b/src/docs/asciidoc/web/webflux-webclient.adoc index d0daf71b3b27..5ef50e1c1903 100644 --- a/src/docs/asciidoc/web/webflux-webclient.adoc +++ b/src/docs/asciidoc/web/webflux-webclient.adoc @@ -662,7 +662,7 @@ or, in the case of a `Resource`, based on the file extension. If necessary, you explicitly provide the `MediaType` to use for each part through one of the overloaded builder `part` methods. -Once a `MultiValueMap` is prepared, the easiest way to pass it to the the `WebClient` is +Once a `MultiValueMap` is prepared, the easiest way to pass it to the `WebClient` is through the `body` method, as the following example shows: [source,java,indent=0,subs="verbatim,quotes",role="primary"] diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index b27d5d09143a..92a8108968c0 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -868,7 +868,7 @@ when consumed to avoid memory leaks. WebFlux applications generally do not need to be concerned with such issues, unless they consume or produce data buffers directly, as opposed to relying on codecs to convert to and from higher level objects, or unless they choose to create custom codecs. For such -cases please review the the information in <>, +cases please review the information in <>, especially the section on <>. diff --git a/src/docs/asciidoc/web/webmvc-view.adoc b/src/docs/asciidoc/web/webmvc-view.adoc index 92c4ce955040..2856ea3b2b53 100644 --- a/src/docs/asciidoc/web/webmvc-view.adoc +++ b/src/docs/asciidoc/web/webmvc-view.adoc @@ -1716,7 +1716,7 @@ the `WEB-INF/defs` directory. At initialization of the `WebApplicationContext`, files are loaded, and the definitions factory are initialized. After that has been done, the Tiles included in the definition files can be used as views within your Spring web application. To be able to use the views, you have to have a `ViewResolver` -as with any other view technology used with Spring. You can can use either of two +as with any other view technology used with Spring. You can use either of two implementations, the `UrlBasedViewResolver` and the `ResourceBundleViewResolver`. You can specify locale-specific Tiles definitions by adding an underscore and then diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index 41be1354b260..c993a6de3f51 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -3739,7 +3739,7 @@ level, <> mechanism. | `javax.servlet.ServletRequest`, `javax.servlet.ServletResponse` | Choose any specific request or response type (for example, `ServletRequest` or - `HttpServletRequest` or or Spring's `MultipartRequest` or `MultipartHttpServletRequest`). + `HttpServletRequest` or Spring's `MultipartRequest` or `MultipartHttpServletRequest`). | `javax.servlet.http.HttpSession` | Enforces the presence of a session. As a consequence, such an argument is never `null`. + @@ -4284,7 +4284,7 @@ as the following example shows: } ---- -The return value can then be obtained by running the the given task through the +The return value can then be obtained by running the given task through the <> `TaskExecutor`. From 52630b06f5c55bc14a7c91a15ee78e6f6cb0d30f Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 27 Nov 2019 11:52:43 +0100 Subject: [PATCH 0122/2315] Upgrade to Reactor Dysprosium-SR2 Closes gh-24037 --- build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 3072f866095f..6b79eca0e9cb 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ configure(allprojects) { project -> imports { mavenBom "com.fasterxml.jackson:jackson-bom:2.10.1" mavenBom "io.netty:netty-bom:4.1.43.Final" - mavenBom "io.projectreactor:reactor-bom:Dysprosium-BUILD-SNAPSHOT" + mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR2" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" mavenBom "org.eclipse.jetty:jetty-bom:9.4.24.v20191120" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.60" @@ -296,7 +296,6 @@ configure(allprojects) { project -> repositories { mavenCentral() maven { url "https://repo.spring.io/libs-spring-framework-build" } - maven { url "https://repo.spring.io/snapshot" } } } configurations.all { From 62ca7c4e8fa26d7eaa413c57aa232321d94d47f8 Mon Sep 17 00:00:00 2001 From: stsypanov Date: Sat, 23 Nov 2019 23:19:42 +0200 Subject: [PATCH 0123/2315] Hoist constant byte[] out of loop --- .../java/org/springframework/beans/ExtendedBeanInfo.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java index 13320a607df9..3639949dbcbe 100644 --- a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java +++ b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java @@ -208,7 +208,7 @@ private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, C } private String propertyNameFor(Method method) { - return Introspector.decapitalize(method.getName().substring(3, method.getName().length())); + return Introspector.decapitalize(method.getName().substring(3)); } @@ -534,11 +534,13 @@ static class PropertyDescriptorComparator implements Comparator Date: Thu, 28 Nov 2019 10:07:20 +0900 Subject: [PATCH 0124/2315] Remove duplicate checks in ResponseCookieTests --- .../test/java/org/springframework/http/ResponseCookieTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-web/src/test/java/org/springframework/http/ResponseCookieTests.java b/spring-web/src/test/java/org/springframework/http/ResponseCookieTests.java index d52c696f2e6b..5320500b0f1a 100644 --- a/spring-web/src/test/java/org/springframework/http/ResponseCookieTests.java +++ b/spring-web/src/test/java/org/springframework/http/ResponseCookieTests.java @@ -72,7 +72,7 @@ public void domainChecks() { Arrays.asList("abc", "abc.org", "abc-def.org", "abc3.org", ".abc.org") .forEach(domain -> ResponseCookie.from("n", "v").domain(domain).build()); - Arrays.asList("-abc.org", "abc.org.", "abc.org-", "-abc.org", "abc.org-") + Arrays.asList("-abc.org", "abc.org.", "abc.org-") .forEach(domain -> assertThatThrownBy(() -> ResponseCookie.from("n", "v").domain(domain).build()) .hasMessageContaining("Invalid first/last char")); From 6f3909f2f044b59fe792bb4f1785e512edf65bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Thu, 28 Nov 2019 09:44:35 +0100 Subject: [PATCH 0125/2315] Upgrade to Kotlin 1.3.61 Closes gh-24006 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 6b79eca0e9cb..317eb5c7cde4 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { plugins { id 'io.spring.dependency-management' version '1.0.8.RELEASE' apply false - id 'org.jetbrains.kotlin.jvm' version '1.3.60' apply false + id 'org.jetbrains.kotlin.jvm' version '1.3.61' apply false id 'org.jetbrains.dokka' version '0.9.18' apply false id 'org.asciidoctor.convert' version '1.5.8' id 'io.spring.nohttp' version '0.0.3.RELEASE' @@ -48,7 +48,7 @@ configure(allprojects) { project -> mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR2" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" mavenBom "org.eclipse.jetty:jetty-bom:9.4.24.v20191120" - mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.60" + mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.61" mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.2" mavenBom "org.junit:junit-bom:5.5.2" } From d8f7ed133f823d393b1833a080484eb7ca9c781d Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 28 Nov 2019 10:48:13 +0100 Subject: [PATCH 0126/2315] Puslish Gradle metadata Closes gh-23503 --- build.gradle | 2 +- settings.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 317eb5c7cde4..760ae2e04ae0 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ plugins { id 'io.spring.nohttp' version '0.0.3.RELEASE' id 'de.undercouch.download' version '4.0.0' id 'com.gradle.build-scan' version '2.4.2' - id "com.jfrog.artifactory" version '4.9.8' apply false + id "com.jfrog.artifactory" version '4.11.0' apply false id "io.freefair.aspectj" version "4.1.1" apply false id "com.github.ben-manes.versions" version "0.24.0" } diff --git a/settings.gradle b/settings.gradle index 923271aace3c..132e7e40d765 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,7 +4,7 @@ pluginManagement { maven { url 'https://repo.spring.io/plugins-release' } } } - +enableFeaturePreview("GRADLE_METADATA") apply from: "$rootDir/gradle/build-cache-settings.gradle" include "spring-aop" From df2ed75df0c0b2a8ebb14d0aacf1fafe4f9f4888 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 28 Nov 2019 10:40:28 +0000 Subject: [PATCH 0127/2315] MultipartBodyBuilder Javadoc update Closes gh-24031 --- .../http/client/MultipartBodyBuilder.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java b/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java index 1d35cd34a402..f4031db2955d 100644 --- a/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java +++ b/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java @@ -39,11 +39,21 @@ import org.springframework.util.MultiValueMap; /** - * Builder for the body of a multipart request, producing - * {@code MultiValueMap}, which can be provided to the - * {@code WebClient} through the {@code body} method. + * Prepare the body of a multipart request, resulting in a + * {@code MultiValueMap}. Parts may be concrete values or + * via asynchronous types such as Reactor {@code Mono}, {@code Flux}, and + * others registered in the + * {@link org.springframework.core.ReactiveAdapterRegistry ReactiveAdapterRegistry}. * - * Examples: + *

This builder is intended for use with the reactive + * {@link org.springframework.web.reactive.function.client.WebClient WebClient}. + * For multipart requests with the {@code RestTemplate}, simply create and + * populate a {@code MultiValueMap} as shown in the Javadoc for + * {@link org.springframework.http.converter.FormHttpMessageConverter FormHttpMessageConverter} + * and in the + * reference docs. + * + *

Below are examples of using this builder: *

  *
  * // Add form field

From b44daa8b71a60b46da90c9fcd5b7ad13d2047167 Mon Sep 17 00:00:00 2001
From: Rossen Stoyanchev 
Date: Thu, 28 Nov 2019 11:28:49 +0000
Subject: [PATCH 0128/2315] Remove the few remaining usages of UriTemplate

Also update Javadoc of UriTemplate to point to UriComponentsBuilder and
UriBuilderFactory as more flexible options.

See gh-24094
---
 .../springframework/http/RequestEntity.java   |  8 +++++--
 .../springframework/web/util/UriTemplate.java | 21 ++++++++++++-------
 .../http/RequestEntityTests.java              |  8 +++----
 .../reactive/result/view/RequestContext.java  |  7 +++----
 .../result/view/DummyMacroRequestContext.java |  7 ++++---
 .../web/servlet/support/RequestContext.java   |  7 +++----
 .../view/DummyMacroRequestContext.java        |  9 ++++----
 7 files changed, 38 insertions(+), 29 deletions(-)

diff --git a/spring-web/src/main/java/org/springframework/http/RequestEntity.java b/spring-web/src/main/java/org/springframework/http/RequestEntity.java
index 6ba2f48e9de6..19133210db7f 100644
--- a/spring-web/src/main/java/org/springframework/http/RequestEntity.java
+++ b/spring-web/src/main/java/org/springframework/http/RequestEntity.java
@@ -44,9 +44,13 @@
  * 
* *

If you would like to provide a URI template with variables, consider using - * {@link org.springframework.web.util.UriTemplate}: + * {@link org.springframework.web.util.DefaultUriBuilderFactory DefaultUriBuilderFactory}: *

- * URI uri = new UriTemplate("https://example.com/{foo}").expand("bar");
+ * // Create shared factory
+ * UriBuilderFactory factory = new DefaultUriBuilderFactory();
+ *
+ * // Use factory to create URL from template
+ * URI uri = factory.uriString("https://example.com/{foo}").build("bar");
  * RequestEntity<MyRequest> request = RequestEntity.post(uri).accept(MediaType.APPLICATION_JSON).body(body);
  * 
* diff --git a/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java b/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java index d9ccf3b995af..6290db6ef8d4 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -30,14 +30,19 @@ import org.springframework.util.Assert; /** - * Represents a URI template. A URI template is a URI-like String that contains variables - * enclosed by braces ({@code {}}) which can be expanded to produce an actual URI. + * Representation of a URI template that can be expanded with URI variables via + * {@link #expand(Map)}, {@link #expand(Object[])}, or matched to a URL via + * {@link #match(String)}. This class is designed to be thread-safe and + * reusable, and allows any number of expand or match calls. * - *

See {@link #expand(Map)}, {@link #expand(Object[])}, and {@link #match(String)} - * for example usages. - * - *

This class is designed to be thread-safe and reusable, allowing for any number - * of expand or match calls. + *

Note: this class uses {@link UriComponentsBuilder} + * internally to expand URI templates, and is merely a shortcut for already + * prepared URI templates. For more dynamic preparation and extra flexibility, + * e.g. around URI encoding, consider using {@code UriComponentsBuilder} or the + * higher level {@link DefaultUriBuilderFactory} which adds several encoding + * modes on top of {@code UriComponentsBuilder}. See the + * reference docs + * for further details. * * @author Arjen Poutsma * @author Juergen Hoeller diff --git a/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java b/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java index 91bd36691969..bd9162733144 100644 --- a/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java @@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test; import org.springframework.core.ParameterizedTypeReference; -import org.springframework.web.util.UriTemplate; +import org.springframework.web.util.UriComponentsBuilder; import static org.assertj.core.api.Assertions.assertThat; @@ -58,7 +58,7 @@ public void normal() throws URISyntaxException { @Test public void uriVariablesExpansion() throws URISyntaxException { - URI uri = new UriTemplate("https://example.com/{foo}").expand("bar"); + URI uri = UriComponentsBuilder.fromUriString("https://example.com/{foo}").buildAndExpand("bar").toUri(); RequestEntity.get(uri).accept(MediaType.TEXT_PLAIN).build(); String url = "https://www.{host}.com/{path}"; @@ -66,7 +66,7 @@ public void uriVariablesExpansion() throws URISyntaxException { String path = "foo/bar"; URI expected = new URI("https://www.example.com/foo/bar"); - uri = new UriTemplate(url).expand(host, path); + uri = UriComponentsBuilder.fromUriString(url).buildAndExpand(host, path).toUri(); RequestEntity entity = RequestEntity.get(uri).build(); assertThat(entity.getUrl()).isEqualTo(expected); @@ -74,7 +74,7 @@ public void uriVariablesExpansion() throws URISyntaxException { uriVariables.put("host", host); uriVariables.put("path", path); - uri = new UriTemplate(url).expand(uriVariables); + uri = UriComponentsBuilder.fromUriString(url).buildAndExpand(uriVariables).toUri(); entity = RequestEntity.get(uri).build(); assertThat(entity.getUrl()).isEqualTo(expected); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RequestContext.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RequestContext.java index 0364aa079ef4..f0510906f3ec 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RequestContext.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RequestContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -37,7 +37,7 @@ import org.springframework.web.bind.EscapedErrors; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.util.HtmlUtils; -import org.springframework.web.util.UriTemplate; +import org.springframework.web.util.UriComponentsBuilder; /** * Context holder for request-specific state, like the {@link MessageSource} to @@ -218,8 +218,7 @@ public String getContextUrl(String relativeUrl) { */ public String getContextUrl(String relativeUrl, Map params) { String url = StringUtils.applyRelativePath(getContextPath() + "/", relativeUrl); - UriTemplate template = new UriTemplate(url); - url = template.expand(params).toASCIIString(); + url = UriComponentsBuilder.fromUriString(url).buildAndExpand(params).encode().toUri().toASCIIString(); return getExchange().transformUrl(url); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DummyMacroRequestContext.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DummyMacroRequestContext.java index a7f624bd7809..d7e91cdbcc59 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DummyMacroRequestContext.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DummyMacroRequestContext.java @@ -22,7 +22,8 @@ import org.springframework.context.support.GenericApplicationContext; import org.springframework.ui.ModelMap; import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.UriTemplate; +import org.springframework.web.util.UriComponents; +import org.springframework.web.util.UriComponentsBuilder; /** * Dummy request context used for FreeMarker macro tests. @@ -107,8 +108,8 @@ public String getContextUrl(String relativeUrl) { * @see org.springframework.web.reactive.result.view.RequestContext#getContextUrl(String, Map) */ public String getContextUrl(String relativeUrl, Map params) { - UriTemplate template = new UriTemplate(relativeUrl); - return getContextPath() + template.expand(params).toASCIIString(); + UriComponents uric = UriComponentsBuilder.fromUriString(relativeUrl).buildAndExpand(params); + return getContextPath() + uric.toUri().toASCIIString(); } /** diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java index f2de59f37be7..187a4d0972be 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -50,7 +50,7 @@ import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.ThemeResolver; import org.springframework.web.util.HtmlUtils; -import org.springframework.web.util.UriTemplate; +import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.WebUtils; @@ -563,8 +563,7 @@ public String getContextUrl(String relativeUrl) { */ public String getContextUrl(String relativeUrl, Map params) { String url = getContextPath() + relativeUrl; - UriTemplate template = new UriTemplate(url); - url = template.expand(params).toASCIIString(); + url = UriComponentsBuilder.fromUriString(url).buildAndExpand(params).encode().toUri().toASCIIString(); if (this.response != null) { url = this.response.encodeURL(url); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java index 822292b4d7a3..cd2bc87d09f5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -23,7 +23,8 @@ import org.springframework.web.servlet.support.BindStatus; import org.springframework.web.servlet.support.RequestContext; -import org.springframework.web.util.UriTemplate; +import org.springframework.web.util.UriComponents; +import org.springframework.web.util.UriComponentsBuilder; /** * Dummy request context used for FreeMarker macro tests. @@ -140,8 +141,8 @@ public String getContextUrl(String relativeUrl) { * @see org.springframework.web.servlet.support.RequestContext#getContextUrl(String, Map) */ public String getContextUrl(String relativeUrl, Map params) { - UriTemplate template = new UriTemplate(relativeUrl); - return getContextPath() + template.expand(params).toASCIIString(); + UriComponents uric = UriComponentsBuilder.fromUriString(relativeUrl).buildAndExpand(params); + return getContextPath() + uric.toUri().toASCIIString(); } /** From d1f544209eb31b1d03345c7df755f3fc9528ef58 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 28 Nov 2019 13:50:35 +0100 Subject: [PATCH 0129/2315] Test status quo for AnnotatedTypeMetadata.getAnnotationAttributes() See gh-24077 --- .../springframework/core/type/AnnotationMetadataTests.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index e269a37a7b06..b608918e0a16 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -96,8 +96,12 @@ private void doTestSubClassAnnotationInfo(AnnotationMetadata metadata) { assertThat(metadata.hasAnnotation(Component.class.getName())).isFalse(); assertThat(metadata.hasAnnotation(Scope.class.getName())).isFalse(); assertThat(metadata.hasAnnotation(SpecialAttr.class.getName())).isFalse(); + assertThat(metadata.hasMetaAnnotation(Component.class.getName())).isFalse(); + assertThat(metadata.hasMetaAnnotation(MetaAnnotation.class.getName())).isFalse(); assertThat(metadata.getAnnotationTypes()).hasSize(0); assertThat(metadata.getAnnotationAttributes(Component.class.getName())).isNull(); + assertThat(metadata.getAnnotationAttributes(MetaAnnotation.class.getName(), false)).isNull(); + assertThat(metadata.getAnnotationAttributes(MetaAnnotation.class.getName(), true)).isNull(); assertThat(metadata.getAnnotatedMethods(DirectAnnotation.class.getName()).size()).isEqualTo(0); assertThat(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName())).isEqualTo(false); assertThat(metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName())).isNull(); From 85016aef307b0d06180f2b031fc7e9280a6a21d2 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 28 Nov 2019 18:45:58 +0100 Subject: [PATCH 0130/2315] Test status quo for @Inherited annotations in AnnotationMetadata This commit introduces failing assertions that are currently disabled via a boolean reproduceGh24077 flag. Setting that flag to true demonstrates the regression for StandardAnnotationMetadata and inconsistencies for SimpleAnnotationMetadata. See gh-24077 --- .../core/type/AnnotationMetadataTests.java | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index b608918e0a16..5442c9b8d6ac 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -51,6 +51,9 @@ */ class AnnotationMetadataTests { + private static final boolean reproduceGh24077 = false; + + @Test void standardAnnotationMetadata() { AnnotationMetadata metadata = AnnotationMetadata.introspect(AnnotatedComponent.class); @@ -93,12 +96,23 @@ private void doTestSubClassAnnotationInfo(AnnotationMetadata metadata) { assertThat(metadata.isAnnotated(Component.class.getName())).isFalse(); assertThat(metadata.isAnnotated(Scope.class.getName())).isFalse(); assertThat(metadata.isAnnotated(SpecialAttr.class.getName())).isFalse(); + + if (reproduceGh24077) { + assertThat(metadata.isAnnotated(NamedComposedAnnotation.class.getName())).isTrue(); + assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isTrue(); + assertThat(metadata.getAnnotationTypes()).containsExactly(NamedComposedAnnotation.class.getName()); + } + else { + assertThat(metadata.isAnnotated(NamedComposedAnnotation.class.getName())).isFalse(); + assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isFalse(); + assertThat(metadata.getAnnotationTypes()).isEmpty(); + } + assertThat(metadata.hasAnnotation(Component.class.getName())).isFalse(); assertThat(metadata.hasAnnotation(Scope.class.getName())).isFalse(); assertThat(metadata.hasAnnotation(SpecialAttr.class.getName())).isFalse(); assertThat(metadata.hasMetaAnnotation(Component.class.getName())).isFalse(); assertThat(metadata.hasMetaAnnotation(MetaAnnotation.class.getName())).isFalse(); - assertThat(metadata.getAnnotationTypes()).hasSize(0); assertThat(metadata.getAnnotationAttributes(Component.class.getName())).isNull(); assertThat(metadata.getAnnotationAttributes(MetaAnnotation.class.getName(), false)).isNull(); assertThat(metadata.getAnnotationAttributes(MetaAnnotation.class.getName(), true)).isNull(); @@ -278,13 +292,31 @@ private void doTestAnnotationInfo(AnnotationMetadata metadata) { assertThat(metadata.getInterfaceNames().length).isEqualTo(1); assertThat(metadata.getInterfaceNames()[0]).isEqualTo(Serializable.class.getName()); + assertThat(metadata.isAnnotated(Component.class.getName())).isTrue(); + + if (reproduceGh24077) { + assertThat(metadata.isAnnotated(NamedComposedAnnotation.class.getName())).isTrue(); + } + assertThat(metadata.hasAnnotation(Component.class.getName())).isTrue(); assertThat(metadata.hasAnnotation(Scope.class.getName())).isTrue(); assertThat(metadata.hasAnnotation(SpecialAttr.class.getName())).isTrue(); - assertThat(metadata.getAnnotationTypes()).hasSize(6); - assertThat(metadata.getAnnotationTypes().contains(Component.class.getName())).isTrue(); - assertThat(metadata.getAnnotationTypes().contains(Scope.class.getName())).isTrue(); - assertThat(metadata.getAnnotationTypes().contains(SpecialAttr.class.getName())).isTrue(); + + if (reproduceGh24077) { + assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isTrue(); + assertThat(metadata.getAnnotationTypes()).containsExactlyInAnyOrder( + Component.class.getName(), Scope.class.getName(), + SpecialAttr.class.getName(), DirectAnnotation.class.getName(), + MetaMetaAnnotation.class.getName(), EnumSubclasses.class.getName(), + NamedComposedAnnotation.class.getName()); + } + else { + assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isFalse(); + assertThat(metadata.getAnnotationTypes()).containsExactlyInAnyOrder( + Component.class.getName(), Scope.class.getName(), + SpecialAttr.class.getName(), DirectAnnotation.class.getName(), + MetaMetaAnnotation.class.getName(), EnumSubclasses.class.getName()); + } AnnotationAttributes compAttrs = (AnnotationAttributes) metadata.getAnnotationAttributes(Component.class.getName()); assertThat(compAttrs).hasSize(1); From 7cedffc707a327dfa56e0ef4808fe892ea38c470 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 29 Nov 2019 00:07:44 +0100 Subject: [PATCH 0131/2315] Support @Inherited again in reflection-based AnnotationMetadata Spring Framework 5.2 introduced a regression in reflection-based AnnotationMetadata. Specifically, as of 5.2, StandardAnnotationMetadata no longer found @Inherited annotations from superclasses. This commit fixes this regression by switching to the INHERITED_ANNOTATIONS SearchStrategy when creating the MergedAnnotations used within StandardAnnotationMetadata, Note, however, that the discrepancy between StandardAnnotationMetadata and SimpleAnnotationMetadata (i.e., reflection-based vs. ASM-based) regarding @Inherited support still remains as it was prior to Spring Framework 5.2. Closes gh-24077 --- .../core/type/StandardAnnotationMetadata.java | 2 +- .../core/type/AnnotationMetadataTests.java | 51 +++++++------------ 2 files changed, 20 insertions(+), 33 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java b/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java index c0f680d260e8..b7dbbdab517f 100644 --- a/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java @@ -85,7 +85,7 @@ public StandardAnnotationMetadata(Class introspectedClass) { public StandardAnnotationMetadata(Class introspectedClass, boolean nestedAnnotationsAsMap) { super(introspectedClass); this.mergedAnnotations = MergedAnnotations.from(introspectedClass, - SearchStrategy.DIRECT, RepeatableContainers.none(), + SearchStrategy.INHERITED_ANNOTATIONS, RepeatableContainers.none(), AnnotationFilter.NONE); this.nestedAnnotationsAsMap = nestedAnnotationsAsMap; } diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index 5442c9b8d6ac..f1f9ddbed5be 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -42,7 +42,7 @@ /** * Unit tests demonstrating that the reflection-based {@link StandardAnnotationMetadata} - * and ASM-based {@code AnnotationMetadataReadingVisitor} produce identical output. + * and ASM-based {@code SimpleAnnotationMetadata} produce almost identical output. * * @author Juergen Hoeller * @author Chris Beams @@ -51,9 +51,6 @@ */ class AnnotationMetadataTests { - private static final boolean reproduceGh24077 = false; - - @Test void standardAnnotationMetadata() { AnnotationMetadata metadata = AnnotationMetadata.introspect(AnnotatedComponent.class); @@ -73,7 +70,7 @@ void asmAnnotationMetadata() throws Exception { @Test void standardAnnotationMetadataForSubclass() { AnnotationMetadata metadata = AnnotationMetadata.introspect(AnnotatedComponentSubClass.class); - doTestSubClassAnnotationInfo(metadata); + doTestSubClassAnnotationInfo(metadata, false); } @Test @@ -81,10 +78,10 @@ void asmAnnotationMetadataForSubclass() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(AnnotatedComponentSubClass.class.getName()); AnnotationMetadata metadata = metadataReader.getAnnotationMetadata(); - doTestSubClassAnnotationInfo(metadata); + doTestSubClassAnnotationInfo(metadata, true); } - private void doTestSubClassAnnotationInfo(AnnotationMetadata metadata) { + private void doTestSubClassAnnotationInfo(AnnotationMetadata metadata, boolean asm) { assertThat(metadata.getClassName()).isEqualTo(AnnotatedComponentSubClass.class.getName()); assertThat(metadata.isInterface()).isFalse(); assertThat(metadata.isAnnotation()).isFalse(); @@ -97,16 +94,16 @@ private void doTestSubClassAnnotationInfo(AnnotationMetadata metadata) { assertThat(metadata.isAnnotated(Scope.class.getName())).isFalse(); assertThat(metadata.isAnnotated(SpecialAttr.class.getName())).isFalse(); - if (reproduceGh24077) { - assertThat(metadata.isAnnotated(NamedComposedAnnotation.class.getName())).isTrue(); - assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isTrue(); - assertThat(metadata.getAnnotationTypes()).containsExactly(NamedComposedAnnotation.class.getName()); - } - else { + if (asm) { assertThat(metadata.isAnnotated(NamedComposedAnnotation.class.getName())).isFalse(); assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isFalse(); assertThat(metadata.getAnnotationTypes()).isEmpty(); } + else { + assertThat(metadata.isAnnotated(NamedComposedAnnotation.class.getName())).isTrue(); + assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isTrue(); + assertThat(metadata.getAnnotationTypes()).containsExactly(NamedComposedAnnotation.class.getName()); + } assertThat(metadata.hasAnnotation(Component.class.getName())).isFalse(); assertThat(metadata.hasAnnotation(Scope.class.getName())).isFalse(); @@ -252,7 +249,7 @@ void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnota @Test void inheritedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingStandardAnnotationMetadata() { AnnotationMetadata metadata = AnnotationMetadata.introspect(NamedComposedAnnotationExtended.class); - assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isFalse(); + assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isTrue(); } @Test @@ -294,29 +291,18 @@ private void doTestAnnotationInfo(AnnotationMetadata metadata) { assertThat(metadata.isAnnotated(Component.class.getName())).isTrue(); - if (reproduceGh24077) { - assertThat(metadata.isAnnotated(NamedComposedAnnotation.class.getName())).isTrue(); - } + assertThat(metadata.isAnnotated(NamedComposedAnnotation.class.getName())).isTrue(); assertThat(metadata.hasAnnotation(Component.class.getName())).isTrue(); assertThat(metadata.hasAnnotation(Scope.class.getName())).isTrue(); assertThat(metadata.hasAnnotation(SpecialAttr.class.getName())).isTrue(); - if (reproduceGh24077) { - assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isTrue(); - assertThat(metadata.getAnnotationTypes()).containsExactlyInAnyOrder( - Component.class.getName(), Scope.class.getName(), - SpecialAttr.class.getName(), DirectAnnotation.class.getName(), - MetaMetaAnnotation.class.getName(), EnumSubclasses.class.getName(), - NamedComposedAnnotation.class.getName()); - } - else { - assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isFalse(); - assertThat(metadata.getAnnotationTypes()).containsExactlyInAnyOrder( - Component.class.getName(), Scope.class.getName(), - SpecialAttr.class.getName(), DirectAnnotation.class.getName(), - MetaMetaAnnotation.class.getName(), EnumSubclasses.class.getName()); - } + assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isTrue(); + assertThat(metadata.getAnnotationTypes()).containsExactlyInAnyOrder( + Component.class.getName(), Scope.class.getName(), + SpecialAttr.class.getName(), DirectAnnotation.class.getName(), + MetaMetaAnnotation.class.getName(), EnumSubclasses.class.getName(), + NamedComposedAnnotation.class.getName()); AnnotationAttributes compAttrs = (AnnotationAttributes) metadata.getAnnotationAttributes(Component.class.getName()); assertThat(compAttrs).hasSize(1); @@ -513,6 +499,7 @@ public enum SubclassEnum { @DirectAnnotation(value = "direct", additional = "", additionalArray = {}) @MetaMetaAnnotation @EnumSubclasses({SubclassEnum.FOO, SubclassEnum.BAR}) + @NamedComposedAnnotation private static class AnnotatedComponent implements Serializable { @TestAutowired From d9ebc3bbc4f383376fdf6ee2f7d35879187f5026 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 29 Nov 2019 14:55:18 +0100 Subject: [PATCH 0132/2315] Polish StringArrayPropertyEditor[Tests] --- .../StringArrayPropertyEditor.java | 24 ++++---- .../StringArrayPropertyEditorTests.java | 59 ++++++++----------- .../org/springframework/util/StringUtils.java | 4 +- 3 files changed, 38 insertions(+), 49 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditor.java index eee219ed9e8f..1a7a8ccc24f8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -53,7 +53,7 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport { /** - * Create a new StringArrayPropertyEditor with the default separator + * Create a new {@code StringArrayPropertyEditor} with the default separator * (a comma). *

An empty text (without elements) will be turned into an empty array. */ @@ -62,7 +62,7 @@ public StringArrayPropertyEditor() { } /** - * Create a new StringArrayPropertyEditor with the given separator. + * Create a new {@code StringArrayPropertyEditor} with the given separator. *

An empty text (without elements) will be turned into an empty array. * @param separator the separator to use for splitting a {@link String} */ @@ -71,7 +71,7 @@ public StringArrayPropertyEditor(String separator) { } /** - * Create a new StringArrayPropertyEditor with the given separator. + * Create a new {@code StringArrayPropertyEditor} with the given separator. * @param separator the separator to use for splitting a {@link String} * @param emptyArrayAsNull {@code true} if an empty String array * is to be transformed into {@code null} @@ -81,19 +81,19 @@ public StringArrayPropertyEditor(String separator, boolean emptyArrayAsNull) { } /** - * Create a new StringArrayPropertyEditor with the given separator. + * Create a new {@code StringArrayPropertyEditor} with the given separator. * @param separator the separator to use for splitting a {@link String} * @param emptyArrayAsNull {@code true} if an empty String array * is to be transformed into {@code null} * @param trimValues {@code true} if the values in the parsed arrays - * are to be trimmed of whitespace (default is true). + * are to be trimmed of whitespace (default is true) */ public StringArrayPropertyEditor(String separator, boolean emptyArrayAsNull, boolean trimValues) { this(separator, null, emptyArrayAsNull, trimValues); } /** - * Create a new StringArrayPropertyEditor with the given separator. + * Create a new {@code StringArrayPropertyEditor} with the given separator. * @param separator the separator to use for splitting a {@link String} * @param charsToDelete a set of characters to delete, in addition to * trimming an input String. Useful for deleting unwanted line breaks: @@ -106,7 +106,7 @@ public StringArrayPropertyEditor(String separator, @Nullable String charsToDelet } /** - * Create a new StringArrayPropertyEditor with the given separator. + * Create a new {@code StringArrayPropertyEditor} with the given separator. * @param separator the separator to use for splitting a {@link String} * @param charsToDelete a set of characters to delete, in addition to * trimming an input String. Useful for deleting unwanted line breaks: @@ -114,7 +114,7 @@ public StringArrayPropertyEditor(String separator, @Nullable String charsToDelet * @param emptyArrayAsNull {@code true} if an empty String array * is to be transformed into {@code null} * @param trimValues {@code true} if the values in the parsed arrays - * are to be trimmed of whitespace (default is true). + * are to be trimmed of whitespace (default is true) */ public StringArrayPropertyEditor( String separator, @Nullable String charsToDelete, boolean emptyArrayAsNull, boolean trimValues) { @@ -128,13 +128,13 @@ public StringArrayPropertyEditor( @Override public void setAsText(String text) throws IllegalArgumentException { String[] array = StringUtils.delimitedListToStringArray(text, this.separator, this.charsToDelete); - if (this.trimValues) { - array = StringUtils.trimArrayElements(array); - } if (this.emptyArrayAsNull && array.length == 0) { setValue(null); } else { + if (this.trimValues) { + array = StringUtils.trimArrayElements(array); + } setValue(array); } } diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditorTests.java index 09716d04fd08..0583c78460b7 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditorTests.java @@ -23,39 +23,31 @@ /** * @author Rick Evans * @author Juergen Hoeller + * @author Sam Brannen */ -public class StringArrayPropertyEditorTests { +class StringArrayPropertyEditorTests { @Test - public void withDefaultSeparator() throws Exception { + void withDefaultSeparator() { StringArrayPropertyEditor editor = new StringArrayPropertyEditor(); editor.setAsText("0,1,2"); Object value = editor.getValue(); - assertThat(value).isNotNull(); - boolean condition = value instanceof String[]; - assertThat(condition).isTrue(); - String[] array = (String[]) value; - for (int i = 0; i < array.length; ++i) { - assertThat(array[i]).isEqualTo(("" + i)); - } + assertTrimmedElements(value); assertThat(editor.getAsText()).isEqualTo("0,1,2"); } @Test - public void trimByDefault() throws Exception { + void trimByDefault() { StringArrayPropertyEditor editor = new StringArrayPropertyEditor(); editor.setAsText(" 0,1 , 2 "); Object value = editor.getValue(); - String[] array = (String[]) value; - for (int i = 0; i < array.length; ++i) { - assertThat(array[i]).isEqualTo(("" + i)); - } + assertTrimmedElements(value); assertThat(editor.getAsText()).isEqualTo("0,1,2"); } @Test - public void noTrim() throws Exception { - StringArrayPropertyEditor editor = new StringArrayPropertyEditor(",",false,false); + void noTrim() { + StringArrayPropertyEditor editor = new StringArrayPropertyEditor(",", false, false); editor.setAsText(" 0,1 , 2 "); Object value = editor.getValue(); String[] array = (String[]) value; @@ -67,48 +59,45 @@ public void noTrim() throws Exception { } @Test - public void withCustomSeparator() throws Exception { + void withCustomSeparator() { StringArrayPropertyEditor editor = new StringArrayPropertyEditor(":"); editor.setAsText("0:1:2"); Object value = editor.getValue(); - boolean condition = value instanceof String[]; - assertThat(condition).isTrue(); - String[] array = (String[]) value; - for (int i = 0; i < array.length; ++i) { - assertThat(array[i]).isEqualTo(("" + i)); - } + assertTrimmedElements(value); assertThat(editor.getAsText()).isEqualTo("0:1:2"); } @Test - public void withCharsToDelete() throws Exception { + void withCharsToDelete() { StringArrayPropertyEditor editor = new StringArrayPropertyEditor(",", "\r\n", false); editor.setAsText("0\r,1,\n2"); Object value = editor.getValue(); - boolean condition = value instanceof String[]; - assertThat(condition).isTrue(); - String[] array = (String[]) value; - for (int i = 0; i < array.length; ++i) { - assertThat(array[i]).isEqualTo(("" + i)); - } + assertTrimmedElements(value); assertThat(editor.getAsText()).isEqualTo("0,1,2"); } @Test - public void withEmptyArray() throws Exception { + void withEmptyArray() { StringArrayPropertyEditor editor = new StringArrayPropertyEditor(); editor.setAsText(""); Object value = editor.getValue(); - boolean condition = value instanceof String[]; - assertThat(condition).isTrue(); - assertThat(((String[]) value).length).isEqualTo(0); + assertThat(value).isInstanceOf(String[].class); + assertThat((String[]) value).isEmpty(); } @Test - public void withEmptyArrayAsNull() throws Exception { + void withEmptyArrayAsNull() { StringArrayPropertyEditor editor = new StringArrayPropertyEditor(",", true); editor.setAsText(""); assertThat(editor.getValue()).isNull(); } + private static void assertTrimmedElements(Object value) { + assertThat(value).isInstanceOf(String[].class); + String[] array = (String[]) value; + for (int i = 0; i < array.length; ++i) { + assertThat(array[i]).isEqualTo(("" + i)); + } + } + } diff --git a/spring-core/src/main/java/org/springframework/util/StringUtils.java b/spring-core/src/main/java/org/springframework/util/StringUtils.java index 4b720ac8e7f6..24af9f14d571 100644 --- a/spring-core/src/main/java/org/springframework/util/StringUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StringUtils.java @@ -1002,8 +1002,8 @@ public static String[] sortStringArray(String[] array) { } /** - * Trim the elements of the given {@code String} array, - * calling {@code String.trim()} on each of them. + * Trim the elements of the given {@code String} array, calling + * {@code String.trim()} on each non-null element. * @param array the original {@code String} array (potentially empty) * @return the resulting array (of the same size) with trimmed elements */ From e858b21c60396c1597e3f1327be944ec31dbfa7d Mon Sep 17 00:00:00 2001 From: Parviz ROzikov Date: Tue, 26 Nov 2019 09:54:49 +0700 Subject: [PATCH 0133/2315] #24022 - added protobuf MessageConverter --- spring-messaging/spring-messaging.gradle | 1 + .../converter/AbstractMessageConverter.java | 27 +- .../MappingJackson2MessageConverter.java | 2 +- .../MarshallingMessageConverter.java | 2 +- .../converter/ProtobufMessageConverter.java | 324 +++++++++ .../AbstractMessageBrokerConfiguration.java | 22 +- .../converter/MessageConverterTests.java | 17 +- .../ProtobufMessageConverterTest.java | 142 ++++ .../messaging/protobuf/Msg.java | 654 ++++++++++++++++++ .../messaging/protobuf/MsgOrBuilder.java | 37 + .../messaging/protobuf/OuterSample.java | 63 ++ .../messaging/protobuf/SecondMsg.java | 389 +++++++++++ .../protobuf/SecondMsgOrBuilder.java | 18 + .../MessageBrokerConfigurationTests.java | 10 +- spring-messaging/src/test/proto/sample.proto | 12 + spring-websocket/spring-websocket.gradle | 1 + .../MessageBrokerBeanDefinitionParser.java | 11 + ...essageBrokerBeanDefinitionParserTests.java | 9 +- 18 files changed, 1719 insertions(+), 22 deletions(-) create mode 100644 spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java create mode 100644 spring-messaging/src/test/java/org/springframework/messaging/converter/ProtobufMessageConverterTest.java create mode 100644 spring-messaging/src/test/java/org/springframework/messaging/protobuf/Msg.java create mode 100644 spring-messaging/src/test/java/org/springframework/messaging/protobuf/MsgOrBuilder.java create mode 100644 spring-messaging/src/test/java/org/springframework/messaging/protobuf/OuterSample.java create mode 100644 spring-messaging/src/test/java/org/springframework/messaging/protobuf/SecondMsg.java create mode 100644 spring-messaging/src/test/java/org/springframework/messaging/protobuf/SecondMsgOrBuilder.java create mode 100644 spring-messaging/src/test/proto/sample.proto diff --git a/spring-messaging/spring-messaging.gradle b/spring-messaging/spring-messaging.gradle index 8d6999b9fb6e..3855f3007c46 100644 --- a/spring-messaging/spring-messaging.gradle +++ b/spring-messaging/spring-messaging.gradle @@ -15,6 +15,7 @@ dependencies { optional("javax.xml.bind:jaxb-api") optional("org.jetbrains.kotlinx:kotlinx-coroutines-core") optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") + optional("com.google.protobuf:protobuf-java-util") testCompile("javax.inject:javax.inject-tck") testCompile("javax.servlet:javax.servlet-api") testCompile("javax.validation:validation-api") diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java index 6ac679d39ef1..d741a6007594 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Arrays; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -47,7 +48,7 @@ public abstract class AbstractMessageConverter implements SmartMessageConverter protected final Log logger = LogFactory.getLog(getClass()); - private final List supportedMimeTypes; + private List supportedMimeTypes; @Nullable private ContentTypeResolver contentTypeResolver = new DefaultContentTypeResolver(); @@ -62,8 +63,7 @@ public abstract class AbstractMessageConverter implements SmartMessageConverter * @param supportedMimeType the supported MIME type */ protected AbstractMessageConverter(MimeType supportedMimeType) { - Assert.notNull(supportedMimeType, "supportedMimeType is required"); - this.supportedMimeTypes = Collections.singletonList(supportedMimeType); + setSupportedMimeTypes(Collections.singletonList(supportedMimeType)); } /** @@ -71,8 +71,16 @@ protected AbstractMessageConverter(MimeType supportedMimeType) { * @param supportedMimeTypes the supported MIME types */ protected AbstractMessageConverter(Collection supportedMimeTypes) { - Assert.notNull(supportedMimeTypes, "supportedMimeTypes must not be null"); - this.supportedMimeTypes = new ArrayList<>(supportedMimeTypes); + setSupportedMimeTypes(new ArrayList<>(supportedMimeTypes)); + } + + /** + * Construct an {@code AbstractMessageConverter} supporting multiple MIME types. + * @param supportedMimeTypes the supported MIME types + * @since 5.2.2 + */ + protected AbstractMessageConverter(MimeType... supportedMimeTypes) { + setSupportedMimeTypes(Arrays.asList(supportedMimeTypes)); } @@ -83,6 +91,15 @@ public List getSupportedMimeTypes() { return Collections.unmodifiableList(this.supportedMimeTypes); } + /** + * Set the list of {@link MimeType} objects supported by this converter. + * @since 5.2.2 + */ + protected void setSupportedMimeTypes(List supportedMimeTypes) { + Assert.notNull(supportedMimeTypes, "supportedMimeTypes must not be null"); + this.supportedMimeTypes = supportedMimeTypes; + } + /** * Configure the {@link ContentTypeResolver} to use to resolve the content * type of an input message. diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java index abf98391db78..16dd3e19bc89 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java @@ -84,7 +84,7 @@ public MappingJackson2MessageConverter() { * @since 4.1.5 */ public MappingJackson2MessageConverter(MimeType... supportedMimeTypes) { - super(Arrays.asList(supportedMimeTypes)); + super(supportedMimeTypes); this.objectMapper = initObjectMapper(); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java index 3a477c79f463..d031157398c2 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java @@ -70,7 +70,7 @@ public MarshallingMessageConverter() { * @param supportedMimeTypes the MIME types */ public MarshallingMessageConverter(MimeType... supportedMimeTypes) { - super(Arrays.asList(supportedMimeTypes)); + super(supportedMimeTypes); } /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java new file mode 100644 index 000000000000..2ac163a3a68f --- /dev/null +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java @@ -0,0 +1,324 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.messaging.converter; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.lang.reflect.Method; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Map; + +import com.google.protobuf.ExtensionRegistry; +import com.google.protobuf.Message; +import com.google.protobuf.util.JsonFormat; +import org.springframework.lang.Nullable; +import org.springframework.messaging.MessageHeaders; +import org.springframework.util.ClassUtils; +import org.springframework.util.ConcurrentReferenceHashMap; +import org.springframework.util.MimeType; + +import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON; +import static org.springframework.util.MimeTypeUtils.TEXT_PLAIN; + +/** + * An {@code MessageConverter} that reads and writes + * {@link com.google.protobuf.Message com.google.protobuf.Messages} using + * Google Protocol Buffers. + * + *

To generate {@code Message} Java classes, you need to install the {@code protoc} binary. + * + *

This converter supports by default {@code "application/x-protobuf"} with the official + * {@code "com.google.protobuf:protobuf-java"} library. + * + *

{@code "application/json"} can be supported with the official {@code "com.google.protobuf:protobuf-java-util"} 3.x + * with 3.3 or higher recommended + * + * @author Parviz Rozikov + * @since 5.2.2 + */ +public class ProtobufMessageConverter extends AbstractMessageConverter { + + + /** + * The default charset used by the converter. + */ + public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; + + /** + * The mime-type for protobuf {@code application/x-protobuf}. + */ + public static final MimeType PROTOBUF = new MimeType("application", "x-protobuf", DEFAULT_CHARSET); + + + private static final Map, Method> methodCache = new ConcurrentReferenceHashMap<>(); + + final ExtensionRegistry extensionRegistry; + + @Nullable + private final ProtobufFormatSupport protobufFormatSupport; + + + /** + * Construct a new {@code ProtobufMessageConverter}. + */ + public ProtobufMessageConverter() { + this((ProtobufFormatSupport) null, (ExtensionRegistry) null); + } + + /** + * Construct a new {@code ProtobufMessageConverter} with a registry that specifies + * protocol message extensions. + * + * @param extensionRegistry the registry to populate + */ + public ProtobufMessageConverter(@Nullable ExtensionRegistry extensionRegistry) { + this(null, extensionRegistry); + } + + /** + * Construct a new {@code ProtobufMessageConverter} with the given + * {@code JsonFormat.Parser} and {@code JsonFormat.Printer} configuration. + * + * @param parser the JSON parser configuration + * @param printer the JSON printer configuration + */ + public ProtobufMessageConverter(@Nullable JsonFormat.Parser parser, @Nullable JsonFormat.Printer printer) { + this(new ProtobufJavaUtilSupport(parser, printer), (ExtensionRegistry) null); + } + + /** + * Construct a new {@code ProtobufMessageConverter} with the given + * {@code JsonFormat.Parser} and {@code JsonFormat.Printer} configuration, also + * accepting a registry that specifies protocol message extensions. + * + * @param parser the JSON parser configuration + * @param printer the JSON printer configuration + * @param extensionRegistry the registry to populate + */ + public ProtobufMessageConverter(@Nullable JsonFormat.Parser parser, + @Nullable JsonFormat.Printer printer, @Nullable ExtensionRegistry extensionRegistry) { + + this(new ProtobufJavaUtilSupport(parser, printer), extensionRegistry); + } + + /** + * Construct a new {@code ProtobufMessageConverter} with the given + * {@code ProtobufFormatSupport} configuration, also + * accepting a registry that specifies protocol message extensions. + * + * @param formatSupport support third party + * @param extensionRegistry the registry to populate + */ + public ProtobufMessageConverter(@Nullable ProtobufFormatSupport formatSupport, + @Nullable ExtensionRegistry extensionRegistry) { + super(PROTOBUF); + + if (formatSupport != null) { + this.protobufFormatSupport = formatSupport; + } + else if (ClassUtils.isPresent("com.google.protobuf.util.JsonFormat", getClass().getClassLoader())) { + this.protobufFormatSupport = new ProtobufJavaUtilSupport(null, null); + } + else { + this.protobufFormatSupport = null; + } + + if (this.protobufFormatSupport != null) { + setSupportedMimeTypes(Arrays.asList(protobufFormatSupport.supportedMediaTypes())); + } + + this.extensionRegistry = (extensionRegistry == null ? ExtensionRegistry.newInstance() : extensionRegistry); + } + + @Override + protected boolean supports(Class clazz) { + return Message.class.isAssignableFrom(clazz); + } + + @Override + protected boolean canConvertTo(Object payload, @Nullable MessageHeaders headers) { + MimeType mimeType = getMimeType(headers); + return (super.canConvertTo(payload, headers) || + this.protobufFormatSupport != null && this.protobufFormatSupport.supportsWriteOnly(mimeType)); + } + + @Override + protected Object convertFromInternal(org.springframework.messaging.Message message, Class targetClass, @Nullable Object conversionHint) { + MimeType contentType = getMimeType(message.getHeaders()); + final Object payload = message.getPayload(); + + if (contentType == null) { + contentType = PROTOBUF; + } + + Charset charset = contentType.getCharset(); + if (charset == null) { + charset = DEFAULT_CHARSET; + } + + Message.Builder builder = getMessageBuilder(targetClass); + + try { + if (PROTOBUF.isCompatibleWith(contentType)) { + builder.mergeFrom((byte[]) payload, this.extensionRegistry); + } + else if (protobufFormatSupport != null) { + this.protobufFormatSupport.merge( + message, charset, contentType, this.extensionRegistry, builder); + } + } + catch (IOException e) { + throw new MessageConversionException(message, "Could not read proto message" + e.getMessage(), e); + } + + return builder.build(); + } + + + @Override + protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { + final Message message = (Message) payload; + + MimeType contentType = getMimeType(headers); + if (contentType == null) { + contentType = PROTOBUF; + + } + + Charset charset = contentType.getCharset(); + if (charset == null) { + charset = DEFAULT_CHARSET; + } + + try { + if (PROTOBUF.isCompatibleWith(contentType)) { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + message.writeTo(byteArrayOutputStream); + payload = byteArrayOutputStream.toByteArray(); + } + else if (this.protobufFormatSupport != null) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + this.protobufFormatSupport.print(message, outputStream, contentType, charset); + payload = new String(outputStream.toByteArray(), charset); + } + } + catch (IOException e) { + throw new MessageConversionException("Could not write proto message" + e.getMessage(), e); + + } + return payload; + } + + + /** + * Create a new {@code Message.Builder} instance for the given class. + *

This method uses a ConcurrentReferenceHashMap for caching method lookups. + */ + private Message.Builder getMessageBuilder(Class clazz) { + try { + Method method = methodCache.get(clazz); + if (method == null) { + method = clazz.getMethod("newBuilder"); + methodCache.put(clazz, method); + } + return (Message.Builder) method.invoke(clazz); + } + catch (Exception ex) { + throw new MessageConversionException( + "Invalid Protobuf Message type: no invocable newBuilder() method on " + clazz, ex); + } + } + + + /** + * Protobuf format support. + */ + interface ProtobufFormatSupport { + + MimeType[] supportedMediaTypes(); + + boolean supportsWriteOnly(@Nullable MimeType mediaType); + + void merge(org.springframework.messaging.Message message, Charset charset, MimeType contentType, + ExtensionRegistry extensionRegistry, Message.Builder builder) + throws IOException, MessageConversionException; + + void print(Message message, OutputStream output, MimeType contentType, Charset charset) + throws IOException, MessageConversionException; + } + + + /** + * {@link ProtobufFormatSupport} implementation used when + * {@code com.google.protobuf.util.JsonFormat} is available. + */ + static class ProtobufJavaUtilSupport implements ProtobufFormatSupport { + + private final JsonFormat.Parser parser; + + private final JsonFormat.Printer printer; + + public ProtobufJavaUtilSupport(@Nullable JsonFormat.Parser parser, @Nullable JsonFormat.Printer printer) { + this.parser = (parser != null ? parser : JsonFormat.parser()); + this.printer = (printer != null ? printer : JsonFormat.printer()); + } + + @Override + public MimeType[] supportedMediaTypes() { + return new MimeType[]{PROTOBUF, TEXT_PLAIN, APPLICATION_JSON}; + } + + @Override + public boolean supportsWriteOnly(@Nullable MimeType mimeType) { + return false; + } + + @Override + public void merge(org.springframework.messaging.Message message, Charset charset, MimeType contentType, + ExtensionRegistry extensionRegistry, Message.Builder builder) + throws IOException, MessageConversionException { + + if (contentType.isCompatibleWith(APPLICATION_JSON)) { + this.parser.merge(message.getPayload().toString(), builder); + } + else { + throw new MessageConversionException( + "protobuf-java-util does not support parsing " + contentType); + } + } + + @Override + public void print(Message message, OutputStream output, MimeType contentType, Charset charset) + throws IOException, MessageConversionException { + + if (contentType.isCompatibleWith(APPLICATION_JSON)) { + OutputStreamWriter writer = new OutputStreamWriter(output, charset); + this.printer.appendTo(message, writer); + writer.flush(); + } else { + throw new MessageConversionException( + "protobuf-java-util does not support printing " + contentType); + } + } + } + + +} diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java index a3cc4f10c15a..519fbac6d110 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java @@ -37,6 +37,7 @@ import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.converter.MessageConverter; import org.springframework.messaging.converter.StringMessageConverter; +import org.springframework.messaging.converter.ProtobufMessageConverter; import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; import org.springframework.messaging.simp.SimpLogging; @@ -93,9 +94,15 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC private static final String MVC_VALIDATOR_NAME = "mvcValidator"; - private static final boolean jackson2Present = ClassUtils.isPresent( - "com.fasterxml.jackson.databind.ObjectMapper", AbstractMessageBrokerConfiguration.class.getClassLoader()); + private static final boolean jackson2Present; + private static final boolean protobufPresent; + + static { + ClassLoader classLoader = AbstractMessageBrokerConfiguration.class.getClassLoader(); + jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader); + protobufPresent = ClassUtils.isPresent("com.google.protobuf.Message", classLoader); + } @Nullable private ApplicationContext applicationContext; @@ -391,6 +398,9 @@ public CompositeMessageConverter brokerMessageConverter() { if (jackson2Present) { converters.add(createJacksonConverter()); } + if (protobufPresent) { + converters.add(createProtobufConverter()); + } } return new CompositeMessageConverter(converters); } @@ -403,6 +413,14 @@ protected MappingJackson2MessageConverter createJacksonConverter() { return converter; } + protected ProtobufMessageConverter createProtobufConverter() { + DefaultContentTypeResolver resolver = new DefaultContentTypeResolver(); + resolver.setDefaultMimeType(ProtobufMessageConverter.PROTOBUF); + final ProtobufMessageConverter converter = new ProtobufMessageConverter(); + converter.setContentTypeResolver(resolver); + return converter; + } + /** * Override this method to add custom message converters. * @param messageConverters the list to add converters to, initially empty diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java index ecc62c210a3e..ff834b84e40a 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java @@ -16,9 +16,6 @@ package org.springframework.messaging.converter; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -81,14 +78,15 @@ public void supportsMimeTypeNotSpecified() { public void supportsMimeTypeNoneConfigured() { Message message = MessageBuilder.withPayload( "ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build(); - this.converter = new TestMessageConverter(Collections.emptyList()); + final MimeType[] empty = {}; + this.converter = new TestMessageConverter(empty); assertThat(this.converter.fromMessage(message, String.class)).isEqualTo("success-from"); } @Test public void canConvertFromStrictContentTypeMatch() { - this.converter = new TestMessageConverter(Arrays.asList(MimeTypeUtils.TEXT_PLAIN)); + this.converter = new TestMessageConverter(MimeTypeUtils.TEXT_PLAIN); this.converter.setStrictContentTypeMatch(true); Message message = MessageBuilder.withPayload("ABC").build(); @@ -102,7 +100,8 @@ public void canConvertFromStrictContentTypeMatch() { @Test public void setStrictContentTypeMatchWithNoSupportedMimeTypes() { - this.converter = new TestMessageConverter(Collections.emptyList()); + final MimeType[] empty = {}; + this.converter = new TestMessageConverter(empty); assertThatIllegalArgumentException().isThrownBy(() -> this.converter.setStrictContentTypeMatch(true)); } @@ -149,7 +148,7 @@ public TestMessageConverter() { super(MimeTypeUtils.TEXT_PLAIN); } - public TestMessageConverter(Collection supportedMimeTypes) { + public TestMessageConverter(MimeType... supportedMimeTypes) { super(supportedMimeTypes); } @@ -160,14 +159,14 @@ protected boolean supports(Class clazz) { @Override protected Object convertFromInternal(Message message, Class targetClass, - @Nullable Object conversionHint) { + @Nullable Object conversionHint) { return "success-from"; } @Override protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, - @Nullable Object conversionHint) { + @Nullable Object conversionHint) { return "success-to"; } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/ProtobufMessageConverterTest.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/ProtobufMessageConverterTest.java new file mode 100644 index 000000000000..fd3b622fc1e6 --- /dev/null +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/ProtobufMessageConverterTest.java @@ -0,0 +1,142 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.messaging.converter; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import com.google.protobuf.ExtensionRegistry; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageHeaders; +import org.springframework.messaging.protobuf.Msg; +import org.springframework.messaging.protobuf.SecondMsg; +import org.springframework.messaging.support.MessageBuilder; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.springframework.messaging.MessageHeaders.CONTENT_TYPE; +import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON; + +/** + * Test suite for {@link ProtobufMessageConverter}. + * + * @author Parviz Rozikov + */ +class ProtobufMessageConverterTest { + + private ProtobufMessageConverter converter; + + private ExtensionRegistry extensionRegistry; + + private Msg testMsg; + private Message message; + private Message messageWithoutContentType; + private Message messageJson; + + + @BeforeEach + public void setup() { + this.extensionRegistry = mock(ExtensionRegistry.class); + this.converter = new ProtobufMessageConverter(); + this.testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build(); + this.message = MessageBuilder.withPayload(this.testMsg.toByteArray()) + .setHeader(CONTENT_TYPE, ProtobufMessageConverter.PROTOBUF).build(); + this.messageWithoutContentType = MessageBuilder.withPayload(this.testMsg.toByteArray()) + .build(); + this.messageJson = MessageBuilder.withPayload("{\n" + + " \"foo\": \"Foo\",\n" + + " \"blah\": {\n" + + " \"blah\": 123\n" + + " }\n" + + "}") + .setHeader(CONTENT_TYPE, APPLICATION_JSON).build(); + } + + @Test + public void extensionRegistryNull() { + ProtobufMessageConverter converter = new ProtobufMessageConverter((ExtensionRegistry) null); + assertThat(converter.extensionRegistry).isNotNull(); + } + + + @Test + public void canConvertFrom() { + assertThat(converter.canConvertFrom(message, Msg.class)).isTrue(); + assertThat(converter.canConvertFrom(messageWithoutContentType, Msg.class)).isTrue(); + assertThat(converter.canConvertFrom(messageJson, Msg.class)).isTrue(); + } + + @Test + public void canConvertTo() { + assertThat(converter.canConvertTo(testMsg, message.getHeaders())).isTrue(); + assertThat(converter.canConvertTo(testMsg, messageWithoutContentType.getHeaders())).isTrue(); + assertThat(converter.canConvertTo(testMsg, messageJson.getHeaders())).isTrue(); + } + + + @Test + public void convertFrom() throws IOException { + final Msg msg = (Msg) converter.fromMessage(message, Msg.class); + assertThat(msg).isEqualTo(testMsg); + } + + @Test + public void convertTo() throws IOException { + final Message message = converter.toMessage(this.testMsg, this.message.getHeaders()); + assertThat(message).isNotNull(); + assertThat(message.getPayload()).isEqualTo(this.message.getPayload()); + } + + + @Test + public void convertFromNoContentType() throws IOException { + Msg result = (Msg) converter.fromMessage(messageWithoutContentType, Msg.class); + assertThat(result).isEqualTo(testMsg); + } + + + @Test + public void defaultContentType() throws Exception { + assertThat(converter.getDefaultContentType(testMsg)).isEqualTo(ProtobufMessageConverter.PROTOBUF); + } + + @Test + public void testJsonWithGoogleProtobuf() throws Exception { + this.converter = new ProtobufMessageConverter( + new ProtobufMessageConverter.ProtobufJavaUtilSupport(null, null), + extensionRegistry); + + final Map headers = new HashMap<>(); + headers.put(CONTENT_TYPE, APPLICATION_JSON); + + //convertTo + final Message message = this.converter.toMessage(this.testMsg, new MessageHeaders(headers)); + assertThat(message).isNotNull(); + assertThat(message.getHeaders().get(CONTENT_TYPE)).isEqualTo(APPLICATION_JSON); + assertThat(((String) message.getPayload()).length() > 0).isTrue(); + assertThat(((String) message.getPayload()).isEmpty()).as("Body is empty").isFalse(); + assertThat(((String) message.getPayload())).isEqualTo(this.messageJson.getPayload()); + + //convertFrom + final Msg msg = (Msg) converter.fromMessage(message, Msg.class); + assertThat(msg).isEqualTo(this.testMsg); + } + +} \ No newline at end of file diff --git a/spring-messaging/src/test/java/org/springframework/messaging/protobuf/Msg.java b/spring-messaging/src/test/java/org/springframework/messaging/protobuf/Msg.java new file mode 100644 index 000000000000..41784343ae3f --- /dev/null +++ b/spring-messaging/src/test/java/org/springframework/messaging/protobuf/Msg.java @@ -0,0 +1,654 @@ +/* + * Copyright 2002-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: sample.proto + +package org.springframework.messaging.protobuf; + +/** + * Protobuf type {@code Msg} + */ +public final class Msg extends + com.google.protobuf.GeneratedMessage + implements MsgOrBuilder { + // Use Msg.newBuilder() to construct. + private Msg(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Msg(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Msg defaultInstance; + public static Msg getDefaultInstance() { + return defaultInstance; + } + + public Msg getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Msg( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + @SuppressWarnings("unused") + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + foo_ = input.readBytes(); + break; + } + case 18: { + SecondMsg.Builder subBuilder = null; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + subBuilder = blah_.toBuilder(); + } + blah_ = input.readMessage(SecondMsg.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(blah_); + blah_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000002; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OuterSample.internal_static_Msg_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return OuterSample.internal_static_Msg_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Msg.class, Msg.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Msg parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Msg(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // optional string foo = 1; + public static final int FOO_FIELD_NUMBER = 1; + private java.lang.Object foo_; + /** + * optional string foo = 1; + */ + public boolean hasFoo() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string foo = 1; + */ + public java.lang.String getFoo() { + java.lang.Object ref = foo_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + foo_ = s; + } + return s; + } + } + /** + * optional string foo = 1; + */ + public com.google.protobuf.ByteString + getFooBytes() { + java.lang.Object ref = foo_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + foo_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // optional .SecondMsg blah = 2; + public static final int BLAH_FIELD_NUMBER = 2; + private SecondMsg blah_; + /** + * optional .SecondMsg blah = 2; + */ + public boolean hasBlah() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .SecondMsg blah = 2; + */ + public SecondMsg getBlah() { + return blah_; + } + /** + * optional .SecondMsg blah = 2; + */ + public SecondMsgOrBuilder getBlahOrBuilder() { + return blah_; + } + + private void initFields() { + foo_ = ""; + blah_ = SecondMsg.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getFooBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeMessage(2, blah_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getFooBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, blah_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static Msg parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Msg parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Msg parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Msg parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Msg parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Msg parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static Msg parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static Msg parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static Msg parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Msg parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(Msg prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Msg} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements MsgOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OuterSample.internal_static_Msg_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return OuterSample.internal_static_Msg_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Msg.class, Msg.Builder.class); + } + + // Construct using org.springframework.messaging.protobuf.Msg.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getBlahFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + foo_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + if (blahBuilder_ == null) { + blah_ = SecondMsg.getDefaultInstance(); + } else { + blahBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OuterSample.internal_static_Msg_descriptor; + } + + public Msg getDefaultInstanceForType() { + return Msg.getDefaultInstance(); + } + + public Msg build() { + Msg result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Msg buildPartial() { + Msg result = new Msg(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.foo_ = foo_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + if (blahBuilder_ == null) { + result.blah_ = blah_; + } else { + result.blah_ = blahBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Msg) { + return mergeFrom((Msg)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Msg other) { + if (other == Msg.getDefaultInstance()) return this; + if (other.hasFoo()) { + bitField0_ |= 0x00000001; + foo_ = other.foo_; + onChanged(); + } + if (other.hasBlah()) { + mergeBlah(other.getBlah()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Msg parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Msg) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // optional string foo = 1; + private java.lang.Object foo_ = ""; + /** + * optional string foo = 1; + */ + public boolean hasFoo() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string foo = 1; + */ + public java.lang.String getFoo() { + java.lang.Object ref = foo_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + foo_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string foo = 1; + */ + public com.google.protobuf.ByteString + getFooBytes() { + java.lang.Object ref = foo_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + foo_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string foo = 1; + */ + public Builder setFoo( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + foo_ = value; + onChanged(); + return this; + } + /** + * optional string foo = 1; + */ + public Builder clearFoo() { + bitField0_ = (bitField0_ & ~0x00000001); + foo_ = getDefaultInstance().getFoo(); + onChanged(); + return this; + } + /** + * optional string foo = 1; + */ + public Builder setFooBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + foo_ = value; + onChanged(); + return this; + } + + // optional .SecondMsg blah = 2; + private SecondMsg blah_ = SecondMsg.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + SecondMsg, SecondMsg.Builder, + SecondMsgOrBuilder> blahBuilder_; + /** + * optional .SecondMsg blah = 2; + */ + public boolean hasBlah() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .SecondMsg blah = 2; + */ + public SecondMsg getBlah() { + if (blahBuilder_ == null) { + return blah_; + } else { + return blahBuilder_.getMessage(); + } + } + /** + * optional .SecondMsg blah = 2; + */ + public Builder setBlah(SecondMsg value) { + if (blahBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + blah_ = value; + onChanged(); + } else { + blahBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .SecondMsg blah = 2; + */ + public Builder setBlah( + SecondMsg.Builder builderForValue) { + if (blahBuilder_ == null) { + blah_ = builderForValue.build(); + onChanged(); + } else { + blahBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .SecondMsg blah = 2; + */ + public Builder mergeBlah(SecondMsg value) { + if (blahBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002) && + blah_ != SecondMsg.getDefaultInstance()) { + blah_ = + SecondMsg.newBuilder(blah_).mergeFrom(value).buildPartial(); + } else { + blah_ = value; + } + onChanged(); + } else { + blahBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .SecondMsg blah = 2; + */ + public Builder clearBlah() { + if (blahBuilder_ == null) { + blah_ = SecondMsg.getDefaultInstance(); + onChanged(); + } else { + blahBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + /** + * optional .SecondMsg blah = 2; + */ + public SecondMsg.Builder getBlahBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getBlahFieldBuilder().getBuilder(); + } + /** + * optional .SecondMsg blah = 2; + */ + public SecondMsgOrBuilder getBlahOrBuilder() { + if (blahBuilder_ != null) { + return blahBuilder_.getMessageOrBuilder(); + } else { + return blah_; + } + } + /** + * optional .SecondMsg blah = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + SecondMsg, SecondMsg.Builder, + SecondMsgOrBuilder> + getBlahFieldBuilder() { + if (blahBuilder_ == null) { + blahBuilder_ = new com.google.protobuf.SingleFieldBuilder<>( + blah_, + getParentForChildren(), + isClean()); + blah_ = null; + } + return blahBuilder_; + } + + // @@protoc_insertion_point(builder_scope:Msg) + } + + static { + defaultInstance = new Msg(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:Msg) +} + diff --git a/spring-messaging/src/test/java/org/springframework/messaging/protobuf/MsgOrBuilder.java b/spring-messaging/src/test/java/org/springframework/messaging/protobuf/MsgOrBuilder.java new file mode 100644 index 000000000000..ca9f94be7450 --- /dev/null +++ b/spring-messaging/src/test/java/org/springframework/messaging/protobuf/MsgOrBuilder.java @@ -0,0 +1,37 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: sample.proto + +package org.springframework.messaging.protobuf; + +public interface MsgOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // optional string foo = 1; + /** + * optional string foo = 1; + */ + boolean hasFoo(); + /** + * optional string foo = 1; + */ + java.lang.String getFoo(); + /** + * optional string foo = 1; + */ + com.google.protobuf.ByteString + getFooBytes(); + + // optional .SecondMsg blah = 2; + /** + * optional .SecondMsg blah = 2; + */ + boolean hasBlah(); + /** + * optional .SecondMsg blah = 2; + */ + SecondMsg getBlah(); + /** + * optional .SecondMsg blah = 2; + */ + SecondMsgOrBuilder getBlahOrBuilder(); +} diff --git a/spring-messaging/src/test/java/org/springframework/messaging/protobuf/OuterSample.java b/spring-messaging/src/test/java/org/springframework/messaging/protobuf/OuterSample.java new file mode 100644 index 000000000000..d3ecd6a62caa --- /dev/null +++ b/spring-messaging/src/test/java/org/springframework/messaging/protobuf/OuterSample.java @@ -0,0 +1,63 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: sample.proto + +package org.springframework.messaging.protobuf; + +@SuppressWarnings("deprecation") +public class OuterSample { + private OuterSample() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_Msg_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_Msg_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_SecondMsg_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_SecondMsg_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\014sample.proto\",\n\003Msg\022\013\n\003foo\030\001 \001(\t\022\030\n\004bl" + + "ah\030\002 \001(\0132\n.SecondMsg\"\031\n\tSecondMsg\022\014\n\004bla" + + "h\030\001 \001(\005B-\n\034org.springframework.protobufB" + + "\013OuterSampleP\001" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_Msg_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Msg_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_Msg_descriptor, + new java.lang.String[] { "Foo", "Blah", }); + internal_static_SecondMsg_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_SecondMsg_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_SecondMsg_descriptor, + new java.lang.String[] { "Blah", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/spring-messaging/src/test/java/org/springframework/messaging/protobuf/SecondMsg.java b/spring-messaging/src/test/java/org/springframework/messaging/protobuf/SecondMsg.java new file mode 100644 index 000000000000..5567d4e7843b --- /dev/null +++ b/spring-messaging/src/test/java/org/springframework/messaging/protobuf/SecondMsg.java @@ -0,0 +1,389 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: sample.proto + +package org.springframework.messaging.protobuf; + +/** + * Protobuf type {@code SecondMsg} + */ +public final class SecondMsg extends + com.google.protobuf.GeneratedMessage + implements SecondMsgOrBuilder { + // Use SecondMsg.newBuilder() to construct. + private SecondMsg(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private SecondMsg(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final SecondMsg defaultInstance; + public static SecondMsg getDefaultInstance() { + return defaultInstance; + } + + public SecondMsg getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SecondMsg( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + @SuppressWarnings("unused") + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + blah_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OuterSample.internal_static_SecondMsg_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return OuterSample.internal_static_SecondMsg_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SecondMsg.class, SecondMsg.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public SecondMsg parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SecondMsg(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // optional int32 blah = 1; + public static final int BLAH_FIELD_NUMBER = 1; + private int blah_; + /** + * optional int32 blah = 1; + */ + public boolean hasBlah() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int32 blah = 1; + */ + public int getBlah() { + return blah_; + } + + private void initFields() { + blah_ = 0; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeInt32(1, blah_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, blah_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static SecondMsg parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SecondMsg parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SecondMsg parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SecondMsg parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SecondMsg parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static SecondMsg parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static SecondMsg parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static SecondMsg parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static SecondMsg parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static SecondMsg parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(SecondMsg prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code SecondMsg} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements SecondMsgOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OuterSample.internal_static_SecondMsg_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return OuterSample.internal_static_SecondMsg_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SecondMsg.class, SecondMsg.Builder.class); + } + + // Construct using org.springframework.messaging.protobuf.SecondMsg.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + blah_ = 0; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OuterSample.internal_static_SecondMsg_descriptor; + } + + public SecondMsg getDefaultInstanceForType() { + return SecondMsg.getDefaultInstance(); + } + + public SecondMsg build() { + SecondMsg result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public SecondMsg buildPartial() { + SecondMsg result = new SecondMsg(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.blah_ = blah_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SecondMsg) { + return mergeFrom((SecondMsg)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SecondMsg other) { + if (other == SecondMsg.getDefaultInstance()) return this; + if (other.hasBlah()) { + setBlah(other.getBlah()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + SecondMsg parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (SecondMsg) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // optional int32 blah = 1; + private int blah_ ; + /** + * optional int32 blah = 1; + */ + public boolean hasBlah() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int32 blah = 1; + */ + public int getBlah() { + return blah_; + } + /** + * optional int32 blah = 1; + */ + public Builder setBlah(int value) { + bitField0_ |= 0x00000001; + blah_ = value; + onChanged(); + return this; + } + /** + * optional int32 blah = 1; + */ + public Builder clearBlah() { + bitField0_ = (bitField0_ & ~0x00000001); + blah_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:SecondMsg) + } + + static { + defaultInstance = new SecondMsg(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:SecondMsg) +} + diff --git a/spring-messaging/src/test/java/org/springframework/messaging/protobuf/SecondMsgOrBuilder.java b/spring-messaging/src/test/java/org/springframework/messaging/protobuf/SecondMsgOrBuilder.java new file mode 100644 index 000000000000..fc4ff1576cd6 --- /dev/null +++ b/spring-messaging/src/test/java/org/springframework/messaging/protobuf/SecondMsgOrBuilder.java @@ -0,0 +1,18 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: sample.proto + +package org.springframework.messaging.protobuf; + +public interface SecondMsgOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // optional int32 blah = 1; + /** + * optional int32 blah = 1; + */ + boolean hasBlah(); + /** + * optional int32 blah = 1; + */ + int getBlah(); +} diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java index 779c1de0526e..4b643212b6cf 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java @@ -41,6 +41,7 @@ import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.converter.MessageConverter; import org.springframework.messaging.converter.StringMessageConverter; +import org.springframework.messaging.converter.ProtobufMessageConverter; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.handler.annotation.SendTo; import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; @@ -281,13 +282,17 @@ public void configureMessageConvertersDefault() { CompositeMessageConverter compositeConverter = config.brokerMessageConverter(); List converters = compositeConverter.getConverters(); - assertThat(converters).hasSize(3); + assertThat(converters).hasSize(4); assertThat(converters.get(0)).isInstanceOf(StringMessageConverter.class); assertThat(converters.get(1)).isInstanceOf(ByteArrayMessageConverter.class); assertThat(converters.get(2)).isInstanceOf(MappingJackson2MessageConverter.class); + assertThat(converters.get(3)).isInstanceOf(ProtobufMessageConverter.class); ContentTypeResolver resolver = ((MappingJackson2MessageConverter) converters.get(2)).getContentTypeResolver(); assertThat(((DefaultContentTypeResolver) resolver).getDefaultMimeType()).isEqualTo(MimeTypeUtils.APPLICATION_JSON); + + resolver = ((ProtobufMessageConverter) converters.get(3)).getContentTypeResolver(); + assertThat(((DefaultContentTypeResolver) resolver).getDefaultMimeType()).isEqualTo(ProtobufMessageConverter.PROTOBUF); } @Test @@ -339,12 +344,13 @@ protected boolean configureMessageConverters(List messageConve }; CompositeMessageConverter compositeConverter = config.brokerMessageConverter(); - assertThat(compositeConverter.getConverters()).hasSize(4); + assertThat(compositeConverter.getConverters()).hasSize(5); Iterator iterator = compositeConverter.getConverters().iterator(); assertThat(iterator.next()).isEqualTo(testConverter); assertThat(iterator.next()).isInstanceOf(StringMessageConverter.class); assertThat(iterator.next()).isInstanceOf(ByteArrayMessageConverter.class); assertThat(iterator.next()).isInstanceOf(MappingJackson2MessageConverter.class); + assertThat(iterator.next()).isInstanceOf(ProtobufMessageConverter.class); } @Test diff --git a/spring-messaging/src/test/proto/sample.proto b/spring-messaging/src/test/proto/sample.proto new file mode 100644 index 000000000000..c303ef2894cf --- /dev/null +++ b/spring-messaging/src/test/proto/sample.proto @@ -0,0 +1,12 @@ +option java_package = "org.springframework.protobuf.messaging"; +option java_outer_classname = "OuterSample"; +option java_multiple_files = true; + +message Msg { + optional string foo = 1; + optional SecondMsg blah = 2; +} + +message SecondMsg { + optional int32 blah = 1; +} diff --git a/spring-websocket/spring-websocket.gradle b/spring-websocket/spring-websocket.gradle index 96355eef5369..b464a375073a 100644 --- a/spring-websocket/spring-websocket.gradle +++ b/spring-websocket/spring-websocket.gradle @@ -21,6 +21,7 @@ dependencies { optional("io.undertow:undertow-servlet") optional("io.undertow:undertow-websockets-jsr") optional("com.fasterxml.jackson.core:jackson-databind") + optional("com.google.protobuf:protobuf-java-util") testCompile("org.apache.tomcat.embed:tomcat-embed-core") testCompile("org.apache.tomcat.embed:tomcat-embed-websocket") testCompile("io.projectreactor.netty:reactor-netty") diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java index 31294cb57940..7323849b022c 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java @@ -44,6 +44,7 @@ import org.springframework.messaging.converter.DefaultContentTypeResolver; import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.converter.StringMessageConverter; +import org.springframework.messaging.converter.ProtobufMessageConverter; import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.messaging.simp.SimpSessionScope; import org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler; @@ -115,10 +116,13 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { private static final boolean javaxValidationPresent; + private static final boolean protobufPresent; + static { ClassLoader classLoader = MessageBrokerBeanDefinitionParser.class.getClassLoader(); jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader); javaxValidationPresent = ClassUtils.isPresent("javax.validation.Validator", classLoader); + protobufPresent = ClassUtils.isPresent("com.google.protobuf.Message", classLoader); } @@ -502,6 +506,13 @@ private RuntimeBeanReference registerMessageConverter( jacksonConverterDef.getPropertyValues().add("objectMapper", jacksonFactoryDef); converters.add(jacksonConverterDef); } + if (protobufPresent) { + final RootBeanDefinition protoConverterDef = new RootBeanDefinition(ProtobufMessageConverter.class); + RootBeanDefinition resolverDef = new RootBeanDefinition(DefaultContentTypeResolver.class); + resolverDef.getPropertyValues().add("defaultMimeType", ProtobufMessageConverter.PROTOBUF); + protoConverterDef.getPropertyValues().add("contentTypeResolver", resolverDef); + converters.add(protoConverterDef); + } } ConstructorArgumentValues cargs = new ConstructorArgumentValues(); cargs.addIndexedArgumentValue(0, converters); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java index 43e1ad59bdf8..ec0ded55043f 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java @@ -41,6 +41,7 @@ import org.springframework.messaging.converter.DefaultContentTypeResolver; import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.converter.MessageConverter; +import org.springframework.messaging.converter.ProtobufMessageConverter; import org.springframework.messaging.converter.StringMessageConverter; import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; @@ -339,14 +340,18 @@ public void annotationMethodMessageHandler() { assertThat(simpMessagingTemplate.getUserDestinationPrefix()).isEqualTo("/personal/"); List converters = compositeMessageConverter.getConverters(); - assertThat(converters).hasSize(3); + assertThat(converters).hasSize(4); assertThat(converters.get(0)).isInstanceOf(StringMessageConverter.class); assertThat(converters.get(1)).isInstanceOf(ByteArrayMessageConverter.class); assertThat(converters.get(2)).isInstanceOf(MappingJackson2MessageConverter.class); + assertThat(converters.get(3)).isInstanceOf(ProtobufMessageConverter.class); ContentTypeResolver resolver = ((MappingJackson2MessageConverter) converters.get(2)).getContentTypeResolver(); assertThat(((DefaultContentTypeResolver) resolver).getDefaultMimeType()).isEqualTo(MimeTypeUtils.APPLICATION_JSON); + resolver = ((ProtobufMessageConverter) converters.get(3)).getContentTypeResolver(); + assertThat(((DefaultContentTypeResolver) resolver).getDefaultMimeType()).isEqualTo(ProtobufMessageConverter.PROTOBUF); + DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(annotationMethodMessageHandler); Object pathMatcher = handlerAccessor.getPropertyValue("pathMatcher"); String pathSeparator = (String) new DirectFieldAccessor(pathMatcher).getPropertyValue("pathSeparator"); @@ -415,7 +420,7 @@ public void messageConverters() { CompositeMessageConverter compositeConverter = this.appContext.getBean(CompositeMessageConverter.class); assertThat(compositeConverter).isNotNull(); - assertThat(compositeConverter.getConverters().size()).isEqualTo(4); + assertThat(compositeConverter.getConverters().size()).isEqualTo(5); assertThat(compositeConverter.getConverters().iterator().next().getClass()).isEqualTo(StringMessageConverter.class); } From 25f3465f1f1dc852da379b95a4303d3b7891da23 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 29 Nov 2019 15:53:37 +0000 Subject: [PATCH 0134/2315] Polishing contribution See gh-24087 --- spring-messaging/spring-messaging.gradle | 2 +- .../converter/AbstractMessageConverter.java | 31 +++--- .../MappingJackson2MessageConverter.java | 1 - .../MarshallingMessageConverter.java | 3 +- .../ProtobufJsonFormatMessageConverter.java | 67 +++++++++++++ .../converter/ProtobufMessageConverter.java | 95 ++++++------------- .../AbstractMessageBrokerConfiguration.java | 22 +---- .../converter/MessageConverterTests.java | 17 ++-- ...ava => ProtobufMessageConverterTests.java} | 39 ++++---- .../MessageBrokerConfigurationTests.java | 10 +- ...rotobufJsonFormatHttpMessageConverter.java | 21 ++-- spring-websocket/spring-websocket.gradle | 1 - .../MessageBrokerBeanDefinitionParser.java | 11 --- ...essageBrokerBeanDefinitionParserTests.java | 9 +- src/checkstyle/checkstyle-suppressions.xml | 1 + 15 files changed, 157 insertions(+), 173 deletions(-) create mode 100644 spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufJsonFormatMessageConverter.java rename spring-messaging/src/test/java/org/springframework/messaging/converter/{ProtobufMessageConverterTest.java => ProtobufMessageConverterTests.java} (87%) diff --git a/spring-messaging/spring-messaging.gradle b/spring-messaging/spring-messaging.gradle index 3855f3007c46..66ddd442ebd2 100644 --- a/spring-messaging/spring-messaging.gradle +++ b/spring-messaging/spring-messaging.gradle @@ -13,9 +13,9 @@ dependencies { optional("io.rsocket:rsocket-transport-netty") optional("com.fasterxml.jackson.core:jackson-databind") optional("javax.xml.bind:jaxb-api") + optional("com.google.protobuf:protobuf-java-util") optional("org.jetbrains.kotlinx:kotlinx-coroutines-core") optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") - optional("com.google.protobuf:protobuf-java-util") testCompile("javax.inject:javax.inject-tck") testCompile("javax.servlet:javax.servlet-api") testCompile("javax.validation:validation-api") diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java index d741a6007594..0dd92e12064b 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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,10 +17,10 @@ package org.springframework.messaging.converter; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Arrays; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -48,7 +48,7 @@ public abstract class AbstractMessageConverter implements SmartMessageConverter protected final Log logger = LogFactory.getLog(getClass()); - private List supportedMimeTypes; + private final List supportedMimeTypes = new ArrayList<>(4); @Nullable private ContentTypeResolver contentTypeResolver = new DefaultContentTypeResolver(); @@ -59,28 +59,28 @@ public abstract class AbstractMessageConverter implements SmartMessageConverter /** - * Construct an {@code AbstractMessageConverter} supporting a single MIME type. + * Constructor with a single MIME type. * @param supportedMimeType the supported MIME type */ protected AbstractMessageConverter(MimeType supportedMimeType) { - setSupportedMimeTypes(Collections.singletonList(supportedMimeType)); + this(Collections.singletonList(supportedMimeType)); } /** - * Construct an {@code AbstractMessageConverter} supporting multiple MIME types. + * Constructor with one or more MIME types via vararg. * @param supportedMimeTypes the supported MIME types + * @since 5.2.2 */ - protected AbstractMessageConverter(Collection supportedMimeTypes) { - setSupportedMimeTypes(new ArrayList<>(supportedMimeTypes)); + protected AbstractMessageConverter(MimeType... supportedMimeTypes) { + this(Arrays.asList(supportedMimeTypes)); } /** - * Construct an {@code AbstractMessageConverter} supporting multiple MIME types. + * Constructor with a Collection of MIME types. * @param supportedMimeTypes the supported MIME types - * @since 5.2.2 */ - protected AbstractMessageConverter(MimeType... supportedMimeTypes) { - setSupportedMimeTypes(Arrays.asList(supportedMimeTypes)); + protected AbstractMessageConverter(Collection supportedMimeTypes) { + this.supportedMimeTypes.addAll(supportedMimeTypes); } @@ -92,12 +92,11 @@ public List getSupportedMimeTypes() { } /** - * Set the list of {@link MimeType} objects supported by this converter. + * Allows sub-classes to add more supported mime types. * @since 5.2.2 */ - protected void setSupportedMimeTypes(List supportedMimeTypes) { - Assert.notNull(supportedMimeTypes, "supportedMimeTypes must not be null"); - this.supportedMimeTypes = supportedMimeTypes; + protected void addSupportedMimeTypes(MimeType... supportedMimeTypes) { + this.supportedMimeTypes.addAll(Arrays.asList(supportedMimeTypes)); } /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java index 16dd3e19bc89..4cb87dc22890 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java @@ -22,7 +22,6 @@ import java.io.Writer; import java.lang.reflect.Type; import java.nio.charset.Charset; -import java.util.Arrays; import java.util.concurrent.atomic.AtomicReference; import com.fasterxml.jackson.annotation.JsonView; diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java index d031157398c2..34701c849a7f 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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. @@ -21,7 +21,6 @@ import java.io.StringReader; import java.io.StringWriter; import java.io.Writer; -import java.util.Arrays; import javax.xml.transform.Result; import javax.xml.transform.Source; diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufJsonFormatMessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufJsonFormatMessageConverter.java new file mode 100644 index 000000000000..2f07568b641d --- /dev/null +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufJsonFormatMessageConverter.java @@ -0,0 +1,67 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.messaging.converter; + +import com.google.protobuf.ExtensionRegistry; +import com.google.protobuf.util.JsonFormat; + +import org.springframework.lang.Nullable; + +/** + * Subclass of {@link ProtobufMessageConverter} for use with the official + * {@code "com.google.protobuf:protobuf-java-util"} library for JSON support. + * + *

Most importantly, this class allows for custom JSON parser and printer + * configurations through the {@link JsonFormat} utility. If no special parser + * or printer configuration is given, default variants will be used instead. + * + *

Requires Protobuf 3.x and {@code "com.google.protobuf:protobuf-java-util"} 3.x, + * with 3.3 or higher recommended. + * + * @author Rossen Stoyanchev + * @since 5.2.2 + */ +public class ProtobufJsonFormatMessageConverter extends ProtobufMessageConverter { + + /** + * Constructor with default instances of {@link JsonFormat.Parser}, + * {@link JsonFormat.Printer}, and {@link ExtensionRegistry}. + */ + public ProtobufJsonFormatMessageConverter(@Nullable ExtensionRegistry extensionRegistry) { + this(null, null); + } + + /** + * Constructor with given instances of {@link JsonFormat.Parser}, + * {@link JsonFormat.Printer}, and a default instance of {@link ExtensionRegistry}. + */ + public ProtobufJsonFormatMessageConverter( + @Nullable JsonFormat.Parser parser, @Nullable JsonFormat.Printer printer) { + + this(parser, printer, null); + } + + /** + * Constructor with given instances of {@link JsonFormat.Parser}, + * {@link JsonFormat.Printer}, and {@link ExtensionRegistry}. + */ + public ProtobufJsonFormatMessageConverter(@Nullable JsonFormat.Parser parser, + @Nullable JsonFormat.Printer printer, @Nullable ExtensionRegistry extensionRegistry) { + + super(new ProtobufJavaUtilSupport(parser, printer), extensionRegistry); + } + +} diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java index 2ac163a3a68f..1d5dbf820c84 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java @@ -23,12 +23,12 @@ import java.lang.reflect.Method; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.Map; import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.Message; import com.google.protobuf.util.JsonFormat; + import org.springframework.lang.Nullable; import org.springframework.messaging.MessageHeaders; import org.springframework.util.ClassUtils; @@ -77,59 +77,23 @@ public class ProtobufMessageConverter extends AbstractMessageConverter { /** - * Construct a new {@code ProtobufMessageConverter}. + * Constructor with a default instance of {@link ExtensionRegistry}. */ public ProtobufMessageConverter() { - this((ProtobufFormatSupport) null, (ExtensionRegistry) null); + this(null, null); } /** - * Construct a new {@code ProtobufMessageConverter} with a registry that specifies - * protocol message extensions. - * - * @param extensionRegistry the registry to populate + * Constructor with a given {@code ExtensionRegistry}. */ - public ProtobufMessageConverter(@Nullable ExtensionRegistry extensionRegistry) { + public ProtobufMessageConverter(ExtensionRegistry extensionRegistry) { this(null, extensionRegistry); } - /** - * Construct a new {@code ProtobufMessageConverter} with the given - * {@code JsonFormat.Parser} and {@code JsonFormat.Printer} configuration. - * - * @param parser the JSON parser configuration - * @param printer the JSON printer configuration - */ - public ProtobufMessageConverter(@Nullable JsonFormat.Parser parser, @Nullable JsonFormat.Printer printer) { - this(new ProtobufJavaUtilSupport(parser, printer), (ExtensionRegistry) null); - } + ProtobufMessageConverter(@Nullable ProtobufFormatSupport formatSupport, + @Nullable ExtensionRegistry extensionRegistry) { - /** - * Construct a new {@code ProtobufMessageConverter} with the given - * {@code JsonFormat.Parser} and {@code JsonFormat.Printer} configuration, also - * accepting a registry that specifies protocol message extensions. - * - * @param parser the JSON parser configuration - * @param printer the JSON printer configuration - * @param extensionRegistry the registry to populate - */ - public ProtobufMessageConverter(@Nullable JsonFormat.Parser parser, - @Nullable JsonFormat.Printer printer, @Nullable ExtensionRegistry extensionRegistry) { - - this(new ProtobufJavaUtilSupport(parser, printer), extensionRegistry); - } - - /** - * Construct a new {@code ProtobufMessageConverter} with the given - * {@code ProtobufFormatSupport} configuration, also - * accepting a registry that specifies protocol message extensions. - * - * @param formatSupport support third party - * @param extensionRegistry the registry to populate - */ - public ProtobufMessageConverter(@Nullable ProtobufFormatSupport formatSupport, - @Nullable ExtensionRegistry extensionRegistry) { - super(PROTOBUF); + super(PROTOBUF, TEXT_PLAIN); if (formatSupport != null) { this.protobufFormatSupport = formatSupport; @@ -142,12 +106,13 @@ else if (ClassUtils.isPresent("com.google.protobuf.util.JsonFormat", getClass(). } if (this.protobufFormatSupport != null) { - setSupportedMimeTypes(Arrays.asList(protobufFormatSupport.supportedMediaTypes())); + addSupportedMimeTypes(this.protobufFormatSupport.supportedMediaTypes()); } this.extensionRegistry = (extensionRegistry == null ? ExtensionRegistry.newInstance() : extensionRegistry); } + @Override protected boolean supports(Class clazz) { return Message.class.isAssignableFrom(clazz); @@ -161,7 +126,9 @@ protected boolean canConvertTo(Object payload, @Nullable MessageHeaders headers) } @Override - protected Object convertFromInternal(org.springframework.messaging.Message message, Class targetClass, @Nullable Object conversionHint) { + protected Object convertFromInternal(org.springframework.messaging.Message message, + Class targetClass, @Nullable Object conversionHint) { + MimeType contentType = getMimeType(message.getHeaders()); final Object payload = message.getPayload(); @@ -175,18 +142,16 @@ protected Object convertFromInternal(org.springframework.messaging.Message me } Message.Builder builder = getMessageBuilder(targetClass); - try { if (PROTOBUF.isCompatibleWith(contentType)) { builder.mergeFrom((byte[]) payload, this.extensionRegistry); } - else if (protobufFormatSupport != null) { - this.protobufFormatSupport.merge( - message, charset, contentType, this.extensionRegistry, builder); + else if (this.protobufFormatSupport != null) { + this.protobufFormatSupport.merge(message, charset, contentType, this.extensionRegistry, builder); } } - catch (IOException e) { - throw new MessageConversionException(message, "Could not read proto message" + e.getMessage(), e); + catch (IOException ex) { + throw new MessageConversionException(message, "Could not read proto message" + ex.getMessage(), ex); } return builder.build(); @@ -194,13 +159,14 @@ else if (protobufFormatSupport != null) { @Override - protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { + protected Object convertToInternal( + Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { + final Message message = (Message) payload; MimeType contentType = getMimeType(headers); if (contentType == null) { contentType = PROTOBUF; - } Charset charset = contentType.getCharset(); @@ -220,14 +186,13 @@ else if (this.protobufFormatSupport != null) { payload = new String(outputStream.toByteArray(), charset); } } - catch (IOException e) { - throw new MessageConversionException("Could not write proto message" + e.getMessage(), e); + catch (IOException ex) { + throw new MessageConversionException("Could not write proto message" + ex.getMessage(), ex); } return payload; } - /** * Create a new {@code Message.Builder} instance for the given class. *

This method uses a ConcurrentReferenceHashMap for caching method lookups. @@ -257,9 +222,9 @@ interface ProtobufFormatSupport { boolean supportsWriteOnly(@Nullable MimeType mediaType); - void merge(org.springframework.messaging.Message message, Charset charset, MimeType contentType, - ExtensionRegistry extensionRegistry, Message.Builder builder) - throws IOException, MessageConversionException; + void merge(org.springframework.messaging.Message message, + Charset charset, MimeType contentType, ExtensionRegistry extensionRegistry, + Message.Builder builder) throws IOException, MessageConversionException; void print(Message message, OutputStream output, MimeType contentType, Charset charset) throws IOException, MessageConversionException; @@ -283,7 +248,7 @@ public ProtobufJavaUtilSupport(@Nullable JsonFormat.Parser parser, @Nullable Jso @Override public MimeType[] supportedMediaTypes() { - return new MimeType[]{PROTOBUF, TEXT_PLAIN, APPLICATION_JSON}; + return new MimeType[]{APPLICATION_JSON}; } @Override @@ -292,8 +257,8 @@ public boolean supportsWriteOnly(@Nullable MimeType mimeType) { } @Override - public void merge(org.springframework.messaging.Message message, Charset charset, MimeType contentType, - ExtensionRegistry extensionRegistry, Message.Builder builder) + public void merge(org.springframework.messaging.Message message, Charset charset, + MimeType contentType, ExtensionRegistry extensionRegistry, Message.Builder builder) throws IOException, MessageConversionException { if (contentType.isCompatibleWith(APPLICATION_JSON)) { @@ -313,12 +278,12 @@ public void print(Message message, OutputStream output, MimeType contentType, Ch OutputStreamWriter writer = new OutputStreamWriter(output, charset); this.printer.appendTo(message, writer); writer.flush(); - } else { + } + else { throw new MessageConversionException( "protobuf-java-util does not support printing " + contentType); } } } - } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java index 519fbac6d110..a3cc4f10c15a 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java @@ -37,7 +37,6 @@ import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.converter.MessageConverter; import org.springframework.messaging.converter.StringMessageConverter; -import org.springframework.messaging.converter.ProtobufMessageConverter; import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; import org.springframework.messaging.simp.SimpLogging; @@ -94,15 +93,9 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC private static final String MVC_VALIDATOR_NAME = "mvcValidator"; - private static final boolean jackson2Present; + private static final boolean jackson2Present = ClassUtils.isPresent( + "com.fasterxml.jackson.databind.ObjectMapper", AbstractMessageBrokerConfiguration.class.getClassLoader()); - private static final boolean protobufPresent; - - static { - ClassLoader classLoader = AbstractMessageBrokerConfiguration.class.getClassLoader(); - jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader); - protobufPresent = ClassUtils.isPresent("com.google.protobuf.Message", classLoader); - } @Nullable private ApplicationContext applicationContext; @@ -398,9 +391,6 @@ public CompositeMessageConverter brokerMessageConverter() { if (jackson2Present) { converters.add(createJacksonConverter()); } - if (protobufPresent) { - converters.add(createProtobufConverter()); - } } return new CompositeMessageConverter(converters); } @@ -413,14 +403,6 @@ protected MappingJackson2MessageConverter createJacksonConverter() { return converter; } - protected ProtobufMessageConverter createProtobufConverter() { - DefaultContentTypeResolver resolver = new DefaultContentTypeResolver(); - resolver.setDefaultMimeType(ProtobufMessageConverter.PROTOBUF); - final ProtobufMessageConverter converter = new ProtobufMessageConverter(); - converter.setContentTypeResolver(resolver); - return converter; - } - /** * Override this method to add custom message converters. * @param messageConverters the list to add converters to, initially empty diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java index ff834b84e40a..dfb4ff7409ca 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java @@ -78,8 +78,7 @@ public void supportsMimeTypeNotSpecified() { public void supportsMimeTypeNoneConfigured() { Message message = MessageBuilder.withPayload( "ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build(); - final MimeType[] empty = {}; - this.converter = new TestMessageConverter(empty); + this.converter = new TestMessageConverter(new MimeType[0]); assertThat(this.converter.fromMessage(message, String.class)).isEqualTo("success-from"); } @@ -100,10 +99,8 @@ public void canConvertFromStrictContentTypeMatch() { @Test public void setStrictContentTypeMatchWithNoSupportedMimeTypes() { - final MimeType[] empty = {}; - this.converter = new TestMessageConverter(empty); - assertThatIllegalArgumentException().isThrownBy(() -> - this.converter.setStrictContentTypeMatch(true)); + this.converter = new TestMessageConverter(new MimeType[0]); + assertThatIllegalArgumentException().isThrownBy(() -> this.converter.setStrictContentTypeMatch(true)); } @Test @@ -158,15 +155,15 @@ protected boolean supports(Class clazz) { } @Override - protected Object convertFromInternal(Message message, Class targetClass, - @Nullable Object conversionHint) { + protected Object convertFromInternal( + Message message, Class targetClass, @Nullable Object conversionHint) { return "success-from"; } @Override - protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, - @Nullable Object conversionHint) { + protected Object convertToInternal( + Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { return "success-to"; } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/ProtobufMessageConverterTest.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/ProtobufMessageConverterTests.java similarity index 87% rename from spring-messaging/src/test/java/org/springframework/messaging/converter/ProtobufMessageConverterTest.java rename to spring-messaging/src/test/java/org/springframework/messaging/converter/ProtobufMessageConverterTests.java index fd3b622fc1e6..63fa57513a13 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/ProtobufMessageConverterTest.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/ProtobufMessageConverterTests.java @@ -16,13 +16,13 @@ package org.springframework.messaging.converter; -import java.io.IOException; import java.util.HashMap; import java.util.Map; import com.google.protobuf.ExtensionRegistry; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.protobuf.Msg; @@ -39,15 +39,18 @@ * * @author Parviz Rozikov */ -class ProtobufMessageConverterTest { +public class ProtobufMessageConverterTests { private ProtobufMessageConverter converter; private ExtensionRegistry extensionRegistry; private Msg testMsg; + private Message message; + private Message messageWithoutContentType; + private Message messageJson; @@ -58,20 +61,22 @@ public void setup() { this.testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build(); this.message = MessageBuilder.withPayload(this.testMsg.toByteArray()) .setHeader(CONTENT_TYPE, ProtobufMessageConverter.PROTOBUF).build(); - this.messageWithoutContentType = MessageBuilder.withPayload(this.testMsg.toByteArray()) + this.messageWithoutContentType = MessageBuilder.withPayload(this.testMsg.toByteArray()).build(); + this.messageJson = MessageBuilder.withPayload( + "{\n" + + " \"foo\": \"Foo\",\n" + + " \"blah\": {\n" + + " \"blah\": 123\n" + + " }\n" + + "}") + .setHeader(CONTENT_TYPE, APPLICATION_JSON) .build(); - this.messageJson = MessageBuilder.withPayload("{\n" + - " \"foo\": \"Foo\",\n" + - " \"blah\": {\n" + - " \"blah\": 123\n" + - " }\n" + - "}") - .setHeader(CONTENT_TYPE, APPLICATION_JSON).build(); } + @Test public void extensionRegistryNull() { - ProtobufMessageConverter converter = new ProtobufMessageConverter((ExtensionRegistry) null); + ProtobufMessageConverter converter = new ProtobufMessageConverter(null); assertThat(converter.extensionRegistry).isNotNull(); } @@ -92,13 +97,13 @@ public void canConvertTo() { @Test - public void convertFrom() throws IOException { + public void convertFrom() { final Msg msg = (Msg) converter.fromMessage(message, Msg.class); assertThat(msg).isEqualTo(testMsg); } @Test - public void convertTo() throws IOException { + public void convertTo() { final Message message = converter.toMessage(this.testMsg, this.message.getHeaders()); assertThat(message).isNotNull(); assertThat(message.getPayload()).isEqualTo(this.message.getPayload()); @@ -106,19 +111,19 @@ public void convertTo() throws IOException { @Test - public void convertFromNoContentType() throws IOException { + public void convertFromNoContentType(){ Msg result = (Msg) converter.fromMessage(messageWithoutContentType, Msg.class); assertThat(result).isEqualTo(testMsg); } @Test - public void defaultContentType() throws Exception { + public void defaultContentType() { assertThat(converter.getDefaultContentType(testMsg)).isEqualTo(ProtobufMessageConverter.PROTOBUF); } @Test - public void testJsonWithGoogleProtobuf() throws Exception { + public void testJsonWithGoogleProtobuf() { this.converter = new ProtobufMessageConverter( new ProtobufMessageConverter.ProtobufJavaUtilSupport(null, null), extensionRegistry); @@ -139,4 +144,4 @@ public void testJsonWithGoogleProtobuf() throws Exception { assertThat(msg).isEqualTo(this.testMsg); } -} \ No newline at end of file +} diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java index 4b643212b6cf..779c1de0526e 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java @@ -41,7 +41,6 @@ import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.converter.MessageConverter; import org.springframework.messaging.converter.StringMessageConverter; -import org.springframework.messaging.converter.ProtobufMessageConverter; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.handler.annotation.SendTo; import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; @@ -282,17 +281,13 @@ public void configureMessageConvertersDefault() { CompositeMessageConverter compositeConverter = config.brokerMessageConverter(); List converters = compositeConverter.getConverters(); - assertThat(converters).hasSize(4); + assertThat(converters).hasSize(3); assertThat(converters.get(0)).isInstanceOf(StringMessageConverter.class); assertThat(converters.get(1)).isInstanceOf(ByteArrayMessageConverter.class); assertThat(converters.get(2)).isInstanceOf(MappingJackson2MessageConverter.class); - assertThat(converters.get(3)).isInstanceOf(ProtobufMessageConverter.class); ContentTypeResolver resolver = ((MappingJackson2MessageConverter) converters.get(2)).getContentTypeResolver(); assertThat(((DefaultContentTypeResolver) resolver).getDefaultMimeType()).isEqualTo(MimeTypeUtils.APPLICATION_JSON); - - resolver = ((ProtobufMessageConverter) converters.get(3)).getContentTypeResolver(); - assertThat(((DefaultContentTypeResolver) resolver).getDefaultMimeType()).isEqualTo(ProtobufMessageConverter.PROTOBUF); } @Test @@ -344,13 +339,12 @@ protected boolean configureMessageConverters(List messageConve }; CompositeMessageConverter compositeConverter = config.brokerMessageConverter(); - assertThat(compositeConverter.getConverters()).hasSize(5); + assertThat(compositeConverter.getConverters()).hasSize(4); Iterator iterator = compositeConverter.getConverters().iterator(); assertThat(iterator.next()).isEqualTo(testConverter); assertThat(iterator.next()).isInstanceOf(StringMessageConverter.class); assertThat(iterator.next()).isInstanceOf(ByteArrayMessageConverter.class); assertThat(iterator.next()).isInstanceOf(MappingJackson2MessageConverter.class); - assertThat(iterator.next()).isInstanceOf(ProtobufMessageConverter.class); } @Test diff --git a/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufJsonFormatHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufJsonFormatHttpMessageConverter.java index 47bc2ad91a5d..a89df049cd79 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufJsonFormatHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufJsonFormatHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -42,18 +42,16 @@ public class ProtobufJsonFormatHttpMessageConverter extends ProtobufHttpMessageConverter { /** - * Construct a new {@code ProtobufJsonFormatHttpMessageConverter} with default - * {@code JsonFormat.Parser} and {@code JsonFormat.Printer} configuration. + * Constructor with default instances of {@link JsonFormat.Parser}, + * {@link JsonFormat.Printer}, and {@link ExtensionRegistry}. */ public ProtobufJsonFormatHttpMessageConverter() { this(null, null, (ExtensionRegistry)null); } /** - * Construct a new {@code ProtobufJsonFormatHttpMessageConverter} with the given - * {@code JsonFormat.Parser} and {@code JsonFormat.Printer} configuration. - * @param parser the JSON parser configuration - * @param printer the JSON printer configuration + * Constructor with given instances of {@link JsonFormat.Parser}, + * {@link JsonFormat.Printer}, and a default instance of {@link ExtensionRegistry}. */ public ProtobufJsonFormatHttpMessageConverter( @Nullable JsonFormat.Parser parser, @Nullable JsonFormat.Printer printer) { @@ -62,13 +60,8 @@ public ProtobufJsonFormatHttpMessageConverter( } /** - * Construct a new {@code ProtobufJsonFormatHttpMessageConverter} with the given - * {@code JsonFormat.Parser} and {@code JsonFormat.Printer} configuration, also - * accepting a registry that specifies protocol message extensions. - * @param parser the JSON parser configuration - * @param printer the JSON printer configuration - * @param extensionRegistry the registry to populate - * @since 5.1 + * Constructor with given instances of {@link JsonFormat.Parser}, + * {@link JsonFormat.Printer}, and {@link ExtensionRegistry}. */ public ProtobufJsonFormatHttpMessageConverter(@Nullable JsonFormat.Parser parser, @Nullable JsonFormat.Printer printer, @Nullable ExtensionRegistry extensionRegistry) { diff --git a/spring-websocket/spring-websocket.gradle b/spring-websocket/spring-websocket.gradle index b464a375073a..96355eef5369 100644 --- a/spring-websocket/spring-websocket.gradle +++ b/spring-websocket/spring-websocket.gradle @@ -21,7 +21,6 @@ dependencies { optional("io.undertow:undertow-servlet") optional("io.undertow:undertow-websockets-jsr") optional("com.fasterxml.jackson.core:jackson-databind") - optional("com.google.protobuf:protobuf-java-util") testCompile("org.apache.tomcat.embed:tomcat-embed-core") testCompile("org.apache.tomcat.embed:tomcat-embed-websocket") testCompile("io.projectreactor.netty:reactor-netty") diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java index 7323849b022c..31294cb57940 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java @@ -44,7 +44,6 @@ import org.springframework.messaging.converter.DefaultContentTypeResolver; import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.converter.StringMessageConverter; -import org.springframework.messaging.converter.ProtobufMessageConverter; import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.messaging.simp.SimpSessionScope; import org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler; @@ -116,13 +115,10 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { private static final boolean javaxValidationPresent; - private static final boolean protobufPresent; - static { ClassLoader classLoader = MessageBrokerBeanDefinitionParser.class.getClassLoader(); jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader); javaxValidationPresent = ClassUtils.isPresent("javax.validation.Validator", classLoader); - protobufPresent = ClassUtils.isPresent("com.google.protobuf.Message", classLoader); } @@ -506,13 +502,6 @@ private RuntimeBeanReference registerMessageConverter( jacksonConverterDef.getPropertyValues().add("objectMapper", jacksonFactoryDef); converters.add(jacksonConverterDef); } - if (protobufPresent) { - final RootBeanDefinition protoConverterDef = new RootBeanDefinition(ProtobufMessageConverter.class); - RootBeanDefinition resolverDef = new RootBeanDefinition(DefaultContentTypeResolver.class); - resolverDef.getPropertyValues().add("defaultMimeType", ProtobufMessageConverter.PROTOBUF); - protoConverterDef.getPropertyValues().add("contentTypeResolver", resolverDef); - converters.add(protoConverterDef); - } } ConstructorArgumentValues cargs = new ConstructorArgumentValues(); cargs.addIndexedArgumentValue(0, converters); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java index ec0ded55043f..43e1ad59bdf8 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java @@ -41,7 +41,6 @@ import org.springframework.messaging.converter.DefaultContentTypeResolver; import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.converter.MessageConverter; -import org.springframework.messaging.converter.ProtobufMessageConverter; import org.springframework.messaging.converter.StringMessageConverter; import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; @@ -340,18 +339,14 @@ public void annotationMethodMessageHandler() { assertThat(simpMessagingTemplate.getUserDestinationPrefix()).isEqualTo("/personal/"); List converters = compositeMessageConverter.getConverters(); - assertThat(converters).hasSize(4); + assertThat(converters).hasSize(3); assertThat(converters.get(0)).isInstanceOf(StringMessageConverter.class); assertThat(converters.get(1)).isInstanceOf(ByteArrayMessageConverter.class); assertThat(converters.get(2)).isInstanceOf(MappingJackson2MessageConverter.class); - assertThat(converters.get(3)).isInstanceOf(ProtobufMessageConverter.class); ContentTypeResolver resolver = ((MappingJackson2MessageConverter) converters.get(2)).getContentTypeResolver(); assertThat(((DefaultContentTypeResolver) resolver).getDefaultMimeType()).isEqualTo(MimeTypeUtils.APPLICATION_JSON); - resolver = ((ProtobufMessageConverter) converters.get(3)).getContentTypeResolver(); - assertThat(((DefaultContentTypeResolver) resolver).getDefaultMimeType()).isEqualTo(ProtobufMessageConverter.PROTOBUF); - DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(annotationMethodMessageHandler); Object pathMatcher = handlerAccessor.getPropertyValue("pathMatcher"); String pathSeparator = (String) new DirectFieldAccessor(pathMatcher).getPropertyValue("pathSeparator"); @@ -420,7 +415,7 @@ public void messageConverters() { CompositeMessageConverter compositeConverter = this.appContext.getBean(CompositeMessageConverter.class); assertThat(compositeConverter).isNotNull(); - assertThat(compositeConverter.getConverters().size()).isEqualTo(5); + assertThat(compositeConverter.getConverters().size()).isEqualTo(4); assertThat(compositeConverter.getConverters().iterator().next().getClass()).isEqualTo(StringMessageConverter.class); } diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index bd0ffdcdb243..2726dce25761 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -52,6 +52,7 @@ + From a15a726fef4be798a24250003f57b9e88f869058 Mon Sep 17 00:00:00 2001 From: Frederik Boster Date: Mon, 25 Nov 2019 15:02:13 +0100 Subject: [PATCH 0135/2315] Improve getMultipartContentType in mock request. See gh-24074 --- .../web/MockMultipartHttpServletRequest.java | 15 ++++++++++++-- .../MockMultipartHttpServletRequestTests.java | 20 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java b/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java index 935d66aee71e..e118497c19c7 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java @@ -16,6 +16,7 @@ package org.springframework.mock.web; +import java.io.IOException; import java.util.Collections; import java.util.Enumeration; import java.util.Iterator; @@ -23,6 +24,8 @@ import java.util.Map; import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.Part; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -121,9 +124,17 @@ public String getMultipartContentType(String paramOrFileName) { if (file != null) { return file.getContentType(); } - else { - return null; + + try { + Part part = getPart(paramOrFileName); + if (part != null) { + return part.getContentType(); + } + } catch (ServletException | IOException e) { + throw new IllegalStateException("Cannot extract content type from multipart request.", e); } + + return null; } @Override diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java index 96fc17a33cc4..5b1a0ec44f72 100644 --- a/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java +++ b/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java @@ -27,6 +27,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; import org.springframework.util.FileCopyUtils; import org.springframework.util.ObjectUtils; import org.springframework.web.multipart.MultipartFile; @@ -61,6 +63,24 @@ void mockMultipartHttpServletRequestWithInputStream() throws IOException { doTestMultipartHttpServletRequest(request); } + @Test + void mockMultiPartHttpServletRequestWithMixedData() { + MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest(); + request.addFile(new MockMultipartFile("file", "myOrigFilename", MediaType.TEXT_PLAIN_VALUE, "myContent2".getBytes())); + + MockPart metadataPart = new MockPart("metadata", "{\"foo\": \"bar\"}".getBytes()); + metadataPart.getHeaders().setContentType(MediaType.APPLICATION_JSON); + request.addPart(metadataPart); + + HttpHeaders fileHttpHeaders = request.getMultipartHeaders("file"); + assertThat(fileHttpHeaders).isNotNull(); + assertThat(fileHttpHeaders.getContentType()).isEqualTo(MediaType.TEXT_PLAIN); + + HttpHeaders dataHttpHeaders = request.getMultipartHeaders("metadata"); + assertThat(dataHttpHeaders).isNotNull(); + assertThat(dataHttpHeaders.getContentType()).isEqualTo(MediaType.APPLICATION_JSON); + } + private void doTestMultipartHttpServletRequest(MultipartHttpServletRequest request) throws IOException { Set fileNames = new HashSet<>(); Iterator fileIter = request.getFileNames(); From 395c1e415cb7c494cde4be3d8a29c16a4d488094 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 29 Nov 2019 11:48:33 +0000 Subject: [PATCH 0136/2315] Polishing contribution See gh-24074 --- .../web/MockMultipartHttpServletRequest.java | 10 +++++----- .../test/MockMultipartHttpServletRequest.java | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java b/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java index e118497c19c7..b438a4fe7d43 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -124,16 +124,16 @@ public String getMultipartContentType(String paramOrFileName) { if (file != null) { return file.getContentType(); } - try { Part part = getPart(paramOrFileName); if (part != null) { return part.getContentType(); } - } catch (ServletException | IOException e) { - throw new IllegalStateException("Cannot extract content type from multipart request.", e); } - + catch (ServletException | IOException ex) { + // Should never happen (we're not actually parsing) + throw new IllegalStateException(ex); + } return null; } diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartHttpServletRequest.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartHttpServletRequest.java index 7aeab6f98bfa..996f1f562522 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartHttpServletRequest.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartHttpServletRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -16,6 +16,7 @@ package org.springframework.mock.web.test; +import java.io.IOException; import java.util.Collections; import java.util.Enumeration; import java.util.Iterator; @@ -23,6 +24,8 @@ import java.util.Map; import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.Part; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -121,9 +124,17 @@ public String getMultipartContentType(String paramOrFileName) { if (file != null) { return file.getContentType(); } - else { - return null; + try { + Part part = getPart(paramOrFileName); + if (part != null) { + return part.getContentType(); + } + } + catch (ServletException | IOException ex) { + // Should never happen (we're not actually parsing) + throw new IllegalStateException(ex); } + return null; } @Override From 093323beeb97bb4d096782d2b6c964039781a1e6 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 29 Nov 2019 17:30:29 +0100 Subject: [PATCH 0137/2315] Introduce Checkstyle rule to prohibit class names ending with "Test" --- .../scannable/{_package.java => PackageMarker.java} | 8 ++++---- .../ComponentScanAnnotationIntegrationTests.java | 6 +++--- src/checkstyle/checkstyle.xml | 8 ++++++++ 3 files changed, 15 insertions(+), 7 deletions(-) rename spring-context/src/test/java/example/scannable/{_package.java => PackageMarker.java} (83%) diff --git a/spring-context/src/test/java/example/scannable/_package.java b/spring-context/src/test/java/example/scannable/PackageMarker.java similarity index 83% rename from spring-context/src/test/java/example/scannable/_package.java rename to spring-context/src/test/java/example/scannable/PackageMarker.java index 2f0de24204ed..5ee79482a7ec 100644 --- a/spring-context/src/test/java/example/scannable/_package.java +++ b/spring-context/src/test/java/example/scannable/PackageMarker.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2019 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. @@ -16,10 +16,10 @@ package example.scannable; - /** - * Marker class for example.scannable package. + * Marker class for {@code example.scannable} package. * * @see org.springframework.context.annotation.ComponentScan#basePackageClasses() */ -public class _package { } +public class PackageMarker { +} diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java index 6c20e2dbffb4..86b607729280 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java @@ -78,7 +78,7 @@ public class ComponentScanAnnotationIntegrationTests { @Test public void controlScan() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); - ctx.scan(example.scannable._package.class.getPackage().getName()); + ctx.scan(example.scannable.PackageMarker.class.getPackage().getName()); ctx.refresh(); assertThat(ctx.containsBean("fooServiceImpl")).as( "control scan for example.scannable package failed to register FooServiceImpl bean").isTrue(); @@ -326,7 +326,7 @@ public boolean match(MetadataReader metadataReader, MetadataReaderFactory metada @Configuration -@ComponentScan(basePackageClasses = example.scannable._package.class) +@ComponentScan(basePackageClasses = example.scannable.PackageMarker.class) class ComponentScanAnnotatedConfig { @Bean @@ -456,7 +456,7 @@ class ComponentScanWithMultipleAnnotationIncludeFilters2 {} @ComponentScan( value = "example.scannable", basePackages = "example.scannable", - basePackageClasses = example.scannable._package.class) + basePackageClasses = example.scannable.PackageMarker.class) class ComponentScanWithBasePackagesAndValueAlias {} diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index acbc9db0908f..96d98fb239a7 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -51,6 +51,14 @@ + + + + + + + From 7f61f3852cb45b475d4b0ccd88dc4b9d4c60a2fa Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 29 Nov 2019 16:58:09 +0000 Subject: [PATCH 0138/2315] Enable reading from the remote build cache for all Previously, the remote build cache was only enabled if the GRADLE_ENTERPRISE_URL environment variable was configured. This meant that contributors would not benefit from the build time improvements of the caching without some additional setup. This commit updates the buildCache configuration so that reading from the remote build cache at https://ge.spring.io is enabled for all. Pushing to the cache continues to be disabled unless the required credentials are provided. Build scan configuration has also been updated in line with this change. While the server URL is now hardcoded, publishing is still opt-in via an environment variable. The exact mechanism by which someone can opt in will change in the future once some server-side changes have been made. At this point, only a change to publishAlwaysIf should be necessary. Closes gh-24105 --- build.gradle | 16 +++++++--------- gradle/build-cache-settings.gradle | 22 ++++++++++------------ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index 760ae2e04ae0..8247e300a2ab 100644 --- a/build.gradle +++ b/build.gradle @@ -18,16 +18,14 @@ plugins { id "com.github.ben-manes.versions" version "0.24.0" } -if (System.getenv('GRADLE_ENTERPRISE_URL')) { - apply from: "$rootDir/gradle/build-scan-user-data.gradle" - buildScan { - captureTaskInputFiles = true - obfuscation { - ipAddresses { addresses -> addresses.collect { address -> '0.0.0.0'} } - } - publishAlways() - server = System.getenv('GRADLE_ENTERPRISE_URL') +apply from: "$rootDir/gradle/build-scan-user-data.gradle" +buildScan { + captureTaskInputFiles = true + obfuscation { + ipAddresses { addresses -> addresses.collect { address -> '0.0.0.0'} } } + publishAlwaysIf(System.getenv('GRADLE_ENTERPRISE_URL') != null) + server = 'https://ge.spring.io' } ext { diff --git a/gradle/build-cache-settings.gradle b/gradle/build-cache-settings.gradle index d62ea57ebd26..5684b4942b8f 100644 --- a/gradle/build-cache-settings.gradle +++ b/gradle/build-cache-settings.gradle @@ -2,18 +2,16 @@ buildCache { local { enabled = true } - if (System.getenv('GRADLE_ENTERPRISE_URL')) { - remote(HttpBuildCache) { - enabled = true - url = "${System.getenv('GRADLE_ENTERPRISE_URL')}/cache/" - def cacheUsername = System.getenv('GRADLE_ENTERPRISE_CACHE_USERNAME') - def cachePassword = System.getenv('GRADLE_ENTERPRISE_CACHE_PASSWORD') - if (cacheUsername && cachePassword) { - push = true - credentials { - username = cacheUsername - password = cachePassword - } + remote(HttpBuildCache) { + enabled = true + url = 'https://ge.spring.io/cache/' + def cacheUsername = System.getenv('GRADLE_ENTERPRISE_CACHE_USERNAME') + def cachePassword = System.getenv('GRADLE_ENTERPRISE_CACHE_PASSWORD') + if (cacheUsername && cachePassword) { + push = true + credentials { + username = cacheUsername + password = cachePassword } } } From 5648ef3276b2e5ff6a439e2e3a7e6236714182a7 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 29 Nov 2019 18:41:59 +0100 Subject: [PATCH 0139/2315] Fix examples for settings in reference manual Closes gh-24080 --- src/docs/asciidoc/data-access.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docs/asciidoc/data-access.adoc b/src/docs/asciidoc/data-access.adoc index f49e957d1fe1..6cb8f23a4339 100644 --- a/src/docs/asciidoc/data-access.adoc +++ b/src/docs/asciidoc/data-access.adoc @@ -1094,13 +1094,13 @@ that are nested within `` and `` tags: | No | | Comma-delimited list of `Exception` instances that trigger rollback. For example, - `com.foo.MyBusinessException,ServletException.` + `com.foo.MyBusinessException,ServletException`. | `no-rollback-for` | No | | Comma-delimited list of `Exception` instances that do not trigger rollback. For example, - `com.foo.MyBusinessException,ServletException.` + `com.foo.MyBusinessException,ServletException`. |=== From 52a1fc4329d6d97fb4a1e1832c74393dcc4f72e9 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 29 Nov 2019 18:50:42 +0100 Subject: [PATCH 0140/2315] Polish BatchPreparedStatementSetter example in reference manual Closes gh-24084 --- src/docs/asciidoc/data-access.adoc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/docs/asciidoc/data-access.adoc b/src/docs/asciidoc/data-access.adoc index 6cb8f23a4339..b68323099f87 100644 --- a/src/docs/asciidoc/data-access.adoc +++ b/src/docs/asciidoc/data-access.adoc @@ -3848,9 +3848,10 @@ based on entries in a list, and the entire list is used as the batch: "update t_actor set first_name = ?, last_name = ? where id = ?", new BatchPreparedStatementSetter() { public void setValues(PreparedStatement ps, int i) throws SQLException { - ps.setString(1, actors.get(i).getFirstName()); - ps.setString(2, actors.get(i).getLastName()); - ps.setLong(3, actors.get(i).getId().longValue()); + Actor actor = actors.get(i); + ps.setString(1, actor.getFirstName()); + ps.setString(2, actor.getLastName()); + ps.setLong(3, actor.getId().longValue()); } public int getBatchSize() { return actors.size(); From d7023fd02b6312bac82f8365cd7b864ec0af8c13 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 29 Nov 2019 19:01:42 +0100 Subject: [PATCH 0141/2315] Delete unused JdbcTemplate fields in examples Closes gh-24085 --- src/docs/asciidoc/data-access.adoc | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/docs/asciidoc/data-access.adoc b/src/docs/asciidoc/data-access.adoc index b68323099f87..38fe149b3e40 100644 --- a/src/docs/asciidoc/data-access.adoc +++ b/src/docs/asciidoc/data-access.adoc @@ -4124,11 +4124,9 @@ example uses only one configuration method (we show examples of multiple methods ---- public class JdbcActorDao implements ActorDao { - private JdbcTemplate jdbcTemplate; private SimpleJdbcInsert insertActor; public void setDataSource(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); this.insertActor = new SimpleJdbcInsert(dataSource).withTableName("t_actor"); } @@ -4148,7 +4146,6 @@ example uses only one configuration method (we show examples of multiple methods ---- class JdbcActorDao(dataSource: DataSource) : ActorDao { - private val jdbcTemplate = JdbcTemplate(dataSource) private val insertActor = SimpleJdbcInsert(dataSource).withTableName("t_actor") fun add(actor: Actor) { @@ -4183,11 +4180,9 @@ listing shows how it works: ---- public class JdbcActorDao implements ActorDao { - private JdbcTemplate jdbcTemplate; private SimpleJdbcInsert insertActor; public void setDataSource(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); this.insertActor = new SimpleJdbcInsert(dataSource) .withTableName("t_actor") .usingGeneratedKeyColumns("id"); @@ -4209,7 +4204,6 @@ listing shows how it works: ---- class JdbcActorDao(dataSource: DataSource) : ActorDao { - private val jdbcTemplate = JdbcTemplate(dataSource) private val insertActor = SimpleJdbcInsert(dataSource) .withTableName("t_actor").usingGeneratedKeyColumns("id") @@ -4245,11 +4239,9 @@ You can limit the columns for an insert by specifying a list of column names wit ---- public class JdbcActorDao implements ActorDao { - private JdbcTemplate jdbcTemplate; private SimpleJdbcInsert insertActor; public void setDataSource(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); this.insertActor = new SimpleJdbcInsert(dataSource) .withTableName("t_actor") .usingColumns("first_name", "last_name") @@ -4272,7 +4264,6 @@ You can limit the columns for an insert by specifying a list of column names wit ---- class JdbcActorDao(dataSource: DataSource) : ActorDao { - private val jdbcTemplate = JdbcTemplate(dataSource) private val insertActor = SimpleJdbcInsert(dataSource) .withTableName("t_actor") .usingColumns("first_name", "last_name") @@ -4309,11 +4300,9 @@ values. The following example shows how to use `BeanPropertySqlParameterSource`: ---- public class JdbcActorDao implements ActorDao { - private JdbcTemplate jdbcTemplate; private SimpleJdbcInsert insertActor; public void setDataSource(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); this.insertActor = new SimpleJdbcInsert(dataSource) .withTableName("t_actor") .usingGeneratedKeyColumns("id"); @@ -4333,7 +4322,6 @@ values. The following example shows how to use `BeanPropertySqlParameterSource`: ---- class JdbcActorDao(dataSource: DataSource) : ActorDao { - private val jdbcTemplate = JdbcTemplate(dataSource) private val insertActor = SimpleJdbcInsert(dataSource) .withTableName("t_actor") .usingGeneratedKeyColumns("id") @@ -4356,11 +4344,9 @@ convenient `addValue` method that can be chained. The following example shows ho ---- public class JdbcActorDao implements ActorDao { - private JdbcTemplate jdbcTemplate; private SimpleJdbcInsert insertActor; public void setDataSource(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); this.insertActor = new SimpleJdbcInsert(dataSource) .withTableName("t_actor") .usingGeneratedKeyColumns("id"); @@ -4382,7 +4368,6 @@ convenient `addValue` method that can be chained. The following example shows ho ---- class JdbcActorDao(dataSource: DataSource) : ActorDao { - private val jdbcTemplate = JdbcTemplate(dataSource) private val insertActor = SimpleJdbcInsert(dataSource) .withTableName("t_actor") .usingGeneratedKeyColumns("id") @@ -4445,11 +4430,9 @@ of the stored procedure): ---- public class JdbcActorDao implements ActorDao { - private JdbcTemplate jdbcTemplate; private SimpleJdbcCall procReadActor; public void setDataSource(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); this.procReadActor = new SimpleJdbcCall(dataSource) .withProcedureName("read_actor"); } @@ -4474,7 +4457,6 @@ of the stored procedure): ---- class JdbcActorDao(dataSource: DataSource) : ActorDao { - private val jdbcTemplate = JdbcTemplate(dataSource) private val procReadActor = SimpleJdbcCall(dataSource) .withProcedureName("read_actor") From b3020bc484bc79865892b67952090b796277e2c4 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 29 Nov 2019 22:26:52 +0100 Subject: [PATCH 0142/2315] Allow ExchangeStrategies customizations in WebClient Prior to this commit, developers could configure their WebClient to use their custom `ExchangeStrategies`, by providing it in the `WebClient.Builder` chain. Once created, an `ExchangeStrategies` instance is not mutable, which makes it hard for further customizations by other components. In the case of the reported issue, other components would override the default configuration for the codecs maxInMemorySize. This commit makes the `ExchangeStrategies` mutable and uses that fact to further customize them with a new `WebClient.Builder#exchangeStrategies` `Consumer` variant. This commit is also deprecating those mutating variants in favor of a new `WebClient.Builder#exchangeStrategies` that takes a `ExchangeStrategies#Builder` directly and avoids mutation issues altogether. Closes gh-23961 --- .../messaging/rsocket/RSocketRequester.java | 15 ++--- .../server/DefaultWebTestClientBuilder.java | 15 ++++- .../web/reactive/server/WebTestClient.java | 30 ++++++++- .../http/codec/ClientCodecConfigurer.java | 7 ++- .../http/codec/CodecConfigurer.java | 6 ++ .../codec/support/BaseCodecConfigurer.java | 39 ++++++++++-- .../http/codec/support/BaseDefaultCodecs.java | 15 +++++ .../support/ClientDefaultCodecsImpl.java | 32 +++++++++- .../support/DefaultClientCodecConfigurer.java | 18 +++++- .../support/DefaultServerCodecConfigurer.java | 17 +++++- .../support/ServerDefaultCodecsImpl.java | 10 +++ .../codec/support/CodecConfigurerTests.java | 8 +++ .../DefaultExchangeStrategiesBuilder.java | 27 +++++--- .../client/DefaultWebClientBuilder.java | 40 ++++++++++-- .../function/client/ExchangeStrategies.java | 12 ++++ .../reactive/function/client/WebClient.java | 28 ++++++++- .../client/ExchangeStrategiesTests.java | 11 ++++ src/docs/asciidoc/web/webflux-webclient.adoc | 61 +++++++++++++++---- 18 files changed, 345 insertions(+), 46 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java index 320b45f3510b..3cccb6140802 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java @@ -169,18 +169,19 @@ interface Builder { RSocketRequester.Builder setupMetadata(Object value, @Nullable MimeType mimeType); /** - * Provide {@link RSocketStrategies} to use. - *

By default this is based on default settings of - * {@link RSocketStrategies.Builder} but may be further customized via - * {@link #rsocketStrategies(Consumer)}. + * Provide the {@link RSocketStrategies} to use. + *

This is useful for changing the default settings, yet still allowing + * further customizations via {@link #rsocketStrategies(Consumer)}. + * If not set, defaults are obtained from {@link RSocketStrategies#builder()}. + * @param strategies the strategies to use */ RSocketRequester.Builder rsocketStrategies(@Nullable RSocketStrategies strategies); /** * Customize the {@link RSocketStrategies}. - *

By default this starts out as {@link RSocketStrategies#builder()}. - * However if strategies were {@link #rsocketStrategies(RSocketStrategies) set} - * explicitly, then they are {@link RSocketStrategies#mutate() mutated}. + *

Allows further customization on {@link RSocketStrategies}, + * mutating them if they were {@link #rsocketStrategies(RSocketStrategies) set}, + * or starting from {@link RSocketStrategies#builder()} defaults}. */ RSocketRequester.Builder rsocketStrategies(Consumer configurer); diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java index f314b4455daf..4d5aeca17eb7 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -137,11 +137,24 @@ public WebTestClient.Builder filters(Consumer> filt } @Override + @Deprecated public WebTestClient.Builder exchangeStrategies(ExchangeStrategies strategies) { this.webClientBuilder.exchangeStrategies(strategies); return this; } + @Override + public WebTestClient.Builder exchangeStrategies(ExchangeStrategies.Builder strategies) { + this.webClientBuilder.exchangeStrategies(strategies); + return this; + } + + @Override + public WebTestClient.Builder exchangeStrategies(Consumer configurer) { + this.webClientBuilder.exchangeStrategies(configurer); + return this; + } + @Override public WebTestClient.Builder responseTimeout(Duration timeout) { this.responseTimeout = timeout; diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java index 7111b8d5284f..f7a0e78824d8 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java @@ -84,6 +84,7 @@ * perform integration tests on an embedded WebFlux server. * * @author Rossen Stoyanchev + * @author Brian Clozel * @since 5.0 * @see StatusAssertions * @see HeaderAssertions @@ -443,11 +444,34 @@ interface Builder { /** * Configure the {@link ExchangeStrategies} to use. - *

By default {@link ExchangeStrategies#withDefaults()} is used. + *

This is useful for changing the default settings, yet still allowing + * further customizations via {@link #exchangeStrategies(Consumer)}. + * By default {@link ExchangeStrategies#withDefaults()} is used. * @param strategies the strategies to use + * @deprecated as of 5.1 in favor of {@link #exchangeStrategies(ExchangeStrategies.Builder)} */ + @Deprecated Builder exchangeStrategies(ExchangeStrategies strategies); + /** + * Configure the {@link ExchangeStrategies.Builder} to use. + *

This is useful for changing the default settings, yet still allowing + * further customizations via {@link #exchangeStrategies(Consumer)}. + * By default {@link ExchangeStrategies#builder()} is used. + * @param strategies the strategies to use + * @since 5.1.12 + */ + Builder exchangeStrategies(ExchangeStrategies.Builder strategies); + + /** + * Customize the {@link ExchangeStrategies}. + *

Allows further customization on {@link ExchangeStrategies}, + * mutating them if they were {@link #exchangeStrategies(ExchangeStrategies) set}, + * or starting from {@link ExchangeStrategies#withDefaults() defaults}. + * @since 5.1.12 + */ + Builder exchangeStrategies(Consumer configurer); + /** * Max amount of time to wait for responses. *

By default 5 seconds. @@ -928,7 +952,7 @@ interface BodyContentSpec { * @since 5.1 * @see #xpath(String, Map, Object...) */ - default XpathAssertions xpath(String expression, Object... args){ + default XpathAssertions xpath(String expression, Object... args) { return xpath(expression, null, args); } @@ -942,7 +966,7 @@ default XpathAssertions xpath(String expression, Object... args){ * @param args arguments to parameterize the expression * @since 5.1 */ - XpathAssertions xpath(String expression, @Nullable Map namespaces, Object... args); + XpathAssertions xpath(String expression, @Nullable Map namespaces, Object... args); /** * Assert the response body content with the given {@link Consumer}. diff --git a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java index db31e97218a4..028d85af381b 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -63,6 +63,11 @@ public interface ClientCodecConfigurer extends CodecConfigurer { @Override ClientDefaultCodecs defaultCodecs(); + /** + * Clone this {@link ClientCodecConfigurer}. + */ + @Override + ClientCodecConfigurer clone(); /** * Static factory method for a {@code ClientCodecConfigurer}. diff --git a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java index 4e1ca8bd0132..55184522c533 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java @@ -87,6 +87,12 @@ public interface CodecConfigurer { */ List> getWriters(); + /** + * Clone this {@link CodecConfigurer}. + * @since 5.1.12 + */ + CodecConfigurer clone(); + /** * Customize or replace the HTTP message readers and writers registered by diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java index 3c6b367c22ac..6d7c61938849 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java @@ -34,13 +34,14 @@ * client and server specific variants. * * @author Rossen Stoyanchev + * @author Brian Clozel * @since 5.0 */ class BaseCodecConfigurer implements CodecConfigurer { - private final BaseDefaultCodecs defaultCodecs; + protected final BaseDefaultCodecs defaultCodecs; - private final DefaultCustomCodecs customCodecs = new DefaultCustomCodecs(); + protected final DefaultCustomCodecs customCodecs; /** @@ -50,6 +51,16 @@ class BaseCodecConfigurer implements CodecConfigurer { BaseCodecConfigurer(BaseDefaultCodecs defaultCodecs) { Assert.notNull(defaultCodecs, "'defaultCodecs' is required"); this.defaultCodecs = defaultCodecs; + this.customCodecs = new DefaultCustomCodecs(); + } + + /** + * Constructor with another {@link BaseCodecConfigurer} to copy + * the configuration from. + */ + BaseCodecConfigurer(BaseCodecConfigurer other) { + this.defaultCodecs = other.cloneDefaultCodecs(); + this.customCodecs = new DefaultCustomCodecs(other.customCodecs); } @@ -87,6 +98,17 @@ public List> getWriters() { return getWritersInternal(false); } + + @Override + public CodecConfigurer clone() { + return new BaseCodecConfigurer(this); + } + + protected BaseDefaultCodecs cloneDefaultCodecs() { + return new BaseDefaultCodecs(this.defaultCodecs); + } + + /** * Internal method that returns the configured writers. * @param forMultipart whether to returns writers for general use ("false"), @@ -110,7 +132,7 @@ protected List> getWritersInternal(boolean forMultipart) { /** * Default implementation of {@code CustomCodecs}. */ - private static final class DefaultCustomCodecs implements CustomCodecs { + protected static final class DefaultCustomCodecs implements CustomCodecs { private final List> typedReaders = new ArrayList<>(); @@ -121,6 +143,16 @@ private static final class DefaultCustomCodecs implements CustomCodecs { private final List> objectWriters = new ArrayList<>(); + DefaultCustomCodecs() { + } + + DefaultCustomCodecs(DefaultCustomCodecs other) { + other.typedReaders.addAll(this.typedReaders); + other.typedWriters.addAll(this.typedWriters); + other.objectReaders.addAll(this.objectReaders); + other.objectWriters.addAll(this.objectWriters); + } + @Override public void decoder(Decoder decoder) { reader(new DecoderHttpMessageReader<>(decoder)); @@ -143,7 +175,6 @@ public void writer(HttpMessageWriter writer) { (canWriteObject ? this.objectWriters : this.typedWriters).add(writer); } - // Package private accessors... List> getTypedReaders() { diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java index 39d76ad0ddbf..1020db44d90b 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java @@ -106,6 +106,21 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs { private boolean registerDefaults = true; + BaseDefaultCodecs() { + } + + protected BaseDefaultCodecs(BaseDefaultCodecs other) { + this.jackson2JsonDecoder = other.jackson2JsonDecoder; + this.jackson2JsonEncoder = other.jackson2JsonEncoder; + this.protobufDecoder = other.protobufDecoder; + this.protobufEncoder = other.protobufEncoder; + this.jaxb2Decoder = other.jaxb2Decoder; + this.jaxb2Encoder = other.jaxb2Encoder; + this.maxInMemorySize = other.maxInMemorySize; + this.enableLoggingRequestDetails = other.enableLoggingRequestDetails; + this.registerDefaults = other.registerDefaults; + } + @Override public void jackson2JsonDecoder(Decoder decoder) { this.jackson2JsonDecoder = decoder; diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java b/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java index 9f578b7320ab..e764cb969612 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -49,6 +49,17 @@ class ClientDefaultCodecsImpl extends BaseDefaultCodecs implements ClientCodecCo private Supplier>> partWritersSupplier; + ClientDefaultCodecsImpl() { + } + + ClientDefaultCodecsImpl(ClientDefaultCodecsImpl other) { + super(other); + this.multipartCodecs = new DefaultMultipartCodecs(other.multipartCodecs); + this.sseDecoder = other.sseDecoder; + this.partWritersSupplier = other.partWritersSupplier; + } + + /** * Set a supplier for part writers to use when * {@link #multipartCodecs()} are not explicitly configured. @@ -73,6 +84,14 @@ public void serverSentEventDecoder(Decoder decoder) { this.sseDecoder = decoder; } + @Override + public ClientDefaultCodecsImpl clone() { + ClientDefaultCodecsImpl codecs = new ClientDefaultCodecsImpl(); + codecs.multipartCodecs = this.multipartCodecs; + codecs.sseDecoder = this.sseDecoder; + codecs.partWritersSupplier = this.partWritersSupplier; + return codecs; + } @Override protected void extendObjectReaders(List> objectReaders) { @@ -116,6 +135,17 @@ private static class DefaultMultipartCodecs implements ClientCodecConfigurer.Mul private final List> writers = new ArrayList<>(); + + DefaultMultipartCodecs() { + } + + DefaultMultipartCodecs(@Nullable DefaultMultipartCodecs other) { + if (other != null) { + this.writers.addAll(other.writers); + } + } + + @Override public ClientCodecConfigurer.MultipartCodecs encoder(Encoder encoder) { writer(new EncoderHttpMessageWriter<>(encoder)); diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java index 9875ded1b98d..737282eecd5e 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -26,14 +26,30 @@ */ public class DefaultClientCodecConfigurer extends BaseCodecConfigurer implements ClientCodecConfigurer { + public DefaultClientCodecConfigurer() { super(new ClientDefaultCodecsImpl()); ((ClientDefaultCodecsImpl) defaultCodecs()).setPartWritersSupplier(() -> getWritersInternal(true)); } + private DefaultClientCodecConfigurer(DefaultClientCodecConfigurer other) { + super(other); + } + + @Override public ClientDefaultCodecs defaultCodecs() { return (ClientDefaultCodecs) super.defaultCodecs(); } + @Override + public DefaultClientCodecConfigurer clone() { + return new DefaultClientCodecConfigurer(this); + } + + @Override + protected BaseDefaultCodecs cloneDefaultCodecs() { + return new ClientDefaultCodecsImpl((ClientDefaultCodecsImpl) defaultCodecs()); + } + } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java index 2623d5a7f7b2..661d45d66693 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -26,13 +26,28 @@ */ public class DefaultServerCodecConfigurer extends BaseCodecConfigurer implements ServerCodecConfigurer { + public DefaultServerCodecConfigurer() { super(new ServerDefaultCodecsImpl()); } + private DefaultServerCodecConfigurer(BaseCodecConfigurer other) { + super(other); + } + + @Override public ServerDefaultCodecs defaultCodecs() { return (ServerDefaultCodecs) super.defaultCodecs(); } + @Override + public DefaultServerCodecConfigurer clone() { + return new DefaultServerCodecConfigurer(this); + } + + @Override + protected BaseDefaultCodecs cloneDefaultCodecs() { + return new ServerDefaultCodecsImpl((ServerDefaultCodecsImpl) defaultCodecs()); + } } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java b/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java index 37e924cd7e91..1d997c3777b1 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java @@ -46,6 +46,16 @@ class ServerDefaultCodecsImpl extends BaseDefaultCodecs implements ServerCodecCo private Encoder sseEncoder; + ServerDefaultCodecsImpl() { + } + + ServerDefaultCodecsImpl(ServerDefaultCodecsImpl other) { + super(other); + this.multipartReader = other.multipartReader; + this.sseEncoder = other.sseEncoder; + } + + @Override public void multipartReader(HttpMessageReader reader) { this.multipartReader = reader; diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java index 1a27f6400025..16164e24c518 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java @@ -268,6 +268,14 @@ public void encoderDecoderOverrides() { assertEncoderInstance(jaxb2Encoder); } + @Test + public void cloneConfigurer() { + CodecConfigurer clone = this.configurer.clone(); + this.configurer.registerDefaults(false); + assertThat(this.configurer.getReaders().size()).isEqualTo(0); + assertThat(clone.getReaders().size()).isEqualTo(11); + } + private Decoder getNextDecoder(List> readers) { HttpMessageReader reader = readers.get(this.index.getAndIncrement()); assertThat(reader.getClass()).isEqualTo(DecoderHttpMessageReader.class); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java index aa1523d9ace5..02b0cc5e5587 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -42,13 +42,18 @@ final class DefaultExchangeStrategiesBuilder implements ExchangeStrategies.Build } - private final ClientCodecConfigurer codecConfigurer = ClientCodecConfigurer.create(); + private final ClientCodecConfigurer codecConfigurer; public DefaultExchangeStrategiesBuilder() { + this.codecConfigurer = ClientCodecConfigurer.create(); this.codecConfigurer.registerDefaults(false); } + private DefaultExchangeStrategiesBuilder(DefaultExchangeStrategies other) { + this.codecConfigurer = other.codecConfigurer.clone(); + } + public void defaultConfiguration() { this.codecConfigurer.registerDefaults(true); @@ -62,21 +67,23 @@ public ExchangeStrategies.Builder codecs(Consumer consume @Override public ExchangeStrategies build() { - return new DefaultExchangeStrategies( - this.codecConfigurer.getReaders(), this.codecConfigurer.getWriters()); + return new DefaultExchangeStrategies(this.codecConfigurer); } private static class DefaultExchangeStrategies implements ExchangeStrategies { + private final ClientCodecConfigurer codecConfigurer; + private final List> readers; private final List> writers; - public DefaultExchangeStrategies(List> readers, List> writers) { - this.readers = unmodifiableCopy(readers); - this.writers = unmodifiableCopy(writers); + public DefaultExchangeStrategies(ClientCodecConfigurer codecConfigurer) { + this.codecConfigurer = codecConfigurer; + this.readers = unmodifiableCopy(this.codecConfigurer.getReaders()); + this.writers = unmodifiableCopy(this.codecConfigurer.getWriters()); } private static List unmodifiableCopy(List list) { @@ -84,6 +91,12 @@ private static List unmodifiableCopy(List list) { } + @Override + @Deprecated + public Builder mutate() { + return new DefaultExchangeStrategiesBuilder(this); + } + @Override public List> messageReaders() { return this.readers; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java index db699ddaae16..82b4c4940861 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java @@ -40,6 +40,7 @@ * Default implementation of {@link WebClient.Builder}. * * @author Rossen Stoyanchev + * @author Brian Clozel * @since 5.0 */ final class DefaultWebClientBuilder implements WebClient.Builder { @@ -79,14 +80,16 @@ final class DefaultWebClientBuilder implements WebClient.Builder { @Nullable private ClientHttpConnector connector; - private ExchangeStrategies exchangeStrategies; + @Nullable + private ExchangeStrategies.Builder strategies; + + private List> strategiesConfigurers; @Nullable private ExchangeFunction exchangeFunction; public DefaultWebClientBuilder() { - this.exchangeStrategies = ExchangeStrategies.withDefaults(); } public DefaultWebClientBuilder(DefaultWebClientBuilder other) { @@ -108,7 +111,7 @@ public DefaultWebClientBuilder(DefaultWebClientBuilder other) { this.defaultRequest = other.defaultRequest; this.filters = other.filters != null ? new ArrayList<>(other.filters) : null; this.connector = other.connector; - this.exchangeStrategies = other.exchangeStrategies; + this.strategies = other.strategies; this.exchangeFunction = other.exchangeFunction; } @@ -203,9 +206,23 @@ public WebClient.Builder clientConnector(ClientHttpConnector connector) { } @Override + @Deprecated public WebClient.Builder exchangeStrategies(ExchangeStrategies strategies) { Assert.notNull(strategies, "ExchangeStrategies must not be null"); - this.exchangeStrategies = strategies; + this.strategies = strategies.mutate(); + return this; + } + + @Override + public WebClient.Builder exchangeStrategies(ExchangeStrategies.Builder strategies) { + Assert.notNull(strategies, "ExchangeStrategies must not be null"); + this.strategies = strategies; + return this; + } + + @Override + public WebClient.Builder exchangeStrategies(Consumer configurer) { + this.strategiesConfigurers.add(configurer); return this; } @@ -229,7 +246,7 @@ public WebClient.Builder clone() { @Override public WebClient build() { ExchangeFunction exchange = (this.exchangeFunction == null ? - ExchangeFunctions.create(getOrInitConnector(), this.exchangeStrategies) : + ExchangeFunctions.create(getOrInitConnector(), initExchangeStrategies()) : this.exchangeFunction); ExchangeFunction filteredExchange = (this.filters != null ? this.filters.stream() .reduce(ExchangeFilterFunction::andThen) @@ -254,6 +271,19 @@ else if (jettyClientPresent) { throw new IllegalStateException("No suitable default ClientHttpConnector found"); } + @SuppressWarnings("deprecation") + private ExchangeStrategies initExchangeStrategies() { + if (CollectionUtils.isEmpty(this.strategiesConfigurers)) { + return this.strategies != null ? this.strategies.build() : ExchangeStrategies.withDefaults(); + } + + ExchangeStrategies.Builder builder = + this.strategies != null ? this.strategies : ExchangeStrategies.builder(); + + this.strategiesConfigurers.forEach(configurer -> configurer.accept(builder)); + return builder.build(); + } + private UriBuilderFactory initUriBuilderFactory() { if (this.uriBuilderFactory != null) { return this.uriBuilderFactory; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java index 804fbd9a42fd..dfc2e1e14d59 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java @@ -47,6 +47,18 @@ public interface ExchangeStrategies { */ List> messageWriters(); + /** + * Return a builder to create a new {@link ExchangeStrategies} instance + * replicated from the current instance. + * @since 5.1.12 + * @deprecated APIs should consume {@link ExchangeStrategies} as final or accept an + * {@link ExchangeStrategies.Builder builder}. + */ + @Deprecated + default Builder mutate() { + throw new UnsupportedOperationException("This ExchangeStrategies implementation does not support mutation."); + } + // Static builder methods diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java index 57fb6397242a..79fdc5a8c1e4 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java @@ -66,6 +66,7 @@ * @author Rossen Stoyanchev * @author Arjen Poutsma * @author Sebastien Deleuze + * @author Brian Clozel * @since 5.0 */ public interface WebClient { @@ -290,12 +291,35 @@ interface Builder { Builder clientConnector(ClientHttpConnector connector); /** - * Configure the {@link ExchangeStrategies} to use. - *

By default this is obtained from {@link ExchangeStrategies#withDefaults()}. + * Provide the {@link ExchangeStrategies} to use. + *

This is useful for changing the default settings, yet still allowing + * further customizations via {@link #exchangeStrategies(Consumer)}. + * If not set, defaults are obtained from {@link ExchangeStrategies#withDefaults()}. * @param strategies the strategies to use + * @deprecated as of 5.1, in favor of {@link #exchangeStrategies(ExchangeStrategies.Builder)} */ + @Deprecated Builder exchangeStrategies(ExchangeStrategies strategies); + /** + * Provide the {@link ExchangeStrategies.Builder} to use. + *

This is useful for changing the default settings, yet still allowing + * further customizations via {@link #exchangeStrategies(Consumer)}. + * If not set, defaults are obtained from {@link ExchangeStrategies#builder()}. + * @param strategies the strategies to use + * @since 5.1.12 + */ + Builder exchangeStrategies(ExchangeStrategies.Builder strategies); + + /** + * Customize the {@link ExchangeStrategies}. + *

Allows further customization on {@link ExchangeStrategies}, + * mutating them if they were {@link #exchangeStrategies(ExchangeStrategies) set}, + * or starting from {@link ExchangeStrategies#withDefaults() defaults}. + * @since 5.1.12 + */ + Builder exchangeStrategies(Consumer configurer); + /** * Provide an {@link ExchangeFunction} pre-configured with * {@link ClientHttpConnector} and {@link ExchangeStrategies}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java index eb37921f7a18..af0eeb0f2260 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java @@ -39,4 +39,15 @@ public void withDefaults() { assertThat(strategies.messageWriters().isEmpty()).isFalse(); } + @Test + @SuppressWarnings("deprecation") + public void mutate() { + ExchangeStrategies strategies = ExchangeStrategies.empty().build(); + assertThat(strategies.messageReaders().isEmpty()).isTrue(); + assertThat(strategies.messageWriters().isEmpty()).isTrue(); + ExchangeStrategies mutated = strategies.mutate().codecs(codecs -> codecs.registerDefaults(true)).build(); + assertThat(mutated.messageReaders().isEmpty()).isFalse(); + assertThat(mutated.messageWriters().isEmpty()).isFalse(); + } + } diff --git a/src/docs/asciidoc/web/webflux-webclient.adoc b/src/docs/asciidoc/web/webflux-webclient.adoc index 5ef50e1c1903..7963da0087d7 100644 --- a/src/docs/asciidoc/web/webflux-webclient.adoc +++ b/src/docs/asciidoc/web/webflux-webclient.adoc @@ -41,28 +41,26 @@ The following example configures < { - // ... - }) - .build(); + Consumer customizeCodecs = builder -> { + builder.codecs(configurer -> { + //... + }); + }; WebClient client = WebClient.builder() - .exchangeStrategies(strategies) + .exchangeStrategies(customizeCodecs) .build(); ---- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin ---- - val strategies = ExchangeStrategies.builder() - .codecs { - // ... + val webClient = WebClient.builder() + .exchangeStrategies { strategies -> + strategies.codecs { + //... + } } .build() - - val client = WebClient.builder() - .exchangeStrategies(strategies) - .build() ---- Once built, a `WebClient` instance is immutable. However, you can clone it and build a @@ -95,7 +93,44 @@ modified copy without affecting the original instance, as the following example // client2 has filterA, filterB, filterC, filterD ---- +[[webflux-client-builder-maxinmemorysize]] +=== MaxInMemorySize + +Spring WebFlux configures by default a maximum size for buffering data in-memory when decoding +HTTP responses with the `WebClient`. This avoids application memory issues if the received +response is much larger than expected. + +The default configured value of 256KB might not be enough for your use case, and your application +might hit that limit with the following: + +---- +org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer +---- + +You can configure this limit on all default codecs with the following code sample: +[source,java,indent=0,subs="verbatim,quotes",role="primary"] +.Java +---- + WebClient webClient = WebClient.builder() + .exchangeStrategies(configurer -> + configurer.codecs(codecs -> + codecs.defaultCodecs().maxInMemorySize(2 * 1024 * 1024) + ) + ) + .build(); +---- +[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] +.Kotlin +---- + val webClient = WebClient.builder() + .exchangeStrategies { strategies -> + strategies.codecs { + it.defaultCodecs().maxInMemorySize(2 * 1024 * 1024) + } + } + .build() +---- [[webflux-client-builder-reactor]] === Reactor Netty From 2267080ff48db4f448b62b04729d3d83de1d1e5e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 1 Dec 2019 00:14:16 +0100 Subject: [PATCH 0143/2315] Upgrade to Protobuf 3.11 and Apache Johnzon 1.2.2 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 8247e300a2ab..d9b3ebcfab11 100644 --- a/build.gradle +++ b/build.gradle @@ -84,13 +84,13 @@ configure(allprojects) { project -> exclude group: "stax", name: "stax-api" } dependency "com.google.code.gson:gson:2.8.6" - dependency "com.google.protobuf:protobuf-java-util:3.10.0" + dependency "com.google.protobuf:protobuf-java-util:3.11.0" dependency "com.googlecode.protobuf-java-format:protobuf-java-format:1.4" dependency("com.thoughtworks.xstream:xstream:1.4.11.1") { exclude group: "xpp3", name: "xpp3_min" exclude group: "xmlpull", name: "xmlpull" } - dependency "org.apache.johnzon:johnzon-jsonb:1.2.1" + dependency "org.apache.johnzon:johnzon-jsonb:1.2.2" dependency("org.codehaus.jettison:jettison:1.3.8") { exclude group: "stax", name: "stax-api" } From 567c7695dd9b99fe1145ed2ef123ca0d098d86fa Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 1 Dec 2019 00:20:00 +0100 Subject: [PATCH 0144/2315] Polishing --- .../messaging/converter/ProtobufMessageConverter.java | 8 ++++---- .../http/converter/FormHttpMessageConverter.java | 3 +-- .../function/client/DefaultExchangeStrategiesBuilder.java | 5 ++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java index 1d5dbf820c84..ed7c10fa62f3 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/ProtobufMessageConverter.java @@ -48,15 +48,15 @@ *

This converter supports by default {@code "application/x-protobuf"} with the official * {@code "com.google.protobuf:protobuf-java"} library. * - *

{@code "application/json"} can be supported with the official {@code "com.google.protobuf:protobuf-java-util"} 3.x - * with 3.3 or higher recommended + *

{@code "application/json"} can be supported with the official + * {@code "com.google.protobuf:protobuf-java-util"} 3.x, with 3.3 or higher recommended. * * @author Parviz Rozikov + * @author Rossen Stoyanchev * @since 5.2.2 */ public class ProtobufMessageConverter extends AbstractMessageConverter { - /** * The default charset used by the converter. */ @@ -187,7 +187,7 @@ else if (this.protobufFormatSupport != null) { } } catch (IOException ex) { - throw new MessageConversionException("Could not write proto message" + ex.getMessage(), ex); + throw new MessageConversionException("Failed to print Protobuf message: " + ex.getMessage(), ex); } return payload; diff --git a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java index 76496f583291..5c2594fe47ed 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java @@ -408,9 +408,8 @@ private void writeForm(MultiValueMap formData, @Nullable MediaTy * {@linkplain #setCharset(Charset) charset} if it does not have one. * If {@code contentType} is {@code null}, * {@code application/x-www-form-urlencoded; charset=UTF-8} is returned. - * *

Subclasses can override this method to change this behavior. - * @param contentType the preferred content type, can be {@code null} + * @param contentType the preferred content type (can be {@code null}) * @return the content type to be used * @since 5.2.2 */ diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java index 02b0cc5e5587..e39d4a59576a 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java @@ -29,6 +29,7 @@ * Default implementation of {@link ExchangeStrategies.Builder}. * * @author Arjen Poutsma + * @author Brian Clozel * @since 5.0 */ final class DefaultExchangeStrategiesBuilder implements ExchangeStrategies.Builder { @@ -79,7 +80,6 @@ private static class DefaultExchangeStrategies implements ExchangeStrategies { private final List> writers; - public DefaultExchangeStrategies(ClientCodecConfigurer codecConfigurer) { this.codecConfigurer = codecConfigurer; this.readers = unmodifiableCopy(this.codecConfigurer.getReaders()); @@ -90,9 +90,8 @@ private static List unmodifiableCopy(List list) { return Collections.unmodifiableList(new ArrayList<>(list)); } - - @Override @Deprecated + @Override public Builder mutate() { return new DefaultExchangeStrategiesBuilder(this); } From 91b557eb4be1803450ca6dbc808f1879f486876c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 1 Dec 2019 01:21:53 +0100 Subject: [PATCH 0145/2315] Polishing --- .../beans/ExtendedBeanInfo.java | 8 +-- .../groovy/GroovyBeanDefinitionReader.java | 58 ++++++++----------- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java index 3639949dbcbe..21ce57cf6add 100644 --- a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java +++ b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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 @@ /** * Decorator for a standard {@link BeanInfo} object, e.g. as created by - * {@link Introspector#getBeanInfo(Class)}, designed to discover and register static - * and/or non-void returning setter methods. For example: + * {@link Introspector#getBeanInfo(Class)}, designed to discover and register + * static and/or non-void returning setter methods. For example: * *

  * public class Bean {
@@ -487,7 +487,7 @@ public void setPropertyEditorClass(@Nullable Class propertyEditorClass) {
 		}
 
 		/*
-		 * See java.beans.IndexedPropertyDescriptor#equals(java.lang.Object)
+		 * See java.beans.IndexedPropertyDescriptor#equals
 		 */
 		@Override
 		public boolean equals(@Nullable Object other) {
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java
index c82964c23276..cf13a4081730 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java
@@ -232,7 +232,6 @@ public int loadBeanDefinitions(Resource resource) throws BeanDefinitionStoreExce
 	 * @return the number of bean definitions found
 	 * @throws BeanDefinitionStoreException in case of loading or parsing errors
 	 */
-	@SuppressWarnings("rawtypes")
 	public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
 		// Check for XML files and redirect them to the "standard" XmlBeanDefinitionReader
 		String filename = encodedResource.getResource().getFilename();
@@ -245,10 +244,10 @@ public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefin
 		}
 
 		@SuppressWarnings("serial")
-		Closure beans = new Closure(this) {
+		Closure beans = new Closure(this) {
 			@Override
 			public Object call(Object... args) {
-				invokeBeanDefiningClosure((Closure) args[0]);
+				invokeBeanDefiningClosure((Closure) args[0]);
 				return null;
 			}
 		};
@@ -290,8 +289,7 @@ public void setVariable(String name, Object value) {
 	 * @param closure the block or closure
 	 * @return this {@code GroovyBeanDefinitionReader} instance
 	 */
-	@SuppressWarnings("rawtypes")
-	public GroovyBeanDefinitionReader beans(Closure closure) {
+	public GroovyBeanDefinitionReader beans(Closure closure) {
 		return invokeBeanDefiningClosure(closure);
 	}
 
@@ -312,29 +310,25 @@ public GenericBeanDefinition bean(Class type) {
 	 * @param args the constructors arguments and closure configurer
 	 * @return the bean definition
 	 */
-	@SuppressWarnings("rawtypes")
 	public AbstractBeanDefinition bean(Class type, Object...args) {
 		GroovyBeanDefinitionWrapper current = this.currentBeanDefinition;
 		try {
-			Closure callable = null;
-			Collection constructorArgs = null;
+			Closure callable = null;
+			Collection constructorArgs = null;
 			if (!ObjectUtils.isEmpty(args)) {
 				int index = args.length;
 				Object lastArg = args[index - 1];
-				if (lastArg instanceof Closure) {
-					callable = (Closure) lastArg;
+				if (lastArg instanceof Closure) {
+					callable = (Closure) lastArg;
 					index--;
 				}
-				if (index > -1) {
-					constructorArgs = resolveConstructorArguments(args, 0, index);
-				}
+				constructorArgs = resolveConstructorArguments(args, 0, index);
 			}
 			this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(null, type, constructorArgs);
 			if (callable != null) {
 				callable.call(this.currentBeanDefinition);
 			}
 			return this.currentBeanDefinition.getBeanDefinition();
-
 		}
 		finally {
 			this.currentBeanDefinition = current;
@@ -381,11 +375,10 @@ public void importBeans(String resourcePattern) throws IOException {
 	 * takes a class argument.
 	 */
 	@Override
-	@SuppressWarnings("rawtypes")
 	public Object invokeMethod(String name, Object arg) {
 		Object[] args = (Object[])arg;
 		if ("beans".equals(name) && args.length == 1 && args[0] instanceof Closure) {
-			return beans((Closure) args[0]);
+			return beans((Closure) args[0]);
 		}
 		else if ("ref".equals(name)) {
 			String refName;
@@ -435,14 +428,13 @@ private boolean addDeferredProperty(String property, Object newValue) {
 		return false;
 	}
 
-	@SuppressWarnings("rawtypes")
 	private void finalizeDeferredProperties() {
 		for (DeferredProperty dp : this.deferredProperties.values()) {
 			if (dp.value instanceof List) {
-				dp.value = manageListIfNecessary((List) dp.value);
+				dp.value = manageListIfNecessary((List) dp.value);
 			}
 			else if (dp.value instanceof Map) {
-				dp.value = manageMapIfNecessary((Map) dp.value);
+				dp.value = manageMapIfNecessary((Map) dp.value);
 			}
 			dp.apply();
 		}
@@ -454,8 +446,7 @@ else if (dp.value instanceof Map) {
 	 * @param callable the closure argument
 	 * @return this {@code GroovyBeanDefinitionReader} instance
 	 */
-	@SuppressWarnings("rawtypes")
-	protected GroovyBeanDefinitionReader invokeBeanDefiningClosure(Closure callable) {
+	protected GroovyBeanDefinitionReader invokeBeanDefiningClosure(Closure callable) {
 		callable.setDelegate(this);
 		callable.call();
 		finalizeDeferredProperties();
@@ -469,7 +460,6 @@ protected GroovyBeanDefinitionReader invokeBeanDefiningClosure(Closure callable)
 	 * argument is sometimes a closure. All the arguments in between are constructor arguments.
 	 * @return the bean definition wrapper
 	 */
-	@SuppressWarnings("rawtypes")
 	private GroovyBeanDefinitionWrapper invokeBeanDefiningMethod(String beanName, Object[] args) {
 		boolean hasClosureArgument = (args[args.length - 1] instanceof Closure);
 		if (args[0] instanceof Class) {
@@ -495,9 +485,10 @@ else if (args[0] instanceof RuntimeBeanReference) {
 		else if (args[0] instanceof Map) {
 			// named constructor arguments
 			if (args.length > 1 && args[1] instanceof Class) {
-				List constructorArgs = resolveConstructorArguments(args, 2, hasClosureArgument ? args.length - 1 : args.length);
+				List constructorArgs =
+						resolveConstructorArguments(args, 2, hasClosureArgument ? args.length - 1 : args.length);
 				this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, (Class) args[1], constructorArgs);
-				Map namedArgs = (Map) args[0];
+				Map namedArgs = (Map) args[0];
 				for (Object o : namedArgs.keySet()) {
 					String propName = (String) o;
 					setProperty(propName, namedArgs.get(propName));
@@ -507,7 +498,7 @@ else if (args[0] instanceof Map) {
 			else {
 				this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName);
 				// First arg is the map containing factoryBean : factoryMethod
-				Map.Entry factoryBeanEntry = (Map.Entry) ((Map) args[0]).entrySet().iterator().next();
+				Map.Entry factoryBeanEntry = ((Map) args[0]).entrySet().iterator().next();
 				// If we have a closure body, that will be the last argument.
 				// In between are the constructor args
 				int constructorArgsTest = (hasClosureArgument ? 2 : 1);
@@ -531,12 +522,13 @@ else if (args[0] instanceof Closure) {
 			this.currentBeanDefinition.getBeanDefinition().setAbstract(true);
 		}
 		else {
-			List constructorArgs = resolveConstructorArguments(args, 0, hasClosureArgument ? args.length - 1 : args.length);
+			List constructorArgs =
+					resolveConstructorArguments(args, 0, hasClosureArgument ? args.length - 1 : args.length);
 			this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, null, constructorArgs);
 		}
 
 		if (hasClosureArgument) {
-			Closure callable = (Closure) args[args.length - 1];
+			Closure callable = (Closure) args[args.length - 1];
 			callable.setDelegate(this);
 			callable.setResolveStrategy(Closure.DELEGATE_FIRST);
 			callable.call(this.currentBeanDefinition);
@@ -549,7 +541,6 @@ else if (args[0] instanceof Closure) {
 		return beanDefinition;
 	}
 
-	@SuppressWarnings("rawtypes")
 	protected List resolveConstructorArguments(Object[] args, int start, int end) {
 		Object[] constructorArgs = Arrays.copyOfRange(args, start, end);
 		for (int i = 0; i < constructorArgs.length; i++) {
@@ -557,10 +548,10 @@ protected List resolveConstructorArguments(Object[] args, int start, int
 				constructorArgs[i] = constructorArgs[i].toString();
 			}
 			else if (constructorArgs[i] instanceof List) {
-				constructorArgs[i] = manageListIfNecessary((List) constructorArgs[i]);
+				constructorArgs[i] = manageListIfNecessary((List) constructorArgs[i]);
 			}
 			else if (constructorArgs[i] instanceof Map){
-				constructorArgs[i] = manageMapIfNecessary((Map) constructorArgs[i]);
+				constructorArgs[i] = manageMapIfNecessary((Map) constructorArgs[i]);
 			}
 		}
 		return Arrays.asList(constructorArgs);
@@ -621,7 +612,6 @@ public void setProperty(String name, Object value) {
 		}
 	}
 
-	@SuppressWarnings("rawtypes")
 	protected void applyPropertyToBeanDefinition(String name, Object value) {
 		if (value instanceof GString) {
 			value = value.toString();
@@ -632,7 +622,7 @@ protected void applyPropertyToBeanDefinition(String name, Object value) {
 		else if (value instanceof Closure) {
 			GroovyBeanDefinitionWrapper current = this.currentBeanDefinition;
 			try {
-				Closure callable = (Closure) value;
+				Closure callable = (Closure) value;
 				Class parameterType = callable.getParameterTypes()[0];
 				if (Object.class == parameterType) {
 					this.currentBeanDefinition = new GroovyBeanDefinitionWrapper("");
@@ -833,8 +823,8 @@ public boolean add(Object value) {
 				return retVal;
 			}
 
-			@SuppressWarnings({ "rawtypes", "unused" })
-			public boolean addAll(Collection values) {
+			@SuppressWarnings("unused")
+			public boolean addAll(Collection values) {
 				boolean retVal = (Boolean) InvokerHelper.invokeMethod(this.propertyValue, "addAll", values);
 				for (Object value : values) {
 					updateDeferredProperties(value);

From 32e7adfa32ca7fce00c7d89a61307c33310a0619 Mon Sep 17 00:00:00 2001
From: Juergen Hoeller 
Date: Sun, 1 Dec 2019 02:00:40 +0100
Subject: [PATCH 0146/2315] Polishing

---
 .../beans/factory/groovy/GroovyBeanDefinitionWrapper.java    | 5 ++---
 .../scheduling/quartz/LocalDataSourceJobStore.java           | 4 +---
 .../scheduling/quartz/ResourceLoaderClassLoadHelper.java     | 4 ++--
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java
index 6e702036314a..d1aeff7d0bcc 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -173,7 +173,6 @@ else if (dynamicProperties.contains(property)) {
 	}
 
 	@Override
-	@SuppressWarnings("rawtypes")
 	public void setProperty(String property, Object newValue) {
 		if (PARENT.equals(property)) {
 			setParent(newValue);
@@ -197,7 +196,7 @@ else if (Boolean.TRUE.equals(newValue)) {
 			// constructorArgs
 			else if (CONSTRUCTOR_ARGS.equals(property) && newValue instanceof List) {
 				ConstructorArgumentValues cav = new ConstructorArgumentValues();
-				List args = (List) newValue;
+				List args = (List) newValue;
 				for (Object arg : args) {
 					cav.addGenericArgumentValue(arg);
 				}
diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java
index d5e0af1779b4..d47fa28c0ea4 100644
--- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java
+++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -110,7 +110,6 @@ public Connection getConnection() throws SQLException {
 					public void shutdown() {
 						// Do nothing - a Spring-managed DataSource has its own lifecycle.
 					}
-					/* Quartz 2.2 initialize method */
 					@Override
 					public void initialize() {
 						// Do nothing - a Spring-managed DataSource has its own lifecycle.
@@ -139,7 +138,6 @@ public Connection getConnection() throws SQLException {
 					public void shutdown() {
 						// Do nothing - a Spring-managed DataSource has its own lifecycle.
 					}
-					/* Quartz 2.2 initialize method */
 					@Override
 					public void initialize() {
 						// Do nothing - a Spring-managed DataSource has its own lifecycle.
diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/ResourceLoaderClassLoadHelper.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/ResourceLoaderClassLoadHelper.java
index 1b274b79f316..996a598460d2 100644
--- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/ResourceLoaderClassLoadHelper.java
+++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/ResourceLoaderClassLoadHelper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -81,8 +81,8 @@ public Class loadClass(String name) throws ClassNotFoundException {
 		return ClassUtils.forName(name, this.resourceLoader.getClassLoader());
 	}
 
-	@Override
 	@SuppressWarnings("unchecked")
+	@Override
 	public  Class loadClass(String name, Class clazz) throws ClassNotFoundException {
 		return (Class) loadClass(name);
 	}

From 1548a0c9a07833b8afdcbc2af6b6a2f41c66ceb7 Mon Sep 17 00:00:00 2001
From: Juergen Hoeller 
Date: Mon, 2 Dec 2019 00:28:08 +0100
Subject: [PATCH 0147/2315] Upgrade to Mockito 3.2

---
 build.gradle | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build.gradle b/build.gradle
index d9b3ebcfab11..d1dd461cb9be 100644
--- a/build.gradle
+++ b/build.gradle
@@ -201,7 +201,7 @@ configure(allprojects) { project ->
 					exclude group: "org.hamcrest", name: "hamcrest-core"
 				}
 			}
-			dependencySet(group: 'org.mockito', version: '3.1.0') {
+			dependencySet(group: 'org.mockito', version: '3.2.0') {
 				entry('mockito-core') {
 					exclude group: "org.hamcrest", name: "hamcrest-core"
 				}

From 1560bbd81e9cfee6fff6e51cc7143cfcd8e6e3d9 Mon Sep 17 00:00:00 2001
From: Brian Clozel 
Date: Mon, 2 Dec 2019 10:39:53 +0100
Subject: [PATCH 0148/2315] Revert "Allow ExchangeStrategies customizations in
 WebClient"

This reverts commit b3020bc484bc79865892b67952090b796277e2c4.
---
 .../messaging/rsocket/RSocketRequester.java   | 15 +++--
 .../server/DefaultWebTestClientBuilder.java   | 15 +----
 .../web/reactive/server/WebTestClient.java    | 30 +--------
 .../http/codec/ClientCodecConfigurer.java     |  7 +--
 .../http/codec/CodecConfigurer.java           |  6 --
 .../codec/support/BaseCodecConfigurer.java    | 39 ++----------
 .../http/codec/support/BaseDefaultCodecs.java | 15 -----
 .../support/ClientDefaultCodecsImpl.java      | 32 +---------
 .../support/DefaultClientCodecConfigurer.java | 18 +-----
 .../support/DefaultServerCodecConfigurer.java | 17 +-----
 .../support/ServerDefaultCodecsImpl.java      | 10 ---
 .../codec/support/CodecConfigurerTests.java   |  8 ---
 .../DefaultExchangeStrategiesBuilder.java     | 22 ++-----
 .../client/DefaultWebClientBuilder.java       | 40 ++----------
 .../function/client/ExchangeStrategies.java   | 12 ----
 .../reactive/function/client/WebClient.java   | 28 +--------
 .../client/ExchangeStrategiesTests.java       | 11 ----
 src/docs/asciidoc/web/webflux-webclient.adoc  | 61 ++++---------------
 18 files changed, 43 insertions(+), 343 deletions(-)

diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java
index 3cccb6140802..320b45f3510b 100644
--- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java
+++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java
@@ -169,19 +169,18 @@ interface Builder {
 		RSocketRequester.Builder setupMetadata(Object value, @Nullable MimeType mimeType);
 
 		/**
-		 * Provide the {@link RSocketStrategies} to use.
-		 * 

This is useful for changing the default settings, yet still allowing - * further customizations via {@link #rsocketStrategies(Consumer)}. - * If not set, defaults are obtained from {@link RSocketStrategies#builder()}. - * @param strategies the strategies to use + * Provide {@link RSocketStrategies} to use. + *

By default this is based on default settings of + * {@link RSocketStrategies.Builder} but may be further customized via + * {@link #rsocketStrategies(Consumer)}. */ RSocketRequester.Builder rsocketStrategies(@Nullable RSocketStrategies strategies); /** * Customize the {@link RSocketStrategies}. - *

Allows further customization on {@link RSocketStrategies}, - * mutating them if they were {@link #rsocketStrategies(RSocketStrategies) set}, - * or starting from {@link RSocketStrategies#builder()} defaults}. + *

By default this starts out as {@link RSocketStrategies#builder()}. + * However if strategies were {@link #rsocketStrategies(RSocketStrategies) set} + * explicitly, then they are {@link RSocketStrategies#mutate() mutated}. */ RSocketRequester.Builder rsocketStrategies(Consumer configurer); diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java index 4d5aeca17eb7..f314b4455daf 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2018 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. @@ -137,24 +137,11 @@ public WebTestClient.Builder filters(Consumer> filt } @Override - @Deprecated public WebTestClient.Builder exchangeStrategies(ExchangeStrategies strategies) { this.webClientBuilder.exchangeStrategies(strategies); return this; } - @Override - public WebTestClient.Builder exchangeStrategies(ExchangeStrategies.Builder strategies) { - this.webClientBuilder.exchangeStrategies(strategies); - return this; - } - - @Override - public WebTestClient.Builder exchangeStrategies(Consumer configurer) { - this.webClientBuilder.exchangeStrategies(configurer); - return this; - } - @Override public WebTestClient.Builder responseTimeout(Duration timeout) { this.responseTimeout = timeout; diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java index f7a0e78824d8..7111b8d5284f 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java @@ -84,7 +84,6 @@ * perform integration tests on an embedded WebFlux server. * * @author Rossen Stoyanchev - * @author Brian Clozel * @since 5.0 * @see StatusAssertions * @see HeaderAssertions @@ -444,34 +443,11 @@ interface Builder { /** * Configure the {@link ExchangeStrategies} to use. - *

This is useful for changing the default settings, yet still allowing - * further customizations via {@link #exchangeStrategies(Consumer)}. - * By default {@link ExchangeStrategies#withDefaults()} is used. + *

By default {@link ExchangeStrategies#withDefaults()} is used. * @param strategies the strategies to use - * @deprecated as of 5.1 in favor of {@link #exchangeStrategies(ExchangeStrategies.Builder)} */ - @Deprecated Builder exchangeStrategies(ExchangeStrategies strategies); - /** - * Configure the {@link ExchangeStrategies.Builder} to use. - *

This is useful for changing the default settings, yet still allowing - * further customizations via {@link #exchangeStrategies(Consumer)}. - * By default {@link ExchangeStrategies#builder()} is used. - * @param strategies the strategies to use - * @since 5.1.12 - */ - Builder exchangeStrategies(ExchangeStrategies.Builder strategies); - - /** - * Customize the {@link ExchangeStrategies}. - *

Allows further customization on {@link ExchangeStrategies}, - * mutating them if they were {@link #exchangeStrategies(ExchangeStrategies) set}, - * or starting from {@link ExchangeStrategies#withDefaults() defaults}. - * @since 5.1.12 - */ - Builder exchangeStrategies(Consumer configurer); - /** * Max amount of time to wait for responses. *

By default 5 seconds. @@ -952,7 +928,7 @@ interface BodyContentSpec { * @since 5.1 * @see #xpath(String, Map, Object...) */ - default XpathAssertions xpath(String expression, Object... args) { + default XpathAssertions xpath(String expression, Object... args){ return xpath(expression, null, args); } @@ -966,7 +942,7 @@ default XpathAssertions xpath(String expression, Object... args) { * @param args arguments to parameterize the expression * @since 5.1 */ - XpathAssertions xpath(String expression, @Nullable Map namespaces, Object... args); + XpathAssertions xpath(String expression, @Nullable Map namespaces, Object... args); /** * Assert the response body content with the given {@link Consumer}. diff --git a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java index 028d85af381b..db31e97218a4 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2018 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. @@ -63,11 +63,6 @@ public interface ClientCodecConfigurer extends CodecConfigurer { @Override ClientDefaultCodecs defaultCodecs(); - /** - * Clone this {@link ClientCodecConfigurer}. - */ - @Override - ClientCodecConfigurer clone(); /** * Static factory method for a {@code ClientCodecConfigurer}. diff --git a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java index 55184522c533..4e1ca8bd0132 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java @@ -87,12 +87,6 @@ public interface CodecConfigurer { */ List> getWriters(); - /** - * Clone this {@link CodecConfigurer}. - * @since 5.1.12 - */ - CodecConfigurer clone(); - /** * Customize or replace the HTTP message readers and writers registered by diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java index 6d7c61938849..3c6b367c22ac 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java @@ -34,14 +34,13 @@ * client and server specific variants. * * @author Rossen Stoyanchev - * @author Brian Clozel * @since 5.0 */ class BaseCodecConfigurer implements CodecConfigurer { - protected final BaseDefaultCodecs defaultCodecs; + private final BaseDefaultCodecs defaultCodecs; - protected final DefaultCustomCodecs customCodecs; + private final DefaultCustomCodecs customCodecs = new DefaultCustomCodecs(); /** @@ -51,16 +50,6 @@ class BaseCodecConfigurer implements CodecConfigurer { BaseCodecConfigurer(BaseDefaultCodecs defaultCodecs) { Assert.notNull(defaultCodecs, "'defaultCodecs' is required"); this.defaultCodecs = defaultCodecs; - this.customCodecs = new DefaultCustomCodecs(); - } - - /** - * Constructor with another {@link BaseCodecConfigurer} to copy - * the configuration from. - */ - BaseCodecConfigurer(BaseCodecConfigurer other) { - this.defaultCodecs = other.cloneDefaultCodecs(); - this.customCodecs = new DefaultCustomCodecs(other.customCodecs); } @@ -98,17 +87,6 @@ public List> getWriters() { return getWritersInternal(false); } - - @Override - public CodecConfigurer clone() { - return new BaseCodecConfigurer(this); - } - - protected BaseDefaultCodecs cloneDefaultCodecs() { - return new BaseDefaultCodecs(this.defaultCodecs); - } - - /** * Internal method that returns the configured writers. * @param forMultipart whether to returns writers for general use ("false"), @@ -132,7 +110,7 @@ protected List> getWritersInternal(boolean forMultipart) { /** * Default implementation of {@code CustomCodecs}. */ - protected static final class DefaultCustomCodecs implements CustomCodecs { + private static final class DefaultCustomCodecs implements CustomCodecs { private final List> typedReaders = new ArrayList<>(); @@ -143,16 +121,6 @@ protected static final class DefaultCustomCodecs implements CustomCodecs { private final List> objectWriters = new ArrayList<>(); - DefaultCustomCodecs() { - } - - DefaultCustomCodecs(DefaultCustomCodecs other) { - other.typedReaders.addAll(this.typedReaders); - other.typedWriters.addAll(this.typedWriters); - other.objectReaders.addAll(this.objectReaders); - other.objectWriters.addAll(this.objectWriters); - } - @Override public void decoder(Decoder decoder) { reader(new DecoderHttpMessageReader<>(decoder)); @@ -175,6 +143,7 @@ public void writer(HttpMessageWriter writer) { (canWriteObject ? this.objectWriters : this.typedWriters).add(writer); } + // Package private accessors... List> getTypedReaders() { diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java index 1020db44d90b..39d76ad0ddbf 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java @@ -106,21 +106,6 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs { private boolean registerDefaults = true; - BaseDefaultCodecs() { - } - - protected BaseDefaultCodecs(BaseDefaultCodecs other) { - this.jackson2JsonDecoder = other.jackson2JsonDecoder; - this.jackson2JsonEncoder = other.jackson2JsonEncoder; - this.protobufDecoder = other.protobufDecoder; - this.protobufEncoder = other.protobufEncoder; - this.jaxb2Decoder = other.jaxb2Decoder; - this.jaxb2Encoder = other.jaxb2Encoder; - this.maxInMemorySize = other.maxInMemorySize; - this.enableLoggingRequestDetails = other.enableLoggingRequestDetails; - this.registerDefaults = other.registerDefaults; - } - @Override public void jackson2JsonDecoder(Decoder decoder) { this.jackson2JsonDecoder = decoder; diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java b/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java index e764cb969612..9f578b7320ab 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2018 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. @@ -49,17 +49,6 @@ class ClientDefaultCodecsImpl extends BaseDefaultCodecs implements ClientCodecCo private Supplier>> partWritersSupplier; - ClientDefaultCodecsImpl() { - } - - ClientDefaultCodecsImpl(ClientDefaultCodecsImpl other) { - super(other); - this.multipartCodecs = new DefaultMultipartCodecs(other.multipartCodecs); - this.sseDecoder = other.sseDecoder; - this.partWritersSupplier = other.partWritersSupplier; - } - - /** * Set a supplier for part writers to use when * {@link #multipartCodecs()} are not explicitly configured. @@ -84,14 +73,6 @@ public void serverSentEventDecoder(Decoder decoder) { this.sseDecoder = decoder; } - @Override - public ClientDefaultCodecsImpl clone() { - ClientDefaultCodecsImpl codecs = new ClientDefaultCodecsImpl(); - codecs.multipartCodecs = this.multipartCodecs; - codecs.sseDecoder = this.sseDecoder; - codecs.partWritersSupplier = this.partWritersSupplier; - return codecs; - } @Override protected void extendObjectReaders(List> objectReaders) { @@ -135,17 +116,6 @@ private static class DefaultMultipartCodecs implements ClientCodecConfigurer.Mul private final List> writers = new ArrayList<>(); - - DefaultMultipartCodecs() { - } - - DefaultMultipartCodecs(@Nullable DefaultMultipartCodecs other) { - if (other != null) { - this.writers.addAll(other.writers); - } - } - - @Override public ClientCodecConfigurer.MultipartCodecs encoder(Encoder encoder) { writer(new EncoderHttpMessageWriter<>(encoder)); diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java index 737282eecd5e..9875ded1b98d 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2018 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. @@ -26,30 +26,14 @@ */ public class DefaultClientCodecConfigurer extends BaseCodecConfigurer implements ClientCodecConfigurer { - public DefaultClientCodecConfigurer() { super(new ClientDefaultCodecsImpl()); ((ClientDefaultCodecsImpl) defaultCodecs()).setPartWritersSupplier(() -> getWritersInternal(true)); } - private DefaultClientCodecConfigurer(DefaultClientCodecConfigurer other) { - super(other); - } - - @Override public ClientDefaultCodecs defaultCodecs() { return (ClientDefaultCodecs) super.defaultCodecs(); } - @Override - public DefaultClientCodecConfigurer clone() { - return new DefaultClientCodecConfigurer(this); - } - - @Override - protected BaseDefaultCodecs cloneDefaultCodecs() { - return new ClientDefaultCodecsImpl((ClientDefaultCodecsImpl) defaultCodecs()); - } - } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java index 661d45d66693..2623d5a7f7b2 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2018 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. @@ -26,28 +26,13 @@ */ public class DefaultServerCodecConfigurer extends BaseCodecConfigurer implements ServerCodecConfigurer { - public DefaultServerCodecConfigurer() { super(new ServerDefaultCodecsImpl()); } - private DefaultServerCodecConfigurer(BaseCodecConfigurer other) { - super(other); - } - - @Override public ServerDefaultCodecs defaultCodecs() { return (ServerDefaultCodecs) super.defaultCodecs(); } - @Override - public DefaultServerCodecConfigurer clone() { - return new DefaultServerCodecConfigurer(this); - } - - @Override - protected BaseDefaultCodecs cloneDefaultCodecs() { - return new ServerDefaultCodecsImpl((ServerDefaultCodecsImpl) defaultCodecs()); - } } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java b/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java index 1d997c3777b1..37e924cd7e91 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java @@ -46,16 +46,6 @@ class ServerDefaultCodecsImpl extends BaseDefaultCodecs implements ServerCodecCo private Encoder sseEncoder; - ServerDefaultCodecsImpl() { - } - - ServerDefaultCodecsImpl(ServerDefaultCodecsImpl other) { - super(other); - this.multipartReader = other.multipartReader; - this.sseEncoder = other.sseEncoder; - } - - @Override public void multipartReader(HttpMessageReader reader) { this.multipartReader = reader; diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java index 16164e24c518..1a27f6400025 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java @@ -268,14 +268,6 @@ public void encoderDecoderOverrides() { assertEncoderInstance(jaxb2Encoder); } - @Test - public void cloneConfigurer() { - CodecConfigurer clone = this.configurer.clone(); - this.configurer.registerDefaults(false); - assertThat(this.configurer.getReaders().size()).isEqualTo(0); - assertThat(clone.getReaders().size()).isEqualTo(11); - } - private Decoder getNextDecoder(List> readers) { HttpMessageReader reader = readers.get(this.index.getAndIncrement()); assertThat(reader.getClass()).isEqualTo(DecoderHttpMessageReader.class); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java index e39d4a59576a..1b2d2edcc2bd 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2018 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. @@ -43,18 +43,13 @@ final class DefaultExchangeStrategiesBuilder implements ExchangeStrategies.Build } - private final ClientCodecConfigurer codecConfigurer; + private final ClientCodecConfigurer codecConfigurer = ClientCodecConfigurer.create(); public DefaultExchangeStrategiesBuilder() { - this.codecConfigurer = ClientCodecConfigurer.create(); this.codecConfigurer.registerDefaults(false); } - private DefaultExchangeStrategiesBuilder(DefaultExchangeStrategies other) { - this.codecConfigurer = other.codecConfigurer.clone(); - } - public void defaultConfiguration() { this.codecConfigurer.registerDefaults(true); @@ -74,28 +69,19 @@ public ExchangeStrategies build() { private static class DefaultExchangeStrategies implements ExchangeStrategies { - private final ClientCodecConfigurer codecConfigurer; - private final List> readers; private final List> writers; public DefaultExchangeStrategies(ClientCodecConfigurer codecConfigurer) { - this.codecConfigurer = codecConfigurer; - this.readers = unmodifiableCopy(this.codecConfigurer.getReaders()); - this.writers = unmodifiableCopy(this.codecConfigurer.getWriters()); + this.readers = unmodifiableCopy(codecConfigurer.getReaders()); + this.writers = unmodifiableCopy(codecConfigurer.getWriters()); } private static List unmodifiableCopy(List list) { return Collections.unmodifiableList(new ArrayList<>(list)); } - @Deprecated - @Override - public Builder mutate() { - return new DefaultExchangeStrategiesBuilder(this); - } - @Override public List> messageReaders() { return this.readers; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java index 82b4c4940861..db699ddaae16 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java @@ -40,7 +40,6 @@ * Default implementation of {@link WebClient.Builder}. * * @author Rossen Stoyanchev - * @author Brian Clozel * @since 5.0 */ final class DefaultWebClientBuilder implements WebClient.Builder { @@ -80,16 +79,14 @@ final class DefaultWebClientBuilder implements WebClient.Builder { @Nullable private ClientHttpConnector connector; - @Nullable - private ExchangeStrategies.Builder strategies; - - private List> strategiesConfigurers; + private ExchangeStrategies exchangeStrategies; @Nullable private ExchangeFunction exchangeFunction; public DefaultWebClientBuilder() { + this.exchangeStrategies = ExchangeStrategies.withDefaults(); } public DefaultWebClientBuilder(DefaultWebClientBuilder other) { @@ -111,7 +108,7 @@ public DefaultWebClientBuilder(DefaultWebClientBuilder other) { this.defaultRequest = other.defaultRequest; this.filters = other.filters != null ? new ArrayList<>(other.filters) : null; this.connector = other.connector; - this.strategies = other.strategies; + this.exchangeStrategies = other.exchangeStrategies; this.exchangeFunction = other.exchangeFunction; } @@ -206,23 +203,9 @@ public WebClient.Builder clientConnector(ClientHttpConnector connector) { } @Override - @Deprecated public WebClient.Builder exchangeStrategies(ExchangeStrategies strategies) { Assert.notNull(strategies, "ExchangeStrategies must not be null"); - this.strategies = strategies.mutate(); - return this; - } - - @Override - public WebClient.Builder exchangeStrategies(ExchangeStrategies.Builder strategies) { - Assert.notNull(strategies, "ExchangeStrategies must not be null"); - this.strategies = strategies; - return this; - } - - @Override - public WebClient.Builder exchangeStrategies(Consumer configurer) { - this.strategiesConfigurers.add(configurer); + this.exchangeStrategies = strategies; return this; } @@ -246,7 +229,7 @@ public WebClient.Builder clone() { @Override public WebClient build() { ExchangeFunction exchange = (this.exchangeFunction == null ? - ExchangeFunctions.create(getOrInitConnector(), initExchangeStrategies()) : + ExchangeFunctions.create(getOrInitConnector(), this.exchangeStrategies) : this.exchangeFunction); ExchangeFunction filteredExchange = (this.filters != null ? this.filters.stream() .reduce(ExchangeFilterFunction::andThen) @@ -271,19 +254,6 @@ else if (jettyClientPresent) { throw new IllegalStateException("No suitable default ClientHttpConnector found"); } - @SuppressWarnings("deprecation") - private ExchangeStrategies initExchangeStrategies() { - if (CollectionUtils.isEmpty(this.strategiesConfigurers)) { - return this.strategies != null ? this.strategies.build() : ExchangeStrategies.withDefaults(); - } - - ExchangeStrategies.Builder builder = - this.strategies != null ? this.strategies : ExchangeStrategies.builder(); - - this.strategiesConfigurers.forEach(configurer -> configurer.accept(builder)); - return builder.build(); - } - private UriBuilderFactory initUriBuilderFactory() { if (this.uriBuilderFactory != null) { return this.uriBuilderFactory; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java index dfc2e1e14d59..804fbd9a42fd 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java @@ -47,18 +47,6 @@ public interface ExchangeStrategies { */ List> messageWriters(); - /** - * Return a builder to create a new {@link ExchangeStrategies} instance - * replicated from the current instance. - * @since 5.1.12 - * @deprecated APIs should consume {@link ExchangeStrategies} as final or accept an - * {@link ExchangeStrategies.Builder builder}. - */ - @Deprecated - default Builder mutate() { - throw new UnsupportedOperationException("This ExchangeStrategies implementation does not support mutation."); - } - // Static builder methods diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java index 79fdc5a8c1e4..57fb6397242a 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java @@ -66,7 +66,6 @@ * @author Rossen Stoyanchev * @author Arjen Poutsma * @author Sebastien Deleuze - * @author Brian Clozel * @since 5.0 */ public interface WebClient { @@ -291,35 +290,12 @@ interface Builder { Builder clientConnector(ClientHttpConnector connector); /** - * Provide the {@link ExchangeStrategies} to use. - *

This is useful for changing the default settings, yet still allowing - * further customizations via {@link #exchangeStrategies(Consumer)}. - * If not set, defaults are obtained from {@link ExchangeStrategies#withDefaults()}. + * Configure the {@link ExchangeStrategies} to use. + *

By default this is obtained from {@link ExchangeStrategies#withDefaults()}. * @param strategies the strategies to use - * @deprecated as of 5.1, in favor of {@link #exchangeStrategies(ExchangeStrategies.Builder)} */ - @Deprecated Builder exchangeStrategies(ExchangeStrategies strategies); - /** - * Provide the {@link ExchangeStrategies.Builder} to use. - *

This is useful for changing the default settings, yet still allowing - * further customizations via {@link #exchangeStrategies(Consumer)}. - * If not set, defaults are obtained from {@link ExchangeStrategies#builder()}. - * @param strategies the strategies to use - * @since 5.1.12 - */ - Builder exchangeStrategies(ExchangeStrategies.Builder strategies); - - /** - * Customize the {@link ExchangeStrategies}. - *

Allows further customization on {@link ExchangeStrategies}, - * mutating them if they were {@link #exchangeStrategies(ExchangeStrategies) set}, - * or starting from {@link ExchangeStrategies#withDefaults() defaults}. - * @since 5.1.12 - */ - Builder exchangeStrategies(Consumer configurer); - /** * Provide an {@link ExchangeFunction} pre-configured with * {@link ClientHttpConnector} and {@link ExchangeStrategies}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java index af0eeb0f2260..eb37921f7a18 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java @@ -39,15 +39,4 @@ public void withDefaults() { assertThat(strategies.messageWriters().isEmpty()).isFalse(); } - @Test - @SuppressWarnings("deprecation") - public void mutate() { - ExchangeStrategies strategies = ExchangeStrategies.empty().build(); - assertThat(strategies.messageReaders().isEmpty()).isTrue(); - assertThat(strategies.messageWriters().isEmpty()).isTrue(); - ExchangeStrategies mutated = strategies.mutate().codecs(codecs -> codecs.registerDefaults(true)).build(); - assertThat(mutated.messageReaders().isEmpty()).isFalse(); - assertThat(mutated.messageWriters().isEmpty()).isFalse(); - } - } diff --git a/src/docs/asciidoc/web/webflux-webclient.adoc b/src/docs/asciidoc/web/webflux-webclient.adoc index 7963da0087d7..5ef50e1c1903 100644 --- a/src/docs/asciidoc/web/webflux-webclient.adoc +++ b/src/docs/asciidoc/web/webflux-webclient.adoc @@ -41,26 +41,28 @@ The following example configures < customizeCodecs = builder -> { - builder.codecs(configurer -> { - //... - }); - }; + ExchangeStrategies strategies = ExchangeStrategies.builder() + .codecs(configurer -> { + // ... + }) + .build(); WebClient client = WebClient.builder() - .exchangeStrategies(customizeCodecs) + .exchangeStrategies(strategies) .build(); ---- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin ---- - val webClient = WebClient.builder() - .exchangeStrategies { strategies -> - strategies.codecs { - //... - } + val strategies = ExchangeStrategies.builder() + .codecs { + // ... } .build() + + val client = WebClient.builder() + .exchangeStrategies(strategies) + .build() ---- Once built, a `WebClient` instance is immutable. However, you can clone it and build a @@ -93,44 +95,7 @@ modified copy without affecting the original instance, as the following example // client2 has filterA, filterB, filterC, filterD ---- -[[webflux-client-builder-maxinmemorysize]] -=== MaxInMemorySize - -Spring WebFlux configures by default a maximum size for buffering data in-memory when decoding -HTTP responses with the `WebClient`. This avoids application memory issues if the received -response is much larger than expected. - -The default configured value of 256KB might not be enough for your use case, and your application -might hit that limit with the following: - ----- -org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer ----- - -You can configure this limit on all default codecs with the following code sample: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java ----- - WebClient webClient = WebClient.builder() - .exchangeStrategies(configurer -> - configurer.codecs(codecs -> - codecs.defaultCodecs().maxInMemorySize(2 * 1024 * 1024) - ) - ) - .build(); ----- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - val webClient = WebClient.builder() - .exchangeStrategies { strategies -> - strategies.codecs { - it.defaultCodecs().maxInMemorySize(2 * 1024 * 1024) - } - } - .build() ----- [[webflux-client-builder-reactor]] === Reactor Netty From 17e2a0c7ea51c448a5bcb7aaa80034682a498b56 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 2 Dec 2019 12:59:02 +0100 Subject: [PATCH 0149/2315] Upgrade to AspectJ 1.9.5 and Checkstyle 8.27 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index d1dd461cb9be..8d7911daa626 100644 --- a/build.gradle +++ b/build.gradle @@ -61,7 +61,7 @@ configure(allprojects) { project -> dependency "com.google.code.findbugs:jsr305:3.0.2" - dependencySet(group: 'org.aspectj', version: '1.9.4') { + dependencySet(group: 'org.aspectj', version: '1.9.5') { entry 'aspectjrt' entry 'aspectjtools' entry 'aspectjweaver' @@ -338,7 +338,7 @@ configure([rootProject] + javaProjects) { project -> } checkstyle { - toolVersion = "8.26" + toolVersion = "8.27" configDir = rootProject.file("src/checkstyle") } From d4209392d27d23c568f9f5b458fc4bdc62005124 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 29 Nov 2019 22:26:52 +0100 Subject: [PATCH 0150/2315] Allow ExchangeStrategies customizations in WebClient Prior to this commit, developers could configure their WebClient to use their custom `ExchangeStrategies`, by providing it in the `WebClient.Builder` chain. Once created, an `ExchangeStrategies` instance is not mutable, which makes it hard for further customizations by other components. In the case of the reported issue, other components would override the default configuration for the codecs maxInMemorySize. This commit makes the `ExchangeStrategies` mutable and uses that fact to further customize them with a new `WebClient.Builder#exchangeStrategies` `Consumer` variant. This commit is also deprecating those mutating variants in favor of a new `WebClient.Builder#exchangeStrategies` that takes a `ExchangeStrategies#Builder` directly and avoids mutation issues altogether. Closes gh-23961 --- .../messaging/rsocket/RSocketRequester.java | 15 ++--- .../server/DefaultWebTestClientBuilder.java | 15 ++++- .../web/reactive/server/WebTestClient.java | 30 ++++++++- .../http/codec/ClientCodecConfigurer.java | 7 ++- .../http/codec/CodecConfigurer.java | 6 ++ .../codec/support/BaseCodecConfigurer.java | 39 ++++++++++-- .../http/codec/support/BaseDefaultCodecs.java | 15 +++++ .../support/ClientDefaultCodecsImpl.java | 32 +++++++++- .../support/DefaultClientCodecConfigurer.java | 18 +++++- .../support/DefaultServerCodecConfigurer.java | 17 +++++- .../support/ServerDefaultCodecsImpl.java | 10 +++ .../codec/support/CodecConfigurerTests.java | 8 +++ .../DefaultExchangeStrategiesBuilder.java | 23 +++++-- .../client/DefaultWebClientBuilder.java | 40 ++++++++++-- .../function/client/ExchangeStrategies.java | 12 ++++ .../reactive/function/client/WebClient.java | 28 ++++++++- .../client/ExchangeStrategiesTests.java | 11 ++++ src/docs/asciidoc/web/webflux-webclient.adoc | 61 +++++++++++++++---- 18 files changed, 344 insertions(+), 43 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java index 320b45f3510b..3cccb6140802 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java @@ -169,18 +169,19 @@ interface Builder { RSocketRequester.Builder setupMetadata(Object value, @Nullable MimeType mimeType); /** - * Provide {@link RSocketStrategies} to use. - *

By default this is based on default settings of - * {@link RSocketStrategies.Builder} but may be further customized via - * {@link #rsocketStrategies(Consumer)}. + * Provide the {@link RSocketStrategies} to use. + *

This is useful for changing the default settings, yet still allowing + * further customizations via {@link #rsocketStrategies(Consumer)}. + * If not set, defaults are obtained from {@link RSocketStrategies#builder()}. + * @param strategies the strategies to use */ RSocketRequester.Builder rsocketStrategies(@Nullable RSocketStrategies strategies); /** * Customize the {@link RSocketStrategies}. - *

By default this starts out as {@link RSocketStrategies#builder()}. - * However if strategies were {@link #rsocketStrategies(RSocketStrategies) set} - * explicitly, then they are {@link RSocketStrategies#mutate() mutated}. + *

Allows further customization on {@link RSocketStrategies}, + * mutating them if they were {@link #rsocketStrategies(RSocketStrategies) set}, + * or starting from {@link RSocketStrategies#builder()} defaults}. */ RSocketRequester.Builder rsocketStrategies(Consumer configurer); diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java index f314b4455daf..4d5aeca17eb7 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -137,11 +137,24 @@ public WebTestClient.Builder filters(Consumer> filt } @Override + @Deprecated public WebTestClient.Builder exchangeStrategies(ExchangeStrategies strategies) { this.webClientBuilder.exchangeStrategies(strategies); return this; } + @Override + public WebTestClient.Builder exchangeStrategies(ExchangeStrategies.Builder strategies) { + this.webClientBuilder.exchangeStrategies(strategies); + return this; + } + + @Override + public WebTestClient.Builder exchangeStrategies(Consumer configurer) { + this.webClientBuilder.exchangeStrategies(configurer); + return this; + } + @Override public WebTestClient.Builder responseTimeout(Duration timeout) { this.responseTimeout = timeout; diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java index 7111b8d5284f..f7a0e78824d8 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java @@ -84,6 +84,7 @@ * perform integration tests on an embedded WebFlux server. * * @author Rossen Stoyanchev + * @author Brian Clozel * @since 5.0 * @see StatusAssertions * @see HeaderAssertions @@ -443,11 +444,34 @@ interface Builder { /** * Configure the {@link ExchangeStrategies} to use. - *

By default {@link ExchangeStrategies#withDefaults()} is used. + *

This is useful for changing the default settings, yet still allowing + * further customizations via {@link #exchangeStrategies(Consumer)}. + * By default {@link ExchangeStrategies#withDefaults()} is used. * @param strategies the strategies to use + * @deprecated as of 5.1 in favor of {@link #exchangeStrategies(ExchangeStrategies.Builder)} */ + @Deprecated Builder exchangeStrategies(ExchangeStrategies strategies); + /** + * Configure the {@link ExchangeStrategies.Builder} to use. + *

This is useful for changing the default settings, yet still allowing + * further customizations via {@link #exchangeStrategies(Consumer)}. + * By default {@link ExchangeStrategies#builder()} is used. + * @param strategies the strategies to use + * @since 5.1.12 + */ + Builder exchangeStrategies(ExchangeStrategies.Builder strategies); + + /** + * Customize the {@link ExchangeStrategies}. + *

Allows further customization on {@link ExchangeStrategies}, + * mutating them if they were {@link #exchangeStrategies(ExchangeStrategies) set}, + * or starting from {@link ExchangeStrategies#withDefaults() defaults}. + * @since 5.1.12 + */ + Builder exchangeStrategies(Consumer configurer); + /** * Max amount of time to wait for responses. *

By default 5 seconds. @@ -928,7 +952,7 @@ interface BodyContentSpec { * @since 5.1 * @see #xpath(String, Map, Object...) */ - default XpathAssertions xpath(String expression, Object... args){ + default XpathAssertions xpath(String expression, Object... args) { return xpath(expression, null, args); } @@ -942,7 +966,7 @@ default XpathAssertions xpath(String expression, Object... args){ * @param args arguments to parameterize the expression * @since 5.1 */ - XpathAssertions xpath(String expression, @Nullable Map namespaces, Object... args); + XpathAssertions xpath(String expression, @Nullable Map namespaces, Object... args); /** * Assert the response body content with the given {@link Consumer}. diff --git a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java index db31e97218a4..028d85af381b 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -63,6 +63,11 @@ public interface ClientCodecConfigurer extends CodecConfigurer { @Override ClientDefaultCodecs defaultCodecs(); + /** + * Clone this {@link ClientCodecConfigurer}. + */ + @Override + ClientCodecConfigurer clone(); /** * Static factory method for a {@code ClientCodecConfigurer}. diff --git a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java index 4e1ca8bd0132..55184522c533 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java @@ -87,6 +87,12 @@ public interface CodecConfigurer { */ List> getWriters(); + /** + * Clone this {@link CodecConfigurer}. + * @since 5.1.12 + */ + CodecConfigurer clone(); + /** * Customize or replace the HTTP message readers and writers registered by diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java index 3c6b367c22ac..6d7c61938849 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java @@ -34,13 +34,14 @@ * client and server specific variants. * * @author Rossen Stoyanchev + * @author Brian Clozel * @since 5.0 */ class BaseCodecConfigurer implements CodecConfigurer { - private final BaseDefaultCodecs defaultCodecs; + protected final BaseDefaultCodecs defaultCodecs; - private final DefaultCustomCodecs customCodecs = new DefaultCustomCodecs(); + protected final DefaultCustomCodecs customCodecs; /** @@ -50,6 +51,16 @@ class BaseCodecConfigurer implements CodecConfigurer { BaseCodecConfigurer(BaseDefaultCodecs defaultCodecs) { Assert.notNull(defaultCodecs, "'defaultCodecs' is required"); this.defaultCodecs = defaultCodecs; + this.customCodecs = new DefaultCustomCodecs(); + } + + /** + * Constructor with another {@link BaseCodecConfigurer} to copy + * the configuration from. + */ + BaseCodecConfigurer(BaseCodecConfigurer other) { + this.defaultCodecs = other.cloneDefaultCodecs(); + this.customCodecs = new DefaultCustomCodecs(other.customCodecs); } @@ -87,6 +98,17 @@ public List> getWriters() { return getWritersInternal(false); } + + @Override + public CodecConfigurer clone() { + return new BaseCodecConfigurer(this); + } + + protected BaseDefaultCodecs cloneDefaultCodecs() { + return new BaseDefaultCodecs(this.defaultCodecs); + } + + /** * Internal method that returns the configured writers. * @param forMultipart whether to returns writers for general use ("false"), @@ -110,7 +132,7 @@ protected List> getWritersInternal(boolean forMultipart) { /** * Default implementation of {@code CustomCodecs}. */ - private static final class DefaultCustomCodecs implements CustomCodecs { + protected static final class DefaultCustomCodecs implements CustomCodecs { private final List> typedReaders = new ArrayList<>(); @@ -121,6 +143,16 @@ private static final class DefaultCustomCodecs implements CustomCodecs { private final List> objectWriters = new ArrayList<>(); + DefaultCustomCodecs() { + } + + DefaultCustomCodecs(DefaultCustomCodecs other) { + other.typedReaders.addAll(this.typedReaders); + other.typedWriters.addAll(this.typedWriters); + other.objectReaders.addAll(this.objectReaders); + other.objectWriters.addAll(this.objectWriters); + } + @Override public void decoder(Decoder decoder) { reader(new DecoderHttpMessageReader<>(decoder)); @@ -143,7 +175,6 @@ public void writer(HttpMessageWriter writer) { (canWriteObject ? this.objectWriters : this.typedWriters).add(writer); } - // Package private accessors... List> getTypedReaders() { diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java index 39d76ad0ddbf..1020db44d90b 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java @@ -106,6 +106,21 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs { private boolean registerDefaults = true; + BaseDefaultCodecs() { + } + + protected BaseDefaultCodecs(BaseDefaultCodecs other) { + this.jackson2JsonDecoder = other.jackson2JsonDecoder; + this.jackson2JsonEncoder = other.jackson2JsonEncoder; + this.protobufDecoder = other.protobufDecoder; + this.protobufEncoder = other.protobufEncoder; + this.jaxb2Decoder = other.jaxb2Decoder; + this.jaxb2Encoder = other.jaxb2Encoder; + this.maxInMemorySize = other.maxInMemorySize; + this.enableLoggingRequestDetails = other.enableLoggingRequestDetails; + this.registerDefaults = other.registerDefaults; + } + @Override public void jackson2JsonDecoder(Decoder decoder) { this.jackson2JsonDecoder = decoder; diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java b/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java index 9f578b7320ab..e764cb969612 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -49,6 +49,17 @@ class ClientDefaultCodecsImpl extends BaseDefaultCodecs implements ClientCodecCo private Supplier>> partWritersSupplier; + ClientDefaultCodecsImpl() { + } + + ClientDefaultCodecsImpl(ClientDefaultCodecsImpl other) { + super(other); + this.multipartCodecs = new DefaultMultipartCodecs(other.multipartCodecs); + this.sseDecoder = other.sseDecoder; + this.partWritersSupplier = other.partWritersSupplier; + } + + /** * Set a supplier for part writers to use when * {@link #multipartCodecs()} are not explicitly configured. @@ -73,6 +84,14 @@ public void serverSentEventDecoder(Decoder decoder) { this.sseDecoder = decoder; } + @Override + public ClientDefaultCodecsImpl clone() { + ClientDefaultCodecsImpl codecs = new ClientDefaultCodecsImpl(); + codecs.multipartCodecs = this.multipartCodecs; + codecs.sseDecoder = this.sseDecoder; + codecs.partWritersSupplier = this.partWritersSupplier; + return codecs; + } @Override protected void extendObjectReaders(List> objectReaders) { @@ -116,6 +135,17 @@ private static class DefaultMultipartCodecs implements ClientCodecConfigurer.Mul private final List> writers = new ArrayList<>(); + + DefaultMultipartCodecs() { + } + + DefaultMultipartCodecs(@Nullable DefaultMultipartCodecs other) { + if (other != null) { + this.writers.addAll(other.writers); + } + } + + @Override public ClientCodecConfigurer.MultipartCodecs encoder(Encoder encoder) { writer(new EncoderHttpMessageWriter<>(encoder)); diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java index 9875ded1b98d..737282eecd5e 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -26,14 +26,30 @@ */ public class DefaultClientCodecConfigurer extends BaseCodecConfigurer implements ClientCodecConfigurer { + public DefaultClientCodecConfigurer() { super(new ClientDefaultCodecsImpl()); ((ClientDefaultCodecsImpl) defaultCodecs()).setPartWritersSupplier(() -> getWritersInternal(true)); } + private DefaultClientCodecConfigurer(DefaultClientCodecConfigurer other) { + super(other); + } + + @Override public ClientDefaultCodecs defaultCodecs() { return (ClientDefaultCodecs) super.defaultCodecs(); } + @Override + public DefaultClientCodecConfigurer clone() { + return new DefaultClientCodecConfigurer(this); + } + + @Override + protected BaseDefaultCodecs cloneDefaultCodecs() { + return new ClientDefaultCodecsImpl((ClientDefaultCodecsImpl) defaultCodecs()); + } + } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java index 2623d5a7f7b2..661d45d66693 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -26,13 +26,28 @@ */ public class DefaultServerCodecConfigurer extends BaseCodecConfigurer implements ServerCodecConfigurer { + public DefaultServerCodecConfigurer() { super(new ServerDefaultCodecsImpl()); } + private DefaultServerCodecConfigurer(BaseCodecConfigurer other) { + super(other); + } + + @Override public ServerDefaultCodecs defaultCodecs() { return (ServerDefaultCodecs) super.defaultCodecs(); } + @Override + public DefaultServerCodecConfigurer clone() { + return new DefaultServerCodecConfigurer(this); + } + + @Override + protected BaseDefaultCodecs cloneDefaultCodecs() { + return new ServerDefaultCodecsImpl((ServerDefaultCodecsImpl) defaultCodecs()); + } } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java b/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java index 37e924cd7e91..1d997c3777b1 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java @@ -46,6 +46,16 @@ class ServerDefaultCodecsImpl extends BaseDefaultCodecs implements ServerCodecCo private Encoder sseEncoder; + ServerDefaultCodecsImpl() { + } + + ServerDefaultCodecsImpl(ServerDefaultCodecsImpl other) { + super(other); + this.multipartReader = other.multipartReader; + this.sseEncoder = other.sseEncoder; + } + + @Override public void multipartReader(HttpMessageReader reader) { this.multipartReader = reader; diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java index 1a27f6400025..16164e24c518 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java @@ -268,6 +268,14 @@ public void encoderDecoderOverrides() { assertEncoderInstance(jaxb2Encoder); } + @Test + public void cloneConfigurer() { + CodecConfigurer clone = this.configurer.clone(); + this.configurer.registerDefaults(false); + assertThat(this.configurer.getReaders().size()).isEqualTo(0); + assertThat(clone.getReaders().size()).isEqualTo(11); + } + private Decoder getNextDecoder(List> readers) { HttpMessageReader reader = readers.get(this.index.getAndIncrement()); assertThat(reader.getClass()).isEqualTo(DecoderHttpMessageReader.class); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java index 1b2d2edcc2bd..a18ae42c6870 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -43,13 +43,18 @@ final class DefaultExchangeStrategiesBuilder implements ExchangeStrategies.Build } - private final ClientCodecConfigurer codecConfigurer = ClientCodecConfigurer.create(); + private final ClientCodecConfigurer codecConfigurer; public DefaultExchangeStrategiesBuilder() { + this.codecConfigurer = ClientCodecConfigurer.create(); this.codecConfigurer.registerDefaults(false); } + private DefaultExchangeStrategiesBuilder(DefaultExchangeStrategies other) { + this.codecConfigurer = other.codecConfigurer.clone(); + } + public void defaultConfiguration() { this.codecConfigurer.registerDefaults(true); @@ -69,19 +74,29 @@ public ExchangeStrategies build() { private static class DefaultExchangeStrategies implements ExchangeStrategies { + private final ClientCodecConfigurer codecConfigurer; + private final List> readers; private final List> writers; + public DefaultExchangeStrategies(ClientCodecConfigurer codecConfigurer) { - this.readers = unmodifiableCopy(codecConfigurer.getReaders()); - this.writers = unmodifiableCopy(codecConfigurer.getWriters()); + this.codecConfigurer = codecConfigurer; + this.readers = unmodifiableCopy(this.codecConfigurer.getReaders()); + this.writers = unmodifiableCopy(this.codecConfigurer.getWriters()); } private static List unmodifiableCopy(List list) { return Collections.unmodifiableList(new ArrayList<>(list)); } + @Override + @Deprecated + public Builder mutate() { + return new DefaultExchangeStrategiesBuilder(this); + } + @Override public List> messageReaders() { return this.readers; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java index db699ddaae16..82b4c4940861 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java @@ -40,6 +40,7 @@ * Default implementation of {@link WebClient.Builder}. * * @author Rossen Stoyanchev + * @author Brian Clozel * @since 5.0 */ final class DefaultWebClientBuilder implements WebClient.Builder { @@ -79,14 +80,16 @@ final class DefaultWebClientBuilder implements WebClient.Builder { @Nullable private ClientHttpConnector connector; - private ExchangeStrategies exchangeStrategies; + @Nullable + private ExchangeStrategies.Builder strategies; + + private List> strategiesConfigurers; @Nullable private ExchangeFunction exchangeFunction; public DefaultWebClientBuilder() { - this.exchangeStrategies = ExchangeStrategies.withDefaults(); } public DefaultWebClientBuilder(DefaultWebClientBuilder other) { @@ -108,7 +111,7 @@ public DefaultWebClientBuilder(DefaultWebClientBuilder other) { this.defaultRequest = other.defaultRequest; this.filters = other.filters != null ? new ArrayList<>(other.filters) : null; this.connector = other.connector; - this.exchangeStrategies = other.exchangeStrategies; + this.strategies = other.strategies; this.exchangeFunction = other.exchangeFunction; } @@ -203,9 +206,23 @@ public WebClient.Builder clientConnector(ClientHttpConnector connector) { } @Override + @Deprecated public WebClient.Builder exchangeStrategies(ExchangeStrategies strategies) { Assert.notNull(strategies, "ExchangeStrategies must not be null"); - this.exchangeStrategies = strategies; + this.strategies = strategies.mutate(); + return this; + } + + @Override + public WebClient.Builder exchangeStrategies(ExchangeStrategies.Builder strategies) { + Assert.notNull(strategies, "ExchangeStrategies must not be null"); + this.strategies = strategies; + return this; + } + + @Override + public WebClient.Builder exchangeStrategies(Consumer configurer) { + this.strategiesConfigurers.add(configurer); return this; } @@ -229,7 +246,7 @@ public WebClient.Builder clone() { @Override public WebClient build() { ExchangeFunction exchange = (this.exchangeFunction == null ? - ExchangeFunctions.create(getOrInitConnector(), this.exchangeStrategies) : + ExchangeFunctions.create(getOrInitConnector(), initExchangeStrategies()) : this.exchangeFunction); ExchangeFunction filteredExchange = (this.filters != null ? this.filters.stream() .reduce(ExchangeFilterFunction::andThen) @@ -254,6 +271,19 @@ else if (jettyClientPresent) { throw new IllegalStateException("No suitable default ClientHttpConnector found"); } + @SuppressWarnings("deprecation") + private ExchangeStrategies initExchangeStrategies() { + if (CollectionUtils.isEmpty(this.strategiesConfigurers)) { + return this.strategies != null ? this.strategies.build() : ExchangeStrategies.withDefaults(); + } + + ExchangeStrategies.Builder builder = + this.strategies != null ? this.strategies : ExchangeStrategies.builder(); + + this.strategiesConfigurers.forEach(configurer -> configurer.accept(builder)); + return builder.build(); + } + private UriBuilderFactory initUriBuilderFactory() { if (this.uriBuilderFactory != null) { return this.uriBuilderFactory; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java index 804fbd9a42fd..dfc2e1e14d59 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java @@ -47,6 +47,18 @@ public interface ExchangeStrategies { */ List> messageWriters(); + /** + * Return a builder to create a new {@link ExchangeStrategies} instance + * replicated from the current instance. + * @since 5.1.12 + * @deprecated APIs should consume {@link ExchangeStrategies} as final or accept an + * {@link ExchangeStrategies.Builder builder}. + */ + @Deprecated + default Builder mutate() { + throw new UnsupportedOperationException("This ExchangeStrategies implementation does not support mutation."); + } + // Static builder methods diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java index 57fb6397242a..79fdc5a8c1e4 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java @@ -66,6 +66,7 @@ * @author Rossen Stoyanchev * @author Arjen Poutsma * @author Sebastien Deleuze + * @author Brian Clozel * @since 5.0 */ public interface WebClient { @@ -290,12 +291,35 @@ interface Builder { Builder clientConnector(ClientHttpConnector connector); /** - * Configure the {@link ExchangeStrategies} to use. - *

By default this is obtained from {@link ExchangeStrategies#withDefaults()}. + * Provide the {@link ExchangeStrategies} to use. + *

This is useful for changing the default settings, yet still allowing + * further customizations via {@link #exchangeStrategies(Consumer)}. + * If not set, defaults are obtained from {@link ExchangeStrategies#withDefaults()}. * @param strategies the strategies to use + * @deprecated as of 5.1, in favor of {@link #exchangeStrategies(ExchangeStrategies.Builder)} */ + @Deprecated Builder exchangeStrategies(ExchangeStrategies strategies); + /** + * Provide the {@link ExchangeStrategies.Builder} to use. + *

This is useful for changing the default settings, yet still allowing + * further customizations via {@link #exchangeStrategies(Consumer)}. + * If not set, defaults are obtained from {@link ExchangeStrategies#builder()}. + * @param strategies the strategies to use + * @since 5.1.12 + */ + Builder exchangeStrategies(ExchangeStrategies.Builder strategies); + + /** + * Customize the {@link ExchangeStrategies}. + *

Allows further customization on {@link ExchangeStrategies}, + * mutating them if they were {@link #exchangeStrategies(ExchangeStrategies) set}, + * or starting from {@link ExchangeStrategies#withDefaults() defaults}. + * @since 5.1.12 + */ + Builder exchangeStrategies(Consumer configurer); + /** * Provide an {@link ExchangeFunction} pre-configured with * {@link ClientHttpConnector} and {@link ExchangeStrategies}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java index eb37921f7a18..af0eeb0f2260 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java @@ -39,4 +39,15 @@ public void withDefaults() { assertThat(strategies.messageWriters().isEmpty()).isFalse(); } + @Test + @SuppressWarnings("deprecation") + public void mutate() { + ExchangeStrategies strategies = ExchangeStrategies.empty().build(); + assertThat(strategies.messageReaders().isEmpty()).isTrue(); + assertThat(strategies.messageWriters().isEmpty()).isTrue(); + ExchangeStrategies mutated = strategies.mutate().codecs(codecs -> codecs.registerDefaults(true)).build(); + assertThat(mutated.messageReaders().isEmpty()).isFalse(); + assertThat(mutated.messageWriters().isEmpty()).isFalse(); + } + } diff --git a/src/docs/asciidoc/web/webflux-webclient.adoc b/src/docs/asciidoc/web/webflux-webclient.adoc index 5ef50e1c1903..7963da0087d7 100644 --- a/src/docs/asciidoc/web/webflux-webclient.adoc +++ b/src/docs/asciidoc/web/webflux-webclient.adoc @@ -41,28 +41,26 @@ The following example configures < { - // ... - }) - .build(); + Consumer customizeCodecs = builder -> { + builder.codecs(configurer -> { + //... + }); + }; WebClient client = WebClient.builder() - .exchangeStrategies(strategies) + .exchangeStrategies(customizeCodecs) .build(); ---- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin ---- - val strategies = ExchangeStrategies.builder() - .codecs { - // ... + val webClient = WebClient.builder() + .exchangeStrategies { strategies -> + strategies.codecs { + //... + } } .build() - - val client = WebClient.builder() - .exchangeStrategies(strategies) - .build() ---- Once built, a `WebClient` instance is immutable. However, you can clone it and build a @@ -95,7 +93,44 @@ modified copy without affecting the original instance, as the following example // client2 has filterA, filterB, filterC, filterD ---- +[[webflux-client-builder-maxinmemorysize]] +=== MaxInMemorySize + +Spring WebFlux configures by default a maximum size for buffering data in-memory when decoding +HTTP responses with the `WebClient`. This avoids application memory issues if the received +response is much larger than expected. + +The default configured value of 256KB might not be enough for your use case, and your application +might hit that limit with the following: + +---- +org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer +---- + +You can configure this limit on all default codecs with the following code sample: +[source,java,indent=0,subs="verbatim,quotes",role="primary"] +.Java +---- + WebClient webClient = WebClient.builder() + .exchangeStrategies(configurer -> + configurer.codecs(codecs -> + codecs.defaultCodecs().maxInMemorySize(2 * 1024 * 1024) + ) + ) + .build(); +---- +[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] +.Kotlin +---- + val webClient = WebClient.builder() + .exchangeStrategies { strategies -> + strategies.codecs { + it.defaultCodecs().maxInMemorySize(2 * 1024 * 1024) + } + } + .build() +---- [[webflux-client-builder-reactor]] === Reactor Netty From acfeb77d4173e90a4db08b3201cd2c6798173f6d Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 2 Dec 2019 14:12:33 +0000 Subject: [PATCH 0151/2315] Polishing See gh-23961 --- .../server/DefaultWebTestClientBuilder.java | 6 -- .../web/reactive/server/WebTestClient.java | 29 +++---- .../http/codec/ClientCodecConfigurer.java | 3 +- .../http/codec/CodecConfigurer.java | 5 +- .../http/codec/ServerCodecConfigurer.java | 6 ++ .../codec/support/BaseCodecConfigurer.java | 32 ++++---- .../http/codec/support/BaseDefaultCodecs.java | 3 + .../support/ClientCodecConfigurerTests.java | 42 ++++++++++ .../codec/support/CodecConfigurerTests.java | 81 +++++++++++++++++-- .../support/ServerCodecConfigurerTests.java | 44 ++++++++++ .../DefaultExchangeStrategiesBuilder.java | 11 ++- .../client/DefaultWebClientBuilder.java | 17 ++-- .../function/client/ExchangeStrategies.java | 5 +- .../reactive/function/client/WebClient.java | 31 +++---- .../client/DefaultWebClientTests.java | 4 + .../client/ExchangeStrategiesTests.java | 1 + src/docs/asciidoc/web/webflux-webclient.adoc | 31 ++++--- src/docs/asciidoc/web/webflux.adoc | 3 +- 18 files changed, 250 insertions(+), 104 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java index 4d5aeca17eb7..5ae951c18742 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java @@ -143,12 +143,6 @@ public WebTestClient.Builder exchangeStrategies(ExchangeStrategies strategies) { return this; } - @Override - public WebTestClient.Builder exchangeStrategies(ExchangeStrategies.Builder strategies) { - this.webClientBuilder.exchangeStrategies(strategies); - return this; - } - @Override public WebTestClient.Builder exchangeStrategies(Consumer configurer) { this.webClientBuilder.exchangeStrategies(configurer); diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java index f7a0e78824d8..814a3a9ebd09 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java @@ -444,30 +444,21 @@ interface Builder { /** * Configure the {@link ExchangeStrategies} to use. - *

This is useful for changing the default settings, yet still allowing - * further customizations via {@link #exchangeStrategies(Consumer)}. - * By default {@link ExchangeStrategies#withDefaults()} is used. + *

Note that in a scenario where the builder is configured by + * multiple parties, it is preferable to use + * {@link #exchangeStrategies(Consumer)} in order to customize the same + * {@code ExchangeStrategies}. This method here sets the strategies that + * everyone else then can customize. + *

By default this is {@link ExchangeStrategies#withDefaults()}. * @param strategies the strategies to use - * @deprecated as of 5.1 in favor of {@link #exchangeStrategies(ExchangeStrategies.Builder)} */ - @Deprecated Builder exchangeStrategies(ExchangeStrategies strategies); /** - * Configure the {@link ExchangeStrategies.Builder} to use. - *

This is useful for changing the default settings, yet still allowing - * further customizations via {@link #exchangeStrategies(Consumer)}. - * By default {@link ExchangeStrategies#builder()} is used. - * @param strategies the strategies to use - * @since 5.1.12 - */ - Builder exchangeStrategies(ExchangeStrategies.Builder strategies); - - /** - * Customize the {@link ExchangeStrategies}. - *

Allows further customization on {@link ExchangeStrategies}, - * mutating them if they were {@link #exchangeStrategies(ExchangeStrategies) set}, - * or starting from {@link ExchangeStrategies#withDefaults() defaults}. + * Customize the strategies configured via + * {@link #exchangeStrategies(ExchangeStrategies)}. This method is + * designed for use in scenarios where multiple parties wish to update + * the {@code ExchangeStrategies}. * @since 5.1.12 */ Builder exchangeStrategies(Consumer configurer); diff --git a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java index 028d85af381b..e41ec7348117 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java @@ -64,11 +64,12 @@ public interface ClientCodecConfigurer extends CodecConfigurer { ClientDefaultCodecs defaultCodecs(); /** - * Clone this {@link ClientCodecConfigurer}. + * {@inheritDoc}. */ @Override ClientCodecConfigurer clone(); + /** * Static factory method for a {@code ClientCodecConfigurer}. */ diff --git a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java index 55184522c533..2e69bfc14b98 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java @@ -88,7 +88,10 @@ public interface CodecConfigurer { List> getWriters(); /** - * Clone this {@link CodecConfigurer}. + * Create a copy of this {@link CodecConfigurer}. The returned clone has its + * own lists of default and custom codecs and generally can be configured + * independently. Keep in mind however that codec instances (if any are + * configured) are themselves not cloned. * @since 5.1.12 */ CodecConfigurer clone(); diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/ServerCodecConfigurer.java index 1479390b525e..3d49092f593f 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerCodecConfigurer.java @@ -62,6 +62,12 @@ public interface ServerCodecConfigurer extends CodecConfigurer { @Override ServerDefaultCodecs defaultCodecs(); + /** + * {@inheritDoc}. + */ + @Override + ServerCodecConfigurer clone(); + /** * Static factory method for a {@code ServerCodecConfigurer}. diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java index 6d7c61938849..31b3784a3fca 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java @@ -37,7 +37,7 @@ * @author Brian Clozel * @since 5.0 */ -class BaseCodecConfigurer implements CodecConfigurer { +abstract class BaseCodecConfigurer implements CodecConfigurer { protected final BaseDefaultCodecs defaultCodecs; @@ -55,14 +55,21 @@ class BaseCodecConfigurer implements CodecConfigurer { } /** - * Constructor with another {@link BaseCodecConfigurer} to copy - * the configuration from. + * Create a deep copy of the given {@link BaseCodecConfigurer}. + * @since 5.1.12 */ - BaseCodecConfigurer(BaseCodecConfigurer other) { + protected BaseCodecConfigurer(BaseCodecConfigurer other) { this.defaultCodecs = other.cloneDefaultCodecs(); this.customCodecs = new DefaultCustomCodecs(other.customCodecs); } + /** + * Sub-classes should override this to create deep copy of + * {@link BaseDefaultCodecs} which can can be client or server specific. + * @since 5.1.12 + */ + protected abstract BaseDefaultCodecs cloneDefaultCodecs(); + @Override public DefaultCodecs defaultCodecs() { @@ -99,16 +106,6 @@ public List> getWriters() { } - @Override - public CodecConfigurer clone() { - return new BaseCodecConfigurer(this); - } - - protected BaseDefaultCodecs cloneDefaultCodecs() { - return new BaseDefaultCodecs(this.defaultCodecs); - } - - /** * Internal method that returns the configured writers. * @param forMultipart whether to returns writers for general use ("false"), @@ -128,6 +125,9 @@ protected List> getWritersInternal(boolean forMultipart) { return result; } + @Override + public abstract CodecConfigurer clone(); + /** * Default implementation of {@code CustomCodecs}. @@ -146,6 +146,10 @@ protected static final class DefaultCustomCodecs implements CustomCodecs { DefaultCustomCodecs() { } + /** + * Create a deep copy of the given {@link DefaultCustomCodecs}. + * @since 5.1.12 + */ DefaultCustomCodecs(DefaultCustomCodecs other) { other.typedReaders.addAll(this.typedReaders); other.typedWriters.addAll(this.typedWriters); diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java index 1020db44d90b..ec38c10a29a3 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java @@ -109,6 +109,9 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs { BaseDefaultCodecs() { } + /** + * Create a deep copy of the given {@link BaseDefaultCodecs}. + */ protected BaseDefaultCodecs(BaseDefaultCodecs other) { this.jackson2JsonDecoder = other.jackson2JsonDecoder; this.jackson2JsonEncoder = other.jackson2JsonEncoder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java index c66fc19eec51..5faea0c90ed2 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; @@ -123,6 +124,47 @@ public void jackson2EncoderOverride() { .filter(e -> e == decoder).orElse(null)).isSameAs(decoder); } + @Test + public void cloneConfigurer() { + ClientCodecConfigurer clone = this.configurer.clone(); + + Jackson2JsonDecoder jackson2Decoder = new Jackson2JsonDecoder(); + clone.defaultCodecs().serverSentEventDecoder(jackson2Decoder); + clone.defaultCodecs().multipartCodecs().encoder(new Jackson2SmileEncoder()); + clone.defaultCodecs().multipartCodecs().writer(new ResourceHttpMessageWriter()); + + // Clone has the customizations + + Decoder sseDecoder = clone.getReaders().stream() + .filter(reader -> reader instanceof ServerSentEventHttpMessageReader) + .map(reader -> ((ServerSentEventHttpMessageReader) reader).getDecoder()) + .findFirst() + .get(); + + List> multipartWriters = clone.getWriters().stream() + .filter(writer -> writer instanceof MultipartHttpMessageWriter) + .flatMap(writer -> ((MultipartHttpMessageWriter) writer).getPartWriters().stream()) + .collect(Collectors.toList()); + + assertThat(sseDecoder).isSameAs(jackson2Decoder); + assertThat(multipartWriters).hasSize(2); + + // Original does not have the customizations + + sseDecoder = this.configurer.getReaders().stream() + .filter(reader -> reader instanceof ServerSentEventHttpMessageReader) + .map(reader -> ((ServerSentEventHttpMessageReader) reader).getDecoder()) + .findFirst() + .get(); + + multipartWriters = this.configurer.getWriters().stream() + .filter(writer -> writer instanceof MultipartHttpMessageWriter) + .flatMap(writer -> ((MultipartHttpMessageWriter) writer).getPartWriters().stream()) + .collect(Collectors.toList()); + + assertThat(sseDecoder).isNotSameAs(jackson2Decoder); + assertThat(multipartWriters).hasSize(10); + } private Decoder getNextDecoder(List> readers) { HttpMessageReader reader = readers.get(this.index.getAndIncrement()); diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java index 16164e24c518..1d66e933d8c3 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; import com.google.protobuf.ExtensionRegistry; import org.junit.jupiter.api.Test; @@ -42,6 +43,8 @@ import org.springframework.http.codec.HttpMessageWriter; import org.springframework.http.codec.ResourceHttpMessageReader; import org.springframework.http.codec.ResourceHttpMessageWriter; +import org.springframework.http.codec.ServerSentEventHttpMessageReader; +import org.springframework.http.codec.ServerSentEventHttpMessageWriter; import org.springframework.http.codec.json.Jackson2JsonDecoder; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.codec.json.Jackson2SmileDecoder; @@ -269,11 +272,68 @@ public void encoderDecoderOverrides() { } @Test - public void cloneConfigurer() { - CodecConfigurer clone = this.configurer.clone(); + public void cloneCustomCodecs() { this.configurer.registerDefaults(false); + CodecConfigurer clone = this.configurer.clone(); + + clone.customCodecs().encoder(new Jackson2JsonEncoder()); + clone.customCodecs().decoder(new Jackson2JsonDecoder()); + clone.customCodecs().reader(new ServerSentEventHttpMessageReader()); + clone.customCodecs().writer(new ServerSentEventHttpMessageWriter()); + assertThat(this.configurer.getReaders().size()).isEqualTo(0); - assertThat(clone.getReaders().size()).isEqualTo(11); + assertThat(this.configurer.getWriters().size()).isEqualTo(0); + assertThat(clone.getReaders().size()).isEqualTo(2); + assertThat(clone.getWriters().size()).isEqualTo(2); + } + + @Test + public void cloneDefaultCodecs() { + CodecConfigurer clone = this.configurer.clone(); + + Jackson2JsonDecoder jacksonDecoder = new Jackson2JsonDecoder(); + Jackson2JsonEncoder jacksonEncoder = new Jackson2JsonEncoder(); + Jaxb2XmlDecoder jaxb2Decoder = new Jaxb2XmlDecoder(); + Jaxb2XmlEncoder jaxb2Encoder = new Jaxb2XmlEncoder(); + ProtobufDecoder protoDecoder = new ProtobufDecoder(); + ProtobufEncoder protoEncoder = new ProtobufEncoder(); + + clone.defaultCodecs().jackson2JsonDecoder(jacksonDecoder); + clone.defaultCodecs().jackson2JsonEncoder(jacksonEncoder); + clone.defaultCodecs().jaxb2Decoder(jaxb2Decoder); + clone.defaultCodecs().jaxb2Encoder(jaxb2Encoder); + clone.defaultCodecs().protobufDecoder(protoDecoder); + clone.defaultCodecs().protobufEncoder(protoEncoder); + + // Clone has the customized the customizations + + List> decoders = clone.getReaders().stream() + .filter(reader -> reader instanceof DecoderHttpMessageReader) + .map(reader -> ((DecoderHttpMessageReader) reader).getDecoder()) + .collect(Collectors.toList()); + + List> encoders = clone.getWriters().stream() + .filter(writer -> writer instanceof EncoderHttpMessageWriter) + .map(reader -> ((EncoderHttpMessageWriter) reader).getEncoder()) + .collect(Collectors.toList()); + + assertThat(decoders).contains(jacksonDecoder, jaxb2Decoder, protoDecoder); + assertThat(encoders).contains(jacksonEncoder, jaxb2Encoder, protoEncoder); + + // Original does not have the customizations + + decoders = this.configurer.getReaders().stream() + .filter(reader -> reader instanceof DecoderHttpMessageReader) + .map(reader -> ((DecoderHttpMessageReader) reader).getDecoder()) + .collect(Collectors.toList()); + + encoders = this.configurer.getWriters().stream() + .filter(writer -> writer instanceof EncoderHttpMessageWriter) + .map(reader -> ((EncoderHttpMessageWriter) reader).getEncoder()) + .collect(Collectors.toList()); + + assertThat(decoders).doesNotContain(jacksonDecoder, jaxb2Decoder, protoDecoder); + assertThat(encoders).doesNotContain(jacksonEncoder, jaxb2Encoder, protoEncoder); } private Decoder getNextDecoder(List> readers) { @@ -324,10 +384,21 @@ private void assertEncoderInstance(Encoder encoder) { private static class TestCodecConfigurer extends BaseCodecConfigurer { TestCodecConfigurer() { - super(new TestDefaultCodecs()); + super(new BaseDefaultCodecs()); + } + + TestCodecConfigurer(TestCodecConfigurer other) { + super(other); + } + + @Override + protected BaseDefaultCodecs cloneDefaultCodecs() { + return new BaseDefaultCodecs((BaseDefaultCodecs) defaultCodecs()); } - private static class TestDefaultCodecs extends BaseDefaultCodecs { + @Override + public CodecConfigurer clone() { + return new TestCodecConfigurer(this); } } diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java index 5698e154dd36..023ec5af9b98 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java @@ -154,6 +154,50 @@ public void maxInMemorySize() { assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); } + @Test + public void cloneConfigurer() { + ServerCodecConfigurer clone = this.configurer.clone(); + + MultipartHttpMessageReader reader = new MultipartHttpMessageReader(new SynchronossPartHttpMessageReader()); + Jackson2JsonEncoder encoder = new Jackson2JsonEncoder(); + clone.defaultCodecs().multipartReader(reader); + clone.defaultCodecs().serverSentEventEncoder(encoder); + + // Clone has the customizations + + HttpMessageReader actualReader = clone.getReaders().stream() + .filter(r -> r instanceof MultipartHttpMessageReader) + .findFirst() + .get(); + + Encoder actualEncoder = clone.getWriters().stream() + .filter(writer -> writer instanceof ServerSentEventHttpMessageWriter) + .map(writer -> ((ServerSentEventHttpMessageWriter) writer).getEncoder()) + .findFirst() + .get(); + + + assertThat(actualReader).isSameAs(reader); + assertThat(actualEncoder).isSameAs(encoder); + + // Original does not have the customizations + + actualReader = this.configurer.getReaders().stream() + .filter(r -> r instanceof MultipartHttpMessageReader) + .findFirst() + .get(); + + actualEncoder = this.configurer.getWriters().stream() + .filter(writer -> writer instanceof ServerSentEventHttpMessageWriter) + .map(writer -> ((ServerSentEventHttpMessageWriter) writer).getEncoder()) + .findFirst() + .get(); + + + assertThat(actualReader).isNotSameAs(reader); + assertThat(actualEncoder).isNotSameAs(encoder); + } + private Decoder getNextDecoder(List> readers) { HttpMessageReader reader = nextReader(readers); assertThat(reader.getClass()).isEqualTo(DecoderHttpMessageReader.class); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java index a18ae42c6870..93732fc2e48c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java @@ -91,12 +91,6 @@ private static List unmodifiableCopy(List list) { return Collections.unmodifiableList(new ArrayList<>(list)); } - @Override - @Deprecated - public Builder mutate() { - return new DefaultExchangeStrategiesBuilder(this); - } - @Override public List> messageReaders() { return this.readers; @@ -106,6 +100,11 @@ public List> messageReaders() { public List> messageWriters() { return this.writers; } + + @Override + public Builder mutate() { + return new DefaultExchangeStrategiesBuilder(this); + } } } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java index 82b4c4940861..f7e9517d27b2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java @@ -81,8 +81,9 @@ final class DefaultWebClientBuilder implements WebClient.Builder { private ClientHttpConnector connector; @Nullable - private ExchangeStrategies.Builder strategies; + private ExchangeStrategies strategies; + @Nullable private List> strategiesConfigurers; @Nullable @@ -208,13 +209,6 @@ public WebClient.Builder clientConnector(ClientHttpConnector connector) { @Override @Deprecated public WebClient.Builder exchangeStrategies(ExchangeStrategies strategies) { - Assert.notNull(strategies, "ExchangeStrategies must not be null"); - this.strategies = strategies.mutate(); - return this; - } - - @Override - public WebClient.Builder exchangeStrategies(ExchangeStrategies.Builder strategies) { Assert.notNull(strategies, "ExchangeStrategies must not be null"); this.strategies = strategies; return this; @@ -222,6 +216,9 @@ public WebClient.Builder exchangeStrategies(ExchangeStrategies.Builder strategie @Override public WebClient.Builder exchangeStrategies(Consumer configurer) { + if (this.strategiesConfigurers == null) { + this.strategiesConfigurers = new ArrayList<>(4); + } this.strategiesConfigurers.add(configurer); return this; } @@ -274,11 +271,11 @@ else if (jettyClientPresent) { @SuppressWarnings("deprecation") private ExchangeStrategies initExchangeStrategies() { if (CollectionUtils.isEmpty(this.strategiesConfigurers)) { - return this.strategies != null ? this.strategies.build() : ExchangeStrategies.withDefaults(); + return this.strategies != null ? this.strategies : ExchangeStrategies.withDefaults(); } ExchangeStrategies.Builder builder = - this.strategies != null ? this.strategies : ExchangeStrategies.builder(); + this.strategies != null ? this.strategies.mutate() : ExchangeStrategies.builder(); this.strategiesConfigurers.forEach(configurer -> configurer.accept(builder)); return builder.build(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java index dfc2e1e14d59..acf32d0959ae 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java @@ -51,12 +51,9 @@ public interface ExchangeStrategies { * Return a builder to create a new {@link ExchangeStrategies} instance * replicated from the current instance. * @since 5.1.12 - * @deprecated APIs should consume {@link ExchangeStrategies} as final or accept an - * {@link ExchangeStrategies.Builder builder}. */ - @Deprecated default Builder mutate() { - throw new UnsupportedOperationException("This ExchangeStrategies implementation does not support mutation."); + throw new UnsupportedOperationException(); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java index 79fdc5a8c1e4..93951bbb966c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java @@ -291,31 +291,22 @@ interface Builder { Builder clientConnector(ClientHttpConnector connector); /** - * Provide the {@link ExchangeStrategies} to use. - *

This is useful for changing the default settings, yet still allowing - * further customizations via {@link #exchangeStrategies(Consumer)}. - * If not set, defaults are obtained from {@link ExchangeStrategies#withDefaults()}. + * Configure the {@link ExchangeStrategies} to use. + *

Note that in a scenario where the builder is configured by + * multiple parties, it is preferable to use + * {@link #exchangeStrategies(Consumer)} in order to customize the same + * {@code ExchangeStrategies}. This method here sets the strategies that + * everyone else then can customize. + *

By default this is {@link ExchangeStrategies#withDefaults()}. * @param strategies the strategies to use - * @deprecated as of 5.1, in favor of {@link #exchangeStrategies(ExchangeStrategies.Builder)} */ - @Deprecated Builder exchangeStrategies(ExchangeStrategies strategies); /** - * Provide the {@link ExchangeStrategies.Builder} to use. - *

This is useful for changing the default settings, yet still allowing - * further customizations via {@link #exchangeStrategies(Consumer)}. - * If not set, defaults are obtained from {@link ExchangeStrategies#builder()}. - * @param strategies the strategies to use - * @since 5.1.12 - */ - Builder exchangeStrategies(ExchangeStrategies.Builder strategies); - - /** - * Customize the {@link ExchangeStrategies}. - *

Allows further customization on {@link ExchangeStrategies}, - * mutating them if they were {@link #exchangeStrategies(ExchangeStrategies) set}, - * or starting from {@link ExchangeStrategies#withDefaults() defaults}. + * Customize the strategies configured via + * {@link #exchangeStrategies(ExchangeStrategies)}. This method is + * designed for use in scenarios where multiple parties wish to update + * the {@code ExchangeStrategies}. * @since 5.1.12 */ Builder exchangeStrategies(Consumer configurer); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java index 7b4a06277413..a731aad83361 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java @@ -20,6 +20,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; import java.util.function.Predicate; import org.junit.jupiter.api.BeforeEach; @@ -36,6 +38,8 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.codec.FormHttpMessageReader; +import org.springframework.http.codec.FormHttpMessageWriter; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java index af0eeb0f2260..14b91b1d6185 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java @@ -45,6 +45,7 @@ public void mutate() { ExchangeStrategies strategies = ExchangeStrategies.empty().build(); assertThat(strategies.messageReaders().isEmpty()).isTrue(); assertThat(strategies.messageWriters().isEmpty()).isTrue(); + ExchangeStrategies mutated = strategies.mutate().codecs(codecs -> codecs.registerDefaults(true)).build(); assertThat(mutated.messageReaders().isEmpty()).isFalse(); assertThat(mutated.messageWriters().isEmpty()).isFalse(); diff --git a/src/docs/asciidoc/web/webflux-webclient.adoc b/src/docs/asciidoc/web/webflux-webclient.adoc index 7963da0087d7..372255fcaf4b 100644 --- a/src/docs/asciidoc/web/webflux-webclient.adoc +++ b/src/docs/asciidoc/web/webflux-webclient.adoc @@ -41,14 +41,12 @@ The following example configures < customizeCodecs = builder -> { - builder.codecs(configurer -> { - //... - }); - }; - WebClient client = WebClient.builder() - .exchangeStrategies(customizeCodecs) + .exchangeStrategies(builder -> { + return builder.codecs(codecConfigurer -> { + //... + }); + }) .build(); ---- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] @@ -96,12 +94,9 @@ modified copy without affecting the original instance, as the following example [[webflux-client-builder-maxinmemorysize]] === MaxInMemorySize -Spring WebFlux configures by default a maximum size for buffering data in-memory when decoding -HTTP responses with the `WebClient`. This avoids application memory issues if the received -response is much larger than expected. - -The default configured value of 256KB might not be enough for your use case, and your application -might hit that limit with the following: +Spring WebFlux configures <> for buffering +data in-memory in codec to avoid application memory issues. By the default this is +configured to 256KB and if that's not enough for your use case, you'll see the following: ---- org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer @@ -113,8 +108,8 @@ You can configure this limit on all default codecs with the following code sampl .Java ---- WebClient webClient = WebClient.builder() - .exchangeStrategies(configurer -> - configurer.codecs(codecs -> + .exchangeStrategies(builder -> + builder.codecs(codecs -> codecs.defaultCodecs().maxInMemorySize(2 * 1024 * 1024) ) ) @@ -124,14 +119,16 @@ You can configure this limit on all default codecs with the following code sampl .Kotlin ---- val webClient = WebClient.builder() - .exchangeStrategies { strategies -> - strategies.codecs { + .exchangeStrategies { builder -> + builder.codecs { it.defaultCodecs().maxInMemorySize(2 * 1024 * 1024) } } .build() ---- + + [[webflux-client-builder-reactor]] === Reactor Netty diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index 92a8108968c0..cff1be3b71a3 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -833,7 +833,8 @@ To configure buffer sizes, you can check if a given `Decoder` or `HttpMessageRea exposes a `maxInMemorySize` property and if so the Javadoc will have details about default values. In WebFlux, the `ServerCodecConfigurer` provides a <> from where to set all codecs, through the -`maxInMemorySize` property for default codecs. +`maxInMemorySize` property for default codecs. On the client side, the limit can be changed +in <>. For <> the `maxInMemorySize` property limits the size of non-file parts. For file parts it determines the threshold at which the part From 50ac8ad8b7d292066e38f5452d60ce81563eafa7 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 2 Dec 2019 14:25:00 +0000 Subject: [PATCH 0152/2315] Fix checkstyle violation --- .../web/reactive/function/client/DefaultWebClientTests.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java index a731aad83361..7b4a06277413 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java @@ -20,8 +20,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Consumer; import java.util.function.Predicate; import org.junit.jupiter.api.BeforeEach; @@ -38,8 +36,6 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.http.codec.FormHttpMessageReader; -import org.springframework.http.codec.FormHttpMessageWriter; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; From 279777b2f3a43ed96eb8151f07b76f38672cc78f Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 2 Dec 2019 16:22:40 +0100 Subject: [PATCH 0153/2315] Polishing --- .../core/annotation/AnnotationTypeMapping.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java index b439926e2d73..c865b0a222b6 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java @@ -475,7 +475,7 @@ boolean isEquivalentToDefaultValue(int attributeIndex, Object value, /** * Get the mirror sets for this type mapping. - * @return the mirrorSets the attribute mirror sets. + * @return the attribute mirror sets */ MirrorSets getMirrorSets() { return this.mirrorSets; @@ -648,8 +648,7 @@ int resolve(@Nullable Object source, @Nullable A annotation, if (isDefaultValue || ObjectUtils.nullSafeEquals(lastValue, value)) { continue; } - if (lastValue != null && - !ObjectUtils.nullSafeEquals(lastValue, value)) { + if (lastValue != null && !ObjectUtils.nullSafeEquals(lastValue, value)) { String on = (source != null) ? " declared on " + source : ""; throw new AnnotationConfigurationException(String.format( "Different @AliasFor mirror values for annotation [%s]%s; attribute '%s' " + From 35b7f3bf343c08b91053e0b3012df21c0f52978a Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 2 Dec 2019 16:43:02 +0100 Subject: [PATCH 0154/2315] Unpublish Gradle metadata See gh-23503 --- settings.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 132e7e40d765..ba295ee37ff9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,7 +4,6 @@ pluginManagement { maven { url 'https://repo.spring.io/plugins-release' } } } -enableFeaturePreview("GRADLE_METADATA") apply from: "$rootDir/gradle/build-cache-settings.gradle" include "spring-aop" From fcbc4378256ee50d17bf0312dccef60cfa4c77ba Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 2 Dec 2019 17:14:13 +0000 Subject: [PATCH 0155/2315] Polishing (follow-up on acfeb7) --- .../test/web/reactive/server/DefaultWebTestClientBuilder.java | 1 - .../web/reactive/function/client/DefaultWebClientBuilder.java | 3 --- 2 files changed, 4 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java index 5ae951c18742..82006d37b255 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java @@ -137,7 +137,6 @@ public WebTestClient.Builder filters(Consumer> filt } @Override - @Deprecated public WebTestClient.Builder exchangeStrategies(ExchangeStrategies strategies) { this.webClientBuilder.exchangeStrategies(strategies); return this; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java index f7e9517d27b2..44c3164b701b 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java @@ -207,9 +207,7 @@ public WebClient.Builder clientConnector(ClientHttpConnector connector) { } @Override - @Deprecated public WebClient.Builder exchangeStrategies(ExchangeStrategies strategies) { - Assert.notNull(strategies, "ExchangeStrategies must not be null"); this.strategies = strategies; return this; } @@ -268,7 +266,6 @@ else if (jettyClientPresent) { throw new IllegalStateException("No suitable default ClientHttpConnector found"); } - @SuppressWarnings("deprecation") private ExchangeStrategies initExchangeStrategies() { if (CollectionUtils.isEmpty(this.strategiesConfigurers)) { return this.strategies != null ? this.strategies : ExchangeStrategies.withDefaults(); From d1ab81587ce1db25183a5f1955410417889d961d Mon Sep 17 00:00:00 2001 From: Wang Xuesong Date: Tue, 3 Dec 2019 02:14:18 +0800 Subject: [PATCH 0156/2315] [*.*] is displayed as [bold .] and needs to be escaped execution(* com.xyz.service.*.*(..)) -> execution(* com.xyz.service.\*.*(..)) Closes gh-24108 --- src/docs/asciidoc/core/core-aop.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docs/asciidoc/core/core-aop.adoc b/src/docs/asciidoc/core/core-aop.adoc index ba428d31ad68..bc100f83e554 100644 --- a/src/docs/asciidoc/core/core-aop.adoc +++ b/src/docs/asciidoc/core/core-aop.adoc @@ -739,14 +739,14 @@ The following examples show some common pointcut expressions: + [literal,subs="verbatim,quotes"] ---- - execution(* com.xyz.service.*.*(..)) + execution(* com.xyz.service.\*.*(..)) ---- * The execution of any method defined in the service package or one of its sub-packages: + [literal,subs="verbatim,quotes"] ---- - execution(* com.xyz.service..*.*(..)) + execution(* com.xyz.service..\*.*(..)) ---- * Any join point (method execution only in Spring AOP) within the service package: From decbb9ccf9dd4da87f2f3aeca9b05ce24824beb9 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 2 Dec 2019 22:52:55 +0100 Subject: [PATCH 0157/2315] Provide default codecs config callback to custom codecs As a follow-up of gh-23961, this change provides a way for custom codecs to align with the default codecs' behavior on common features like buffer size limits and logging request details. Closes gh-24118 Co-authored-by: Rossen Stoyanchev --- .../http/codec/CodecConfigurer.java | 34 ++++++++++++++ .../codec/support/BaseCodecConfigurer.java | 18 ++++++++ .../http/codec/support/BaseDefaultCodecs.java | 8 ++-- src/docs/asciidoc/web/webflux.adoc | 45 ++++++++++++++++++- 4 files changed, 100 insertions(+), 5 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java index 2e69bfc14b98..4caf849b1af2 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java @@ -17,9 +17,11 @@ package org.springframework.http.codec; import java.util.List; +import java.util.function.Consumer; import org.springframework.core.codec.Decoder; import org.springframework.core.codec.Encoder; +import org.springframework.lang.Nullable; /** * Defines a common interface for configuring either client or server HTTP @@ -212,6 +214,38 @@ interface CustomCodecs { * @param writer the writer to add */ void writer(HttpMessageWriter writer); + + /** + * Register a callback for the {@link DefaultCodecConfig configuration} + * applied to default codecs. This allows custom codecs to follow general + * guidelines applied to default ones, such as logging details and limiting + * the amount of buffered data. + * @param codecsConfigConsumer the default codecs configuration callback + * @since 5.1.12 + */ + void withDefaultCodecConfig(Consumer codecsConfigConsumer); + } + + + /** + * Common options applied to default codecs and passed in a callback to custom codecs + * so they get a chance to align their behavior on the default ones. + * @since 5.1.12 + */ + interface DefaultCodecConfig { + + /** + * Get the configured limit on the number of bytes that can be buffered whenever + * the input stream needs to be aggregated. + */ + @Nullable + Integer maxInMemorySize(); + + /** + * Whether to log form data at DEBUG level, and headers at TRACE level. + * Both may contain sensitive information. + */ + boolean isEnableLoggingRequestDetails(); } } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java index 31b3784a3fca..325c407e5e3d 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; import org.springframework.core.ResolvableType; import org.springframework.core.codec.Decoder; @@ -39,6 +40,8 @@ */ abstract class BaseCodecConfigurer implements CodecConfigurer { + protected boolean customCodecsInitialized; + protected final BaseDefaultCodecs defaultCodecs; protected final DefaultCustomCodecs customCodecs; @@ -88,6 +91,7 @@ public CustomCodecs customCodecs() { @Override public List> getReaders() { + initializeCustomCodecs(); List> result = new ArrayList<>(); result.addAll(this.customCodecs.getTypedReaders()); @@ -113,6 +117,7 @@ public List> getWriters() { * same except for the multipart writer itself. */ protected List> getWritersInternal(boolean forMultipart) { + initializeCustomCodecs(); List> result = new ArrayList<>(); result.addAll(this.customCodecs.getTypedWriters()); @@ -128,6 +133,13 @@ protected List> getWritersInternal(boolean forMultipart) { @Override public abstract CodecConfigurer clone(); + private void initializeCustomCodecs() { + if(!this.customCodecsInitialized) { + this.customCodecs.configConsumers.forEach(consumer -> consumer.accept(this.defaultCodecs)); + this.customCodecsInitialized = true; + } + } + /** * Default implementation of {@code CustomCodecs}. @@ -142,6 +154,7 @@ protected static final class DefaultCustomCodecs implements CustomCodecs { private final List> objectWriters = new ArrayList<>(); + private final List> configConsumers = new ArrayList<>(); DefaultCustomCodecs() { } @@ -179,6 +192,11 @@ public void writer(HttpMessageWriter writer) { (canWriteObject ? this.objectWriters : this.typedWriters).add(writer); } + @Override + public void withDefaultCodecConfig(Consumer codecsConfigConsumer) { + this.configConsumers.add(codecsConfigConsumer); + } + // Package private accessors... List> getTypedReaders() { diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java index ec38c10a29a3..c3a7fa385912 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java @@ -60,7 +60,7 @@ * @author Rossen Stoyanchev * @author Sebastien Deleuze */ -class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs { +class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigurer.DefaultCodecConfig { static final boolean jackson2Present; @@ -159,8 +159,9 @@ public void maxInMemorySize(int byteCount) { this.maxInMemorySize = byteCount; } + @Override @Nullable - protected Integer maxInMemorySize() { + public Integer maxInMemorySize() { return this.maxInMemorySize; } @@ -169,7 +170,8 @@ public void enableLoggingRequestDetails(boolean enable) { this.enableLoggingRequestDetails = enable; } - protected boolean isEnableLoggingRequestDetails() { + @Override + public boolean isEnableLoggingRequestDetails() { return this.enableLoggingRequestDetails; } diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index cff1be3b71a3..4c501f1d71f7 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -950,7 +950,7 @@ The following example shows how to do so for client-side requests: configurer.defaultCodecs().enableLoggingRequestDetails(true); WebClient webClient = WebClient.builder() - .exchangeStrategies(ExchangeStrategies.builder().codecs(consumer).build()) + .exchangeStrategies(strategies -> strategies.codecs(consumer)) .build(); ---- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] @@ -959,12 +959,53 @@ The following example shows how to do so for client-side requests: val consumer: (ClientCodecConfigurer) -> Unit = { configurer -> configurer.defaultCodecs().enableLoggingRequestDetails(true) } val webClient = WebClient.builder() - .exchangeStrategies(ExchangeStrategies.builder().codecs(consumer).build()) + .exchangeStrategies({ strategies -> strategies.codecs(consumer) }) .build() ---- +[[webflux-codecs-custom]] +==== Custom codecs +Applications can register custom codecs for supporting additional media types, +or specific behaviors that are not supported by the default codecs. +Some configuration options expressed by developers are enforced on default codecs. +Custom codecs might want to get a chance to align with those preferences, +like <> +or <>. + +The following example shows how to do so for client-side requests: + +[source,java,indent=0,subs="verbatim,quotes",role="primary"] +.Java +---- + Consumer consumer = configurer -> { + CustomDecoder customDecoder = new CustomDecoder(); + configurer.customCodecs().decoder(customDecoder); + configurer.customCodecs().withDefaultCodecConfig(config -> + customDecoder.maxInMemorySize(config.maxInMemorySize()) + ); + } + + WebClient webClient = WebClient.builder() + .exchangeStrategies(strategies -> strategies.codecs(consumer)) + .build(); +---- +[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] +.Kotlin +---- + val consumer: (ClientCodecConfigurer) -> Unit = { configurer -> + val customDecoder = CustomDecoder() + configurer.customCodecs().decoder(customDecoder) + configurer.customCodecs().withDefaultCodecConfig({ config -> + customDecoder.maxInMemorySize(config.maxInMemorySize()) + }) + } + + val webClient = WebClient.builder() + .exchangeStrategies({ strategies -> strategies.codecs(consumer) }) + .build() +---- [[webflux-dispatcher-handler]] == `DispatcherHandler` From 21053780efb0db61193b4f6ca5bc3390ff4bc322 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 2 Dec 2019 23:13:44 +0100 Subject: [PATCH 0158/2315] Polish --- .../http/codec/support/CodecConfigurerTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java index 1d66e933d8c3..938c225178a3 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java @@ -17,6 +17,7 @@ package org.springframework.http.codec.support; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -336,6 +337,18 @@ public void cloneDefaultCodecs() { assertThat(encoders).doesNotContain(jacksonEncoder, jaxb2Encoder, protoEncoder); } + @Test + void withDefaultCodecConfig() { + AtomicBoolean callbackCalled = new AtomicBoolean(false); + this.configurer.defaultCodecs().enableLoggingRequestDetails(true); + this.configurer.customCodecs().withDefaultCodecConfig(config -> { + assertThat(config.isEnableLoggingRequestDetails()).isTrue(); + callbackCalled.compareAndSet(false, true); + }); + this.configurer.getReaders(); + assertThat(callbackCalled).isTrue(); + } + private Decoder getNextDecoder(List> readers) { HttpMessageReader reader = readers.get(this.index.getAndIncrement()); assertThat(reader.getClass()).isEqualTo(DecoderHttpMessageReader.class); From 1bff7ce1418807d1f75daa9025fabfe4d4203bb9 Mon Sep 17 00:00:00 2001 From: Spring Buildmaster Date: Tue, 3 Dec 2019 08:59:24 +0000 Subject: [PATCH 0159/2315] Next Development Version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index c7a95ea35442..ba11054b2e55 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=5.2.2.BUILD-SNAPSHOT +version=5.2.3.BUILD-SNAPSHOT org.gradle.jvmargs=-Xmx1536M org.gradle.caching=true org.gradle.parallel=true From 6f15f32be3c5dcface3a9f4f5c58b0abe98e5071 Mon Sep 17 00:00:00 2001 From: wanxiangming1994 Date: Sun, 1 Dec 2019 20:22:41 +0800 Subject: [PATCH 0160/2315] Honor default values for implicit aliases in composed annotations Spring Framework 5.2 introduced a regression for implicit aliases declared via @AliasFor. Specifically, Spring's merged annotation algorithms stopped honoring default values for implicit alias pairs if the composed annotation was used without specifying the aliased attributes. This commit fixes this regression. Closes gh-24110 --- .../core/annotation/AnnotationTypeMapping.java | 3 +++ .../core/annotation/AnnotationTypeMappingsTests.java | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java index c865b0a222b6..bab16eaeda63 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java @@ -646,6 +646,9 @@ int resolve(@Nullable Object source, @Nullable A annotation, boolean isDefaultValue = (value == null || isEquivalentToDefaultValue(attribute, value, valueExtractor)); if (isDefaultValue || ObjectUtils.nullSafeEquals(lastValue, value)) { + if (result == -1) { + result = this.indexes[i]; + } continue; } if (lastValue != null && !ObjectUtils.nullSafeEquals(lastValue, value)) { diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java index fd3f12b7cc15..c90fd3012bf5 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java @@ -368,13 +368,13 @@ void resolveMirrorsWhenHasSameValuesUsesFirst() { } @Test - void resolveMirrorsWhenOnlyHasDefaultValuesResolvesNone() { + void resolveMirrorsWhenOnlyHasDefaultValuesUsesFirst() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( AliasPair.class).get(0); Method[] resolved = resolveMirrorSets(mapping, WithDefaultValueAliasPair.class, AliasPair.class); - assertThat(resolved[0]).isNull(); - assertThat(resolved[1]).isNull(); + assertThat(resolved[0].getName()).isEqualTo("a"); + assertThat(resolved[1].getName()).isEqualTo("a"); } @Test From fb13f6f0bc300ac8001d5cfc53b89f6136be0569 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 3 Dec 2019 16:48:30 +0100 Subject: [PATCH 0161/2315] Add integration test for gh-24110 --- .../AnnotatedElementUtilsTests.java | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java index 650078d10591..1b1bc2b0f98e 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java @@ -516,6 +516,20 @@ void getMergedAnnotationWithImplicitAliasesInMetaAnnotationOnComposedAnnotation( assertThat(isAnnotated(element, name)).isTrue(); } + @Test + void getMergedAnnotationWithImplicitAliasesWithDefaultsInMetaAnnotationOnComposedAnnotation() { + Class element = ImplicitAliasesWithDefaultsClass.class; + String name = AliasesWithDefaults.class.getName(); + AliasesWithDefaults annotation = getMergedAnnotation(element, AliasesWithDefaults.class); + + assertThat(annotation).as("Should find @AliasesWithDefaults on " + element.getSimpleName()).isNotNull(); + assertThat(annotation.a1()).as("a1").isEqualTo("ImplicitAliasesWithDefaults"); + assertThat(annotation.a2()).as("a2").isEqualTo("ImplicitAliasesWithDefaults"); + + // Verify contracts between utility methods: + assertThat(isAnnotated(element, name)).isTrue(); + } + @Test void getMergedAnnotationAttributesWithInvalidConventionBasedComposedAnnotation() { Class element = InvalidConventionBasedComposedContextConfigClass.class; @@ -1064,7 +1078,6 @@ static class MetaCycleAnnotatedClass { String[] xmlConfigFiles() default {}; } - @ContextConfig @Retention(RetentionPolicy.RUNTIME) @interface AliasedComposedContextConfig { @@ -1105,6 +1118,27 @@ static class MetaCycleAnnotatedClass { @interface ComposedImplicitAliasesContextConfig { } + @Retention(RetentionPolicy.RUNTIME) + @interface AliasesWithDefaults { + + @AliasFor("a2") + String a1() default "AliasesWithDefaults"; + + @AliasFor("a1") + String a2() default "AliasesWithDefaults"; + } + + @Retention(RetentionPolicy.RUNTIME) + @AliasesWithDefaults + @interface ImplicitAliasesWithDefaults { + + @AliasFor(annotation = AliasesWithDefaults.class, attribute = "a1") + String b1() default "ImplicitAliasesWithDefaults"; + + @AliasFor(annotation = AliasesWithDefaults.class, attribute = "a2") + String b2() default "ImplicitAliasesWithDefaults"; + } + @ImplicitAliasesContextConfig @Retention(RetentionPolicy.RUNTIME) @interface TransitiveImplicitAliasesContextConfig { @@ -1410,6 +1444,10 @@ static class ImplicitAliasesContextConfigClass2 { static class ImplicitAliasesContextConfigClass3 { } + @ImplicitAliasesWithDefaults + static class ImplicitAliasesWithDefaultsClass { + } + @TransitiveImplicitAliasesContextConfig(groovy = "test.groovy") static class TransitiveImplicitAliasesContextConfigClass { } From 797f618f2b2e96bc0bc38028cd7126f0a0234391 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 4 Dec 2019 16:14:14 +0000 Subject: [PATCH 0162/2315] Remove mismatched marker in core-beans.adoc Closes gh-24132 --- src/docs/asciidoc/core/core-beans.adoc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc index 29e7f9d26450..d434ac95de15 100644 --- a/src/docs/asciidoc/core/core-beans.adoc +++ b/src/docs/asciidoc/core/core-beans.adoc @@ -5400,7 +5400,6 @@ The following example shows corresponding bean definitions. is qualified with the same value. <2> The bean with the `action` qualifier value is wired with the constructor argument that is qualified with the same value. -==== For a fallback match, the bean name is considered a default qualifier value. Thus, you can define the bean with an `id` of `main` instead of the nested qualifier element, leading From b866d4209cf21b41c69619d846f30beb2bbb1c72 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 4 Dec 2019 17:33:31 +0000 Subject: [PATCH 0163/2315] Add UriUtils.encodeQueryParams Closes gh-24043 --- .../springframework/web/util/UriUtils.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/util/UriUtils.java b/spring-web/src/main/java/org/springframework/web/util/UriUtils.java index c2d5d29ba843..ca2b9a0a25a4 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriUtils.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -21,9 +21,12 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import org.springframework.lang.Nullable; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; /** @@ -225,7 +228,6 @@ public static String encodeQuery(String query, Charset charset) { * @return the encoded query parameter */ public static String encodeQueryParam(String queryParam, String encoding) { - return encode(queryParam, encoding, HierarchicalUriComponents.Type.QUERY_PARAM); } @@ -240,6 +242,34 @@ public static String encodeQueryParam(String queryParam, Charset charset) { return encode(queryParam, charset, HierarchicalUriComponents.Type.QUERY_PARAM); } + /** + * Encode the query parameters from the given {@code MultiValueMap} with UTF-8. + *

This can be used with {@link UriComponentsBuilder#queryParams(MultiValueMap)} + * when building a URI from an already encoded template. + *

+	 * MultiValueMap<String, String> params = new LinkedMultiValueMap<>(2);
+	 * // add to params...
+	 *
+	 * ServletUriComponentsBuilder.fromCurrentRequest()
+	 *         .queryParams(UriUtils.encodeQueryParams(params))
+	 *         .build(true)
+	 *         .toUriString();
+	 * 
+ * @param params the parameters to encode + * @return a new {@code MultiValueMap} with the encoded names and values + * @since 5.2.3 + */ + public static MultiValueMap encodeQueryParams(MultiValueMap params) { + Charset charset = StandardCharsets.UTF_8; + MultiValueMap result = new LinkedMultiValueMap<>(params.size()); + for (Map.Entry> entry : params.entrySet()) { + for (String value : entry.getValue()) { + result.add(encodeQueryParam(entry.getKey(), charset), encodeQueryParam(value, charset)); + } + } + return result; + } + /** * Encode the given URI fragment with the given encoding. * @param fragment the fragment to be encoded From 3a48682226615aaea3b63755c25763877c35dfd8 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 4 Dec 2019 18:17:46 +0000 Subject: [PATCH 0164/2315] Replace ReadCancellationException with takeWhile Closes gh-24125 --- .../web/reactive/function/BodyExtractors.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyExtractors.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyExtractors.java index 391a5fbf90dd..5dd63b72efb2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyExtractors.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyExtractors.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -264,18 +264,11 @@ private static Supplier> skipBodyAsMono(ReactiveHttpInputMessage mes () -> consumeAndCancel(message).then(Mono.empty()) : Mono::empty; } - private static Mono consumeAndCancel(ReactiveHttpInputMessage message) { - return message.getBody() - .map(buffer -> { - DataBufferUtils.release(buffer); - throw new ReadCancellationException(); - }) - .onErrorResume(ReadCancellationException.class, ex -> Mono.empty()) - .then(); - } - - @SuppressWarnings("serial") - private static class ReadCancellationException extends RuntimeException { + private static Flux consumeAndCancel(ReactiveHttpInputMessage message) { + return message.getBody().takeWhile(buffer -> { + DataBufferUtils.release(buffer); + return false; + }); } } From 828fe395231fc2e7284769ac7c0250af66b15815 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 4 Dec 2019 18:19:18 +0000 Subject: [PATCH 0165/2315] Consistently use releaseBody in DefaultWebClient See gh-24125 --- .../function/client/ClientResponse.java | 8 +++++--- .../function/client/DefaultWebClient.java | 2 +- .../web/reactive/function/client/WebClient.java | 12 +++++++++--- src/docs/asciidoc/web/webflux-webclient.adoc | 17 ++++++----------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java index cb7c9cd07539..5c6eaa0cf196 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java @@ -62,9 +62,11 @@ *
  • {@link #toBodilessEntity()}
  • *
  • {@link #releaseBody()}
  • * - * You can use {@code bodyToMono(Void.class)} if no response content is - * expected. However keep in mind that if the response does have content, the - * connection will be closed and will not be placed back in the pool. + * You can also use {@code bodyToMono(Void.class)} if no response content is + * expected. However keep in mind the connection will be closed, instead of + * being placed back in the pool, if any content does arrive. This is in + * contrast to {@link #releaseBody()} which does consume the full body and + * releases any content received. * * @author Brian Clozel * @author Arjen Poutsma diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java index 866ba6e89095..587c335dcb44 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java @@ -532,7 +532,7 @@ private Mono statusHandlers(ClientResponse response) { private Mono drainBody(ClientResponse response, Throwable ex) { // Ensure the body is drained, even if the StatusHandler didn't consume it, // but ignore exception, in case the handler did consume. - return (Mono) response.bodyToMono(Void.class) + return (Mono) response.releaseBody() .onErrorResume(ex2 -> Mono.empty()).thenReturn(ex); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java index 93951bbb966c..8bafb691fe7d 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java @@ -498,9 +498,15 @@ interface RequestHeadersSpec> { * .exchange() * .flatMapMany(response -> response.bodyToFlux(Person.class)); * - *

    NOTE: You must always use one of the body or - * entity methods of the response to ensure resources are released. - * See {@link ClientResponse} for more details. + *

    NOTE: Unlike {@link #retrieve()}, when using + * {@code exchange()}, it is the responsibility of the application to + * consume any response content regardless of the scenario (success, + * error, unexpected data, etc). Not doing so can cause a memory leak. + * See {@link ClientResponse} for a list of all the available options + * for consuming the body. Generally prefer using {@link #retrieve()} + * unless you have a good reason to use {@code exchange()} which does + * allow to check the response status and headers before deciding how or + * if to consume the response. * @return a {@code Mono} for the response * @see #retrieve() */ diff --git a/src/docs/asciidoc/web/webflux-webclient.adoc b/src/docs/asciidoc/web/webflux-webclient.adoc index 372255fcaf4b..2121f23c7e1a 100644 --- a/src/docs/asciidoc/web/webflux-webclient.adoc +++ b/src/docs/asciidoc/web/webflux-webclient.adoc @@ -496,17 +496,12 @@ Note that (unlike `retrieve()`), with `exchange()`, there are no automatic error [CAUTION] ==== -When using `exchange()`, you have to make sure that the body is always consumed or released, -even when an exception occurs (see <>). -Typically, you do this by invoking either `bodyTo*` or `toEntity*` on `ClientResponse` -to convert the body into an object of the desired type, but -you can also invoke `releaseBody()` to discard the body contents without consuming it or -`toBodilessEntity()` to get just the status and headers (while discarding the body). - -Finally, there is `bodyToMono(Void.class)`, which should only be used if no response content is -expected. -If the response does have content, the connection is closed and is not placed back in the pool, -because it is not left in a reusable state. +Unlike `retrieve()`, when using `exchange(), it is the responsibility of the application +to consume any response content regardless of the scenario (success, error, unexpected +data, etc). Not doing so can cause a memory leak. The Javadoc for `ClientResponse` lists +all the available options for consuming the body. Generally prefer using `retrieve()` +unless you have a good reason for using `exchange()` which does allow to check the +response status and headers before deciding how to or if to consume the response. ==== From 14ce84cebbc8d64a5047e4287166d03ce101de8f Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 5 Dec 2019 13:00:44 +0900 Subject: [PATCH 0166/2315] Fix status code in webflux.adoc --- src/docs/asciidoc/web/webflux.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index 4c501f1d71f7..b6e03ff12844 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -3612,7 +3612,7 @@ as the following example shows: There are three variants for checking conditional requests against `eTag` values, `lastModified` values, or both. For conditional `GET` and `HEAD` requests, you can set the response to 304 (NOT_MODIFIED). For conditional `POST`, `PUT`, and `DELETE`, you can instead set the response -to 409 (PRECONDITION_FAILED) to prevent concurrent modification. +to 412 (PRECONDITION_FAILED) to prevent concurrent modification. From d503bc2804b7bdbb9e9c46081a7fa454ac81c8d7 Mon Sep 17 00:00:00 2001 From: Vitalii Rastvorov Date: Wed, 4 Dec 2019 18:18:46 +0200 Subject: [PATCH 0167/2315] Add firstElement to CollectionUtils --- .../springframework/util/CollectionUtils.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java index 79798b9f5448..79f5185796e1 100644 --- a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java @@ -355,6 +355,45 @@ public static T lastElement(@Nullable List list) { return list.get(list.size() - 1); } + /** + * Retrieve the first element of the given Set, using {@link SortedSet#first()} + * or otherwise using the iterator. + * @param set the Set to check (may be {@code null} or empty) + * @return the first element, or {@code null} if none + * @see SortedSet + * @see LinkedHashMap#keySet() + * @see java.util.LinkedHashSet + */ + @Nullable + public static T firstElement(@Nullable Set set) { + if (isEmpty(set)) { + return null; + } + if (set instanceof SortedSet) { + return ((SortedSet) set).first(); + } + + Iterator it = set.iterator(); + T first = null; + if (it.hasNext()) { + first = it.next(); + } + return first; + } + + /** + * Retrieve the first element of the given List, accessing the zero index. + * @param list the List to check (may be {@code null} or empty) + * @return the first element, or {@code null} if none + */ + @Nullable + public static T firstElement(@Nullable List list) { + if (isEmpty(list)) { + return null; + } + return list.get(0); + } + /** * Marshal the elements from the given enumeration into an array of the given type. * Enumeration elements must be assignable to the type of the given array. The array From c2141e2e9323f09ef42f2af92458c2d7bb9b424b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 5 Dec 2019 16:36:55 +0100 Subject: [PATCH 0168/2315] Add @since tags to firstElement methods --- .../springframework/util/CollectionUtils.java | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java index 79f5185796e1..84b1fd1c67ff 100644 --- a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java @@ -314,84 +314,86 @@ else if (candidate != val.getClass()) { } /** - * Retrieve the last element of the given Set, using {@link SortedSet#last()} - * or otherwise iterating over all elements (assuming a linked set). + * Retrieve the first element of the given Set, using {@link SortedSet#first()} + * or otherwise using the iterator. * @param set the Set to check (may be {@code null} or empty) - * @return the last element, or {@code null} if none - * @since 5.0.3 + * @return the first element, or {@code null} if none + * @since 5.2.3 * @see SortedSet * @see LinkedHashMap#keySet() * @see java.util.LinkedHashSet */ @Nullable - public static T lastElement(@Nullable Set set) { + public static T firstElement(@Nullable Set set) { if (isEmpty(set)) { return null; } if (set instanceof SortedSet) { - return ((SortedSet) set).last(); + return ((SortedSet) set).first(); } - // Full iteration necessary... Iterator it = set.iterator(); - T last = null; - while (it.hasNext()) { - last = it.next(); + T first = null; + if (it.hasNext()) { + first = it.next(); } - return last; + return first; } /** - * Retrieve the last element of the given List, accessing the highest index. + * Retrieve the first element of the given List, accessing the zero index. * @param list the List to check (may be {@code null} or empty) - * @return the last element, or {@code null} if none - * @since 5.0.3 + * @return the first element, or {@code null} if none + * @since 5.2.3 */ @Nullable - public static T lastElement(@Nullable List list) { + public static T firstElement(@Nullable List list) { if (isEmpty(list)) { return null; } - return list.get(list.size() - 1); + return list.get(0); } /** - * Retrieve the first element of the given Set, using {@link SortedSet#first()} - * or otherwise using the iterator. + * Retrieve the last element of the given Set, using {@link SortedSet#last()} + * or otherwise iterating over all elements (assuming a linked set). * @param set the Set to check (may be {@code null} or empty) - * @return the first element, or {@code null} if none + * @return the last element, or {@code null} if none + * @since 5.0.3 * @see SortedSet * @see LinkedHashMap#keySet() * @see java.util.LinkedHashSet */ @Nullable - public static T firstElement(@Nullable Set set) { + public static T lastElement(@Nullable Set set) { if (isEmpty(set)) { return null; } if (set instanceof SortedSet) { - return ((SortedSet) set).first(); + return ((SortedSet) set).last(); } + // Full iteration necessary... Iterator it = set.iterator(); - T first = null; - if (it.hasNext()) { - first = it.next(); + T last = null; + while (it.hasNext()) { + last = it.next(); } - return first; + return last; } /** - * Retrieve the first element of the given List, accessing the zero index. + * Retrieve the last element of the given List, accessing the highest index. * @param list the List to check (may be {@code null} or empty) - * @return the first element, or {@code null} if none + * @return the last element, or {@code null} if none + * @since 5.0.3 */ @Nullable - public static T firstElement(@Nullable List list) { + public static T lastElement(@Nullable List list) { if (isEmpty(list)) { return null; } - return list.get(0); + return list.get(list.size() - 1); } /** From 3b9d1a00b08f15d8852bb867b68b3a9f14e70a63 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 5 Dec 2019 22:37:00 +0100 Subject: [PATCH 0169/2315] Polishing --- .../core/type/StandardAnnotationMetadata.java | 3 +- .../SimpleAnnotationMetadata.java | 2 - .../type/AbstractAnnotationMetadataTests.java | 139 ++++++------------ 3 files changed, 46 insertions(+), 98 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java b/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java index b7dbbdab517f..c99c72a6f62a 100644 --- a/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java @@ -100,8 +100,7 @@ public MergedAnnotations getAnnotations() { public Set getAnnotationTypes() { Set annotationTypes = this.annotationTypes; if (annotationTypes == null) { - annotationTypes = Collections.unmodifiableSet( - AnnotationMetadata.super.getAnnotationTypes()); + annotationTypes = Collections.unmodifiableSet(AnnotationMetadata.super.getAnnotationTypes()); this.annotationTypes = annotationTypes; } return annotationTypes; diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadata.java b/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadata.java index 340eecb6c6fc..f19399df8be9 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadata.java @@ -156,6 +156,4 @@ public MergedAnnotations getAnnotations() { return this.annotations; } - - } diff --git a/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java index 0f088c0f6ce0..583787b9dbc8 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java @@ -38,8 +38,7 @@ public abstract class AbstractAnnotationMetadataTests { @Test public void getClassNameReturnsClassName() { - assertThat(get(TestClass.class).getClassName()).isEqualTo( - TestClass.class.getName()); + assertThat(get(TestClass.class).getClassName()).isEqualTo(TestClass.class.getName()); } @Test @@ -93,16 +92,13 @@ public void getEnclosingClassNameWhenHasEnclosingClassReturnsEnclosingClass() { @Test public void getEnclosingClassNameWhenHasNoEnclosingClassReturnsNull() { - assertThat(get( - AbstractAnnotationMetadataTests.class).getEnclosingClassName()).isNull(); + assertThat(get(AbstractAnnotationMetadataTests.class).getEnclosingClassName()).isNull(); } @Test public void getSuperClassNameWhenHasSuperClassReturnsName() { - assertThat(get(TestSubclass.class).getSuperClassName()).isEqualTo( - TestClass.class.getName()); - assertThat(get(TestClass.class).getSuperClassName()).isEqualTo( - Object.class.getName()); + assertThat(get(TestSubclass.class).getSuperClassName()).isEqualTo(TestClass.class.getName()); + assertThat(get(TestClass.class).getSuperClassName()).isEqualTo(Object.class.getName()); } @Test @@ -114,11 +110,8 @@ public void getSuperClassNameWhenHasNoSuperClassReturnsNull() { @Test public void getInterfaceNamesWhenHasInterfacesReturnsNames() { - assertThat(get(TestSubclass.class).getInterfaceNames()).containsExactlyInAnyOrder( - TestInterface.class.getName()); - assertThat(get( - TestSubInterface.class).getInterfaceNames()).containsExactlyInAnyOrder( - TestInterface.class.getName()); + assertThat(get(TestSubclass.class).getInterfaceNames()).containsExactlyInAnyOrder(TestInterface.class.getName()); + assertThat(get(TestSubInterface.class).getInterfaceNames()).containsExactlyInAnyOrder(TestInterface.class.getName()); } @Test @@ -128,10 +121,8 @@ public void getInterfaceNamesWhenHasNoInterfacesReturnsEmptyArray() { @Test public void getMemberClassNamesWhenHasMemberClassesReturnsNames() { - assertThat(get( - TestMemberClass.class).getMemberClassNames()).containsExactlyInAnyOrder( - TestMemberClassInnerClass.class.getName(), - TestMemberClassInnerInterface.class.getName()); + assertThat(get(TestMemberClass.class).getMemberClassNames()).containsExactlyInAnyOrder( + TestMemberClassInnerClass.class.getName(), TestMemberClassInnerInterface.class.getName()); } @Test @@ -141,44 +132,37 @@ public void getMemberClassNamesWhenHasNoMemberClassesReturnsEmptyArray() { @Test public void getAnnotationsReturnsDirectAnnotations() { - AnnotationMetadata metadata = get(WithDirectAnnotations.class); - assertThat(metadata.getAnnotations().stream().filter( - MergedAnnotation::isDirectlyPresent).map( - a -> a.getType().getName())).containsExactlyInAnyOrder( - DirectAnnotation1.class.getName(), - DirectAnnotation2.class.getName()); + assertThat(get(WithDirectAnnotations.class).getAnnotations().stream()) + .filteredOn(MergedAnnotation::isDirectlyPresent) + .extracting(a -> a.getType().getName()) + .containsExactlyInAnyOrder(DirectAnnotation1.class.getName(), DirectAnnotation2.class.getName()); } @Test public void isAnnotatedWhenMatchesDirectAnnotationReturnsTrue() { - assertThat(get(WithDirectAnnotations.class).isAnnotated( - DirectAnnotation1.class.getName())).isTrue(); + assertThat(get(WithDirectAnnotations.class).isAnnotated(DirectAnnotation1.class.getName())).isTrue(); } @Test public void isAnnotatedWhenMatchesMetaAnnotationReturnsTrue() { - assertThat(get(WithMetaAnnotations.class).isAnnotated( - MetaAnnotation2.class.getName())).isTrue(); + assertThat(get(WithMetaAnnotations.class).isAnnotated(MetaAnnotation2.class.getName())).isTrue(); } @Test public void isAnnotatedWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() { - assertThat(get(TestClass.class).isAnnotated( - DirectAnnotation1.class.getName())).isFalse(); + assertThat(get(TestClass.class).isAnnotated(DirectAnnotation1.class.getName())).isFalse(); } @Test public void getAnnotationAttributesReturnsAttributes() { - assertThat(get(WithAnnotationAttributes.class).getAnnotationAttributes( - AnnotationAttributes.class.getName())).containsOnly(entry("name", "test"), - entry("size", 1)); + assertThat(get(WithAnnotationAttributes.class).getAnnotationAttributes(AnnotationAttributes.class.getName())) + .containsOnly(entry("name", "test"), entry("size", 1)); } @Test public void getAllAnnotationAttributesReturnsAllAttributes() { - MultiValueMap attributes = get( - WithMetaAnnotationAttributes.class).getAllAnnotationAttributes( - AnnotationAttributes.class.getName()); + MultiValueMap attributes = + get(WithMetaAnnotationAttributes.class).getAllAnnotationAttributes(AnnotationAttributes.class.getName()); assertThat(attributes).containsOnlyKeys("name", "size"); assertThat(attributes.get("name")).containsExactlyInAnyOrder("m1", "m2"); assertThat(attributes.get("size")).containsExactlyInAnyOrder(1, 2); @@ -194,155 +178,126 @@ public void getAnnotationTypesReturnsDirectAnnotations() { @Test public void getMetaAnnotationTypesReturnsMetaAnnotations() { AnnotationMetadata metadata = get(WithMetaAnnotations.class); - assertThat(metadata.getMetaAnnotationTypes( - MetaAnnotationRoot.class.getName())).containsExactlyInAnyOrder( - MetaAnnotation1.class.getName(), MetaAnnotation2.class.getName()); + assertThat(metadata.getMetaAnnotationTypes(MetaAnnotationRoot.class.getName())) + .containsExactlyInAnyOrder(MetaAnnotation1.class.getName(), MetaAnnotation2.class.getName()); } @Test public void hasAnnotationWhenMatchesDirectAnnotationReturnsTrue() { - assertThat(get(WithDirectAnnotations.class).hasAnnotation( - DirectAnnotation1.class.getName())).isTrue(); + assertThat(get(WithDirectAnnotations.class).hasAnnotation(DirectAnnotation1.class.getName())).isTrue(); } @Test public void hasAnnotationWhenMatchesMetaAnnotationReturnsFalse() { - assertThat(get(WithMetaAnnotations.class).hasAnnotation( - MetaAnnotation1.class.getName())).isFalse(); - assertThat(get(WithMetaAnnotations.class).hasAnnotation( - MetaAnnotation2.class.getName())).isFalse(); + assertThat(get(WithMetaAnnotations.class).hasAnnotation(MetaAnnotation1.class.getName())).isFalse(); + assertThat(get(WithMetaAnnotations.class).hasAnnotation(MetaAnnotation2.class.getName())).isFalse(); } @Test public void hasAnnotationWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() { - assertThat(get(TestClass.class).hasAnnotation( - DirectAnnotation1.class.getName())).isFalse(); + assertThat(get(TestClass.class).hasAnnotation(DirectAnnotation1.class.getName())).isFalse(); } @Test public void hasMetaAnnotationWhenMatchesDirectReturnsFalse() { - assertThat(get(WithDirectAnnotations.class).hasMetaAnnotation( - DirectAnnotation1.class.getName())).isFalse(); + assertThat(get(WithDirectAnnotations.class).hasMetaAnnotation(DirectAnnotation1.class.getName())).isFalse(); } @Test public void hasMetaAnnotationWhenMatchesMetaAnnotationReturnsTrue() { - assertThat(get(WithMetaAnnotations.class).hasMetaAnnotation( - MetaAnnotation1.class.getName())).isTrue(); - assertThat(get(WithMetaAnnotations.class).hasMetaAnnotation( - MetaAnnotation2.class.getName())).isTrue(); + assertThat(get(WithMetaAnnotations.class).hasMetaAnnotation(MetaAnnotation1.class.getName())).isTrue(); + assertThat(get(WithMetaAnnotations.class).hasMetaAnnotation(MetaAnnotation2.class.getName())).isTrue(); } @Test public void hasMetaAnnotationWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() { - assertThat(get(TestClass.class).hasMetaAnnotation( - MetaAnnotation1.class.getName())).isFalse(); + assertThat(get(TestClass.class).hasMetaAnnotation(MetaAnnotation1.class.getName())).isFalse(); } @Test public void hasAnnotatedMethodsWhenMatchesDirectAnnotationReturnsTrue() { - assertThat(get(WithAnnotatedMethod.class).hasAnnotatedMethods( - DirectAnnotation1.class.getName())).isTrue(); + assertThat(get(WithAnnotatedMethod.class).hasAnnotatedMethods(DirectAnnotation1.class.getName())).isTrue(); } @Test public void hasAnnotatedMethodsWhenMatchesMetaAnnotationReturnsTrue() { - assertThat(get(WithMetaAnnotatedMethod.class).hasAnnotatedMethods( - MetaAnnotation2.class.getName())).isTrue(); + assertThat(get(WithMetaAnnotatedMethod.class).hasAnnotatedMethods(MetaAnnotation2.class.getName())).isTrue(); } @Test public void hasAnnotatedMethodsWhenDoesNotMatchAnyAnnotationReturnsFalse() { - assertThat(get(WithAnnotatedMethod.class).hasAnnotatedMethods( - MetaAnnotation2.class.getName())).isFalse(); - assertThat(get(WithNonAnnotatedMethod.class).hasAnnotatedMethods( - DirectAnnotation1.class.getName())).isFalse(); + assertThat(get(WithAnnotatedMethod.class).hasAnnotatedMethods(MetaAnnotation2.class.getName())).isFalse(); + assertThat(get(WithNonAnnotatedMethod.class).hasAnnotatedMethods(DirectAnnotation1.class.getName())).isFalse(); } @Test public void getAnnotatedMethodsReturnsMatchingAnnotatedAndMetaAnnotatedMethods() { - assertThat(get(WithDirectAndMetaAnnotatedMethods.class).getAnnotatedMethods( - MetaAnnotation2.class.getName()).stream().map( - MethodMetadata::getMethodName)).containsExactlyInAnyOrder( - "direct", "meta"); + assertThat(get(WithDirectAndMetaAnnotatedMethods.class).getAnnotatedMethods(MetaAnnotation2.class.getName())) + .extracting(MethodMetadata::getMethodName) + .containsExactlyInAnyOrder("direct", "meta"); } protected abstract AnnotationMetadata get(Class source); - @Retention(RetentionPolicy.RUNTIME) - public static @interface DirectAnnotation1 { + @Retention(RetentionPolicy.RUNTIME) + public @interface DirectAnnotation1 { } @Retention(RetentionPolicy.RUNTIME) - public static @interface DirectAnnotation2 { - + public @interface DirectAnnotation2 { } @Retention(RetentionPolicy.RUNTIME) @MetaAnnotation1 - public static @interface MetaAnnotationRoot { - + public @interface MetaAnnotationRoot { } @Retention(RetentionPolicy.RUNTIME) @MetaAnnotation2 - public static @interface MetaAnnotation1 { - + public @interface MetaAnnotation1 { } @Retention(RetentionPolicy.RUNTIME) - public static @interface MetaAnnotation2 { - + public @interface MetaAnnotation2 { } public static class TestClass { - } public static interface TestInterface { - } public static interface TestSubInterface extends TestInterface { - } public @interface TestAnnotation { - } public static final class TestFinalClass { - } public class TestNonStaticInnerClass { - } public static class TestSubclass extends TestClass implements TestInterface { - } @DirectAnnotation1 @DirectAnnotation2 public static class WithDirectAnnotations { - } @MetaAnnotationRoot public static class WithMetaAnnotations { - } public static class TestMemberClass { public static class TestMemberClassInnerClass { - } interface TestMemberClassInnerInterface { - } } @@ -384,29 +339,25 @@ public void meta() { @AnnotationAttributes(name = "test", size = 1) public static class WithAnnotationAttributes { - } @MetaAnnotationAttributes1 @MetaAnnotationAttributes2 public static class WithMetaAnnotationAttributes { - } @Retention(RetentionPolicy.RUNTIME) @AnnotationAttributes(name = "m1", size = 1) - public static @interface MetaAnnotationAttributes1 { - + public @interface MetaAnnotationAttributes1 { } @Retention(RetentionPolicy.RUNTIME) @AnnotationAttributes(name = "m2", size = 2) - public static @interface MetaAnnotationAttributes2 { - + public @interface MetaAnnotationAttributes2 { } @Retention(RetentionPolicy.RUNTIME) - public static @interface AnnotationAttributes { + public @interface AnnotationAttributes { String name(); From a4fa6a7a3104a81e4db7d09691aad8ca54cc967b Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 5 Dec 2019 23:28:44 +0100 Subject: [PATCH 0170/2315] Test status quo for @Inherited annotation support in AnnotationMetadata --- .../core/type/AnnotationMetadataTests.java | 1 + ...tedAnnotationsAnnotationMetadataTests.java | 188 ++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 spring-core/src/test/java/org/springframework/core/type/InheritedAnnotationsAnnotationMetadataTests.java diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index f1f9ddbed5be..571440dfaa71 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -48,6 +48,7 @@ * @author Chris Beams * @author Phillip Webb * @author Sam Brannen + * @see InheritedAnnotationsAnnotationMetadataTests */ class AnnotationMetadataTests { diff --git a/spring-core/src/test/java/org/springframework/core/type/InheritedAnnotationsAnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/InheritedAnnotationsAnnotationMetadataTests.java new file mode 100644 index 000000000000..3255676c55aa --- /dev/null +++ b/spring-core/src/test/java/org/springframework/core/type/InheritedAnnotationsAnnotationMetadataTests.java @@ -0,0 +1,188 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.core.type; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.Map; +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import org.springframework.core.type.classreading.MetadataReader; +import org.springframework.core.type.classreading.MetadataReaderFactory; +import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; +import org.springframework.util.MultiValueMap; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Unit tests demonstrating that the reflection-based {@link StandardAnnotationMetadata} + * supports {@link Inherited @Inherited} annotations; whereas, the ASM-based + * {@code SimpleAnnotationMetadata} does not. + * + * @author Sam Brannen + * @since 5.2.3 + * @see AnnotationMetadataTests + */ +class InheritedAnnotationsAnnotationMetadataTests { + + private final AnnotationMetadata standardMetadata = AnnotationMetadata.introspect(AnnotatedSubclass.class); + + private final AnnotationMetadata asmMetadata; + + + InheritedAnnotationsAnnotationMetadataTests() throws Exception { + MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); + MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(AnnotatedSubclass.class.getName()); + this.asmMetadata = metadataReader.getAnnotationMetadata(); + } + + @Test + void getAnnotationTypes() { + assertThat(standardMetadata.getAnnotationTypes()).containsExactlyInAnyOrder( + NamedAnnotation3.class.getName(), + InheritedComposedAnnotation.class.getName()); + + assertThat(asmMetadata.getAnnotationTypes()).containsExactly( + NamedAnnotation3.class.getName()); + } + + @Test + void hasAnnotation() { + assertThat(standardMetadata.hasAnnotation(InheritedComposedAnnotation.class.getName())).isTrue(); + assertThat(standardMetadata.hasAnnotation(NamedAnnotation3.class.getName())).isTrue(); + + // true because @NamedAnnotation3 is also directly present + assertThat(asmMetadata.hasAnnotation(NamedAnnotation3.class.getName())).isTrue(); + + assertThat(asmMetadata.hasAnnotation(InheritedComposedAnnotation.class.getName())).isFalse(); + } + + @Test + void getMetaAnnotationTypes() { + Set metaAnnotationTypes; + + metaAnnotationTypes = standardMetadata.getMetaAnnotationTypes(InheritedComposedAnnotation.class.getName()); + assertThat(metaAnnotationTypes).containsExactlyInAnyOrder( + MetaAnnotation.class.getName(), + NamedAnnotation1.class.getName(), + NamedAnnotation2.class.getName(), + NamedAnnotation3.class.getName()); + + metaAnnotationTypes = asmMetadata.getMetaAnnotationTypes(InheritedComposedAnnotation.class.getName()); + assertThat(metaAnnotationTypes).isEmpty(); + } + + @Test + void hasMetaAnnotation() { + assertThat(standardMetadata.hasMetaAnnotation(NamedAnnotation1.class.getName())).isTrue(); + assertThat(standardMetadata.hasMetaAnnotation(NamedAnnotation2.class.getName())).isTrue(); + assertThat(standardMetadata.hasMetaAnnotation(NamedAnnotation3.class.getName())).isTrue(); + assertThat(standardMetadata.hasMetaAnnotation(MetaAnnotation.class.getName())).isTrue(); + + assertThat(asmMetadata.hasMetaAnnotation(NamedAnnotation1.class.getName())).isFalse(); + assertThat(asmMetadata.hasMetaAnnotation(NamedAnnotation2.class.getName())).isFalse(); + assertThat(asmMetadata.hasMetaAnnotation(NamedAnnotation3.class.getName())).isFalse(); + assertThat(asmMetadata.hasMetaAnnotation(MetaAnnotation.class.getName())).isFalse(); + } + + @Test + void isAnnotated() { + assertThat(standardMetadata.isAnnotated(InheritedComposedAnnotation.class.getName())).isTrue(); + assertThat(standardMetadata.isAnnotated(NamedAnnotation1.class.getName())).isTrue(); + assertThat(standardMetadata.isAnnotated(NamedAnnotation2.class.getName())).isTrue(); + assertThat(standardMetadata.isAnnotated(NamedAnnotation3.class.getName())).isTrue(); + assertThat(standardMetadata.isAnnotated(MetaAnnotation.class.getName())).isTrue(); + + // true because @NamedAnnotation3 is also directly present + assertThat(asmMetadata.isAnnotated(NamedAnnotation3.class.getName())).isTrue(); + + assertThat(asmMetadata.isAnnotated(InheritedComposedAnnotation.class.getName())).isFalse(); + assertThat(asmMetadata.isAnnotated(NamedAnnotation1.class.getName())).isFalse(); + assertThat(asmMetadata.isAnnotated(NamedAnnotation2.class.getName())).isFalse(); + assertThat(asmMetadata.isAnnotated(MetaAnnotation.class.getName())).isFalse(); + } + + @Test + void getAnnotationAttributes() { + Map annotationAttributes; + + annotationAttributes = standardMetadata.getAnnotationAttributes(NamedAnnotation1.class.getName()); + assertThat(annotationAttributes.get("name")).isEqualTo("name 1"); + + annotationAttributes = asmMetadata.getAnnotationAttributes(NamedAnnotation1.class.getName()); + assertThat(annotationAttributes).isNull(); + } + + @Test + void getAllAnnotationAttributes() { + MultiValueMap annotationAttributes; + + annotationAttributes = standardMetadata.getAllAnnotationAttributes(NamedAnnotation3.class.getName()); + assertThat(annotationAttributes).containsKey("name"); + assertThat(annotationAttributes.get("name")).containsExactlyInAnyOrder("name 3", "local"); + + annotationAttributes = asmMetadata.getAllAnnotationAttributes(NamedAnnotation1.class.getName()); + assertThat(annotationAttributes).isNull(); + } + + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.ANNOTATION_TYPE) + @interface MetaAnnotation { + } + + @MetaAnnotation + @Retention(RetentionPolicy.RUNTIME) + @interface NamedAnnotation1 { + + String name() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @interface NamedAnnotation2 { + + String name() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @interface NamedAnnotation3 { + + String name() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @NamedAnnotation1(name = "name 1") + @NamedAnnotation2(name = "name 2") + @NamedAnnotation3(name = "name 3") + @Inherited + @interface InheritedComposedAnnotation { + } + + @InheritedComposedAnnotation + private static class AnnotatedClass { + } + + @NamedAnnotation3(name = "local") + private static class AnnotatedSubclass extends AnnotatedClass { + } + +} From 7c84695333228fb2960d69aa312e41e4ead3b5aa Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 5 Dec 2019 13:17:41 -0800 Subject: [PATCH 0171/2315] Support variable resolution of wildcard types Update `ResolvableType` so that variable referenced can be resolved against wildcard types. Prior to this commit, given a type: Map> Calling `type.getGeneric(1).asCollection().resolveGeneric()` would return `null`. This was because the `List` variable `E` referenced a wildcard type which `resolveVariable` did not support. Closes gh-24145 --- .../java/org/springframework/core/ResolvableType.java | 6 ++++++ .../org/springframework/core/ResolvableTypeTests.java | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/spring-core/src/main/java/org/springframework/core/ResolvableType.java b/spring-core/src/main/java/org/springframework/core/ResolvableType.java index 720e4eb56e77..994a395cf7d0 100644 --- a/spring-core/src/main/java/org/springframework/core/ResolvableType.java +++ b/spring-core/src/main/java/org/springframework/core/ResolvableType.java @@ -873,6 +873,12 @@ private ResolvableType resolveVariable(TypeVariable variable) { return forType(ownerType, this.variableResolver).resolveVariable(variable); } } + if (this.type instanceof WildcardType) { + ResolvableType resolved = resolveType().resolveVariable(variable); + if (resolved != null) { + return resolved; + } + } if (this.variableResolver != null) { return this.variableResolver.resolveVariable(variable); } diff --git a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java index 27182ecfb16d..7a781bb7e7d1 100644 --- a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java +++ b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java @@ -688,6 +688,13 @@ void resolveBoundedTypeVariableResult() throws Exception { assertThat(type.resolve()).isEqualTo(CharSequence.class); } + + @Test + void resolveBoundedTypeVariableWildcardResult() throws Exception { + ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("boundedTypeVaraibleWildcardResult")); + assertThat(type.getGeneric(1).asCollection().resolveGeneric()).isEqualTo(CharSequence.class); + } + @Test void resolveVariableNotFound() throws Exception { ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("typedReturn")); @@ -1417,6 +1424,8 @@ interface Methods { R boundedTypeVaraibleResult(); + Map> boundedTypeVaraibleWildcardResult(); + void nested(Map, Map> p); void typedParameter(T p); From 484006ce9050919dc3d26d9e4933f88a93f1c9cb Mon Sep 17 00:00:00 2001 From: stsypanov Date: Fri, 6 Dec 2019 14:07:07 +0200 Subject: [PATCH 0172/2315] Hoist Class.getName() from String concatenation to dodge an issue related to profile pollution --- .../aop/interceptor/SimpleTraceInterceptor.java | 4 ++-- .../src/main/java/org/springframework/beans/BeanUtils.java | 5 +++-- .../src/main/java/org/springframework/util/ObjectUtils.java | 4 +++- .../web/server/handler/DefaultWebFilterChain.java | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/SimpleTraceInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/SimpleTraceInterceptor.java index 147408f24808..87d6186d2914 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/SimpleTraceInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/SimpleTraceInterceptor.java @@ -73,8 +73,8 @@ protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throw * @return the description */ protected String getInvocationDescription(MethodInvocation invocation) { - return "method '" + invocation.getMethod().getName() + "' of class [" + - invocation.getThis().getClass().getName() + "]"; + String className = invocation.getThis().getClass().getName(); + return "method '" + invocation.getMethod().getName() + "' of class [" + className + "]"; } } diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java index 3e0ef30ecd98..1aff95efadb8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java @@ -523,7 +523,8 @@ public static PropertyEditor findEditorByConvention(@Nullable Class targetTyp return null; } } - String editorName = targetType.getName() + "Editor"; + String targetTypeName = targetType.getName(); + String editorName = targetTypeName + "Editor"; try { Class editorClass = cl.loadClass(editorName); if (!PropertyEditor.class.isAssignableFrom(editorClass)) { @@ -539,7 +540,7 @@ public static PropertyEditor findEditorByConvention(@Nullable Class targetTyp catch (ClassNotFoundException ex) { if (logger.isTraceEnabled()) { logger.trace("No property editor [" + editorName + "] found for type " + - targetType.getName() + " according to 'Editor' suffix convention"); + targetTypeName + " according to 'Editor' suffix convention"); } unknownEditorTypes.add(targetType); return null; diff --git a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java index 38ec08eacd06..397ff3a7cc98 100644 --- a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java @@ -611,7 +611,9 @@ public static String identityToString(@Nullable Object obj) { if (obj == null) { return EMPTY_STRING; } - return obj.getClass().getName() + "@" + getIdentityHexString(obj); + String className = obj.getClass().getName(); + String identityHexString = getIdentityHexString(obj); + return className + '@' + identityHexString; } /** diff --git a/spring-web/src/main/java/org/springframework/web/server/handler/DefaultWebFilterChain.java b/spring-web/src/main/java/org/springframework/web/server/handler/DefaultWebFilterChain.java index 74196cc4c35b..deca3c2e2315 100644 --- a/spring-web/src/main/java/org/springframework/web/server/handler/DefaultWebFilterChain.java +++ b/spring-web/src/main/java/org/springframework/web/server/handler/DefaultWebFilterChain.java @@ -123,8 +123,8 @@ public Mono filter(ServerWebExchange exchange) { } private Mono invokeFilter(WebFilter current, DefaultWebFilterChain chain, ServerWebExchange exchange) { - return current.filter(exchange, chain) - .checkpoint(current.getClass().getName() + " [DefaultWebFilterChain]"); + String currentName = current.getClass().getName(); + return current.filter(exchange, chain).checkpoint(currentName + " [DefaultWebFilterChain]"); } } From d4d940e6e30c1219f54e83d371abd0efc44ccdcb Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Fri, 6 Dec 2019 12:02:22 -0600 Subject: [PATCH 0173/2315] Add missing backtick in WebSocket documentation Closes gh-24155 --- src/docs/asciidoc/web/websocket.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/asciidoc/web/websocket.adoc b/src/docs/asciidoc/web/websocket.adoc index feaebc0d3ccf..975060591075 100644 --- a/src/docs/asciidoc/web/websocket.adoc +++ b/src/docs/asciidoc/web/websocket.adoc @@ -1592,7 +1592,7 @@ in both the XML namespace and Java configuration as the `systemLogin` and The STOMP broker relay also creates a separate TCP connection for every connected WebSocket client. You can configure the STOMP credentials that are used for all TCP connections created on behalf of clients. This is exposed in both the XML namespace -and Java configuration as the `clientLogin and `clientPasscode` properties with default +and Java configuration as the `clientLogin` and `clientPasscode` properties with default values of `guest`and `guest`. NOTE: The STOMP broker relay always sets the `login` and `passcode` headers on every `CONNECT` From de8a6c8c57deac295b3df41dec59e4e540a3f813 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 6 Dec 2019 19:08:54 +0100 Subject: [PATCH 0174/2315] Polishing --- src/docs/asciidoc/web/websocket.adoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/docs/asciidoc/web/websocket.adoc b/src/docs/asciidoc/web/websocket.adoc index 975060591075..3cc268b01a74 100644 --- a/src/docs/asciidoc/web/websocket.adoc +++ b/src/docs/asciidoc/web/websocket.adoc @@ -1593,7 +1593,7 @@ The STOMP broker relay also creates a separate TCP connection for every connecte WebSocket client. You can configure the STOMP credentials that are used for all TCP connections created on behalf of clients. This is exposed in both the XML namespace and Java configuration as the `clientLogin` and `clientPasscode` properties with default -values of `guest`and `guest`. +values of `guest` and `guest`. NOTE: The STOMP broker relay always sets the `login` and `passcode` headers on every `CONNECT` frame that it forwards to the broker on behalf of clients. Therefore, WebSocket clients @@ -1787,8 +1787,8 @@ in applications that do not maintain a server-side session or in mobile applications where it is common to use headers for authentication). The https://tools.ietf.org/html/rfc6455#section-10.5[WebSocket protocol, RFC 6455] -"`doesn't prescribe any particular way that servers can authenticate clients during -the WebSocket handshake.`" In practice, however, browser clients can use only standard +"doesn't prescribe any particular way that servers can authenticate clients during +the WebSocket handshake." In practice, however, browser clients can use only standard authentication headers (that is, basic HTTP authentication) or cookies and cannot (for example) provide custom headers. Likewise, the SockJS JavaScript client does not provide a way to send HTTP headers with SockJS transport requests. See @@ -1921,7 +1921,7 @@ session that sent the message being handled). You can send a message to user destinations from any application component by, for example, injecting the `SimpMessagingTemplate` created by the Java configuration or -the XML namespace. (The bean name is `"brokerMessagingTemplate"` if required +the XML namespace. (The bean name is `brokerMessagingTemplate` if required for qualification with `@Qualifier`.) The following example shows how to do so: [source,java,indent=0] From 55ae3c5e872229bac6ba475a46b1a29d1c9b8056 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 7 Dec 2019 12:59:03 +0100 Subject: [PATCH 0175/2315] Polishing --- .../rsocket/RSocketBufferLeakTests.java | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java index b175f0990890..94451b2f3db9 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java @@ -36,6 +36,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -59,21 +61,20 @@ * * @author Rossen Stoyanchev */ -public class RSocketBufferLeakTests { +@TestInstance(Lifecycle.PER_CLASS) +class RSocketBufferLeakTests { - private static AnnotationConfigApplicationContext context; + private final PayloadInterceptor payloadInterceptor = new PayloadInterceptor(); - private static final PayloadInterceptor payloadInterceptor = new PayloadInterceptor(); + private AnnotationConfigApplicationContext context; - private static CloseableChannel server; + private CloseableChannel server; - private static RSocketRequester requester; + private RSocketRequester requester; @BeforeAll - @SuppressWarnings("ConstantConditions") - public static void setupOnce() { - + void setupOnce() { context = new AnnotationConfigApplicationContext(ServerConfig.class); RSocketMessageHandler messageHandler = context.getBean(RSocketMessageHandler.class); SocketAcceptor responder = messageHandler.responder(); @@ -94,20 +95,21 @@ public static void setupOnce() { } @AfterAll - public static void tearDownOnce() { + void tearDownOnce() { requester.rsocket().dispose(); server.dispose(); + context.close(); } @BeforeEach - public void setUp() { + void setUp() { getLeakAwareNettyDataBufferFactory().reset(); payloadInterceptor.reset(); } @AfterEach - public void tearDown() throws InterruptedException { + void tearDown() throws InterruptedException { getLeakAwareNettyDataBufferFactory().checkForLeaks(Duration.ofSeconds(5)); payloadInterceptor.checkForLeaks(); } @@ -118,7 +120,7 @@ private LeakAwareNettyDataBufferFactory getLeakAwareNettyDataBufferFactory() { @Test - public void assemblyTimeErrorForHandleAndReply() { + void assemblyTimeErrorForHandleAndReply() { Mono result = requester.route("A.B").data("foo").retrieveMono(String.class); StepVerifier.create(result).expectErrorMatches(ex -> { String prefix = "Ambiguous handler methods mapped for destination 'A.B':"; @@ -127,7 +129,7 @@ public void assemblyTimeErrorForHandleAndReply() { } @Test - public void subscriptionTimeErrorForHandleAndReply() { + void subscriptionTimeErrorForHandleAndReply() { Mono result = requester.route("not-decodable").data("foo").retrieveMono(String.class); StepVerifier.create(result).expectErrorMatches(ex -> { String prefix = "Cannot decode to [org.springframework.core.io.Resource]"; @@ -136,13 +138,13 @@ public void subscriptionTimeErrorForHandleAndReply() { } @Test - public void errorSignalWithExceptionHandler() { + void errorSignalWithExceptionHandler() { Flux result = requester.route("error-signal").data("foo").retrieveFlux(String.class); StepVerifier.create(result).expectNext("Handled 'bad input'").expectComplete().verify(Duration.ofSeconds(5)); } @Test - public void ignoreInput() { + void ignoreInput() { Mono result = requester.route("ignore-input").data("a").retrieveMono(String.class); StepVerifier.create(result).expectNext("bar").thenCancel().verify(Duration.ofSeconds(5)); } @@ -167,14 +169,14 @@ void notDecodable(@Payload Resource resource) { } @MessageMapping("error-signal") - public Flux errorSignal(String payload) { + Flux errorSignal(String payload) { return Flux.error(new IllegalArgumentException("bad input")) .delayElements(Duration.ofMillis(10)) .cast(String.class); } @MessageExceptionHandler - public String handleIllegalArgument(IllegalArgumentException ex) { + String handleIllegalArgument(IllegalArgumentException ex) { return "Handled '" + ex.getMessage() + "'"; } @@ -189,19 +191,19 @@ Mono ignoreInput() { static class ServerConfig { @Bean - public ServerController controller() { + ServerController controller() { return new ServerController(); } @Bean - public RSocketMessageHandler messageHandler() { + RSocketMessageHandler messageHandler() { RSocketMessageHandler handler = new RSocketMessageHandler(); handler.setRSocketStrategies(rsocketStrategies()); return handler; } @Bean - public RSocketStrategies rsocketStrategies() { + RSocketStrategies rsocketStrategies() { return RSocketStrategies.builder() .dataBufferFactory(new LeakAwareNettyDataBufferFactory(PooledByteBufAllocator.DEFAULT)) .build(); @@ -249,7 +251,7 @@ private void checkForLeak(PayloadLeakInfo info) { } } - public void reset() { + void reset() { this.rsockets.forEach(PayloadSavingDecorator::reset); } From d7d474f65890a7490e9d1de989ecd96660f70cf6 Mon Sep 17 00:00:00 2001 From: yokotaso Date: Sat, 7 Dec 2019 14:20:36 +0900 Subject: [PATCH 0176/2315] Do not cache prototype @ControllerAdvice beans Spring Framework 5.2 introduced support for caching @ControllerAdvice beans; however, this caching was also applied incorrectly to non-singleton beans. This commit addresses this regression by only caching singleton @ControllerAdvice beans. Closes gh-24157 --- .../web/method/ControllerAdviceBean.java | 5 ++++- .../RequestMappingHandlerAdapterTests.java | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java index e66bb4473091..fbf7318c9640 100644 --- a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java +++ b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java @@ -54,6 +54,7 @@ public class ControllerAdviceBean implements Ordered { */ private final Object beanOrName; + private final boolean isSingletonBean; /** * Reference to the resolved bean instance, potentially lazily retrieved * via the {@code BeanFactory}. @@ -84,6 +85,7 @@ public ControllerAdviceBean(Object bean) { this.beanType = ClassUtils.getUserClass(bean.getClass()); this.beanTypePredicate = createBeanTypePredicate(this.beanType); this.beanFactory = null; + this.isSingletonBean = true; } /** @@ -115,6 +117,7 @@ public ControllerAdviceBean(String beanName, BeanFactory beanFactory, @Nullable "] does not contain specified controller advice bean '" + beanName + "'"); this.beanOrName = beanName; + this.isSingletonBean = beanFactory.isSingleton(beanName); this.beanType = getBeanType(beanName, beanFactory); this.beanTypePredicate = (controllerAdvice != null ? createBeanTypePredicate(controllerAdvice) : createBeanTypePredicate(this.beanType)); @@ -191,7 +194,7 @@ public Class getBeanType() { * will be cached, thereby avoiding repeated lookups in the {@code BeanFactory}. */ public Object resolveBean() { - if (this.resolvedBean == null) { + if (!this.isSingletonBean || this.resolvedBean == null) { // this.beanOrName must be a String representing the bean name if // this.resolvedBean is null. this.resolvedBean = obtainBeanFactory().getBean((String) this.beanOrName); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java index 8ec5bd501e4a..f97a39c5fdef 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java @@ -206,6 +206,20 @@ public void modelAttributeAdvice() throws Exception { assertThat(mav.getModel().get("attr2")).isEqualTo("gAttr2"); } + @Test + public void prototypePageControllerAdvice() throws Exception { + this.webAppContext.registerPrototype("maa", ModelAttributeAdvice.class); + this.webAppContext.refresh(); + + HandlerMethod handlerMethod = handlerMethod(new SimpleController(), "handle"); + this.handlerAdapter.afterPropertiesSet(); + ModelAndView mav1 = this.handlerAdapter.handle(this.request, this.response, handlerMethod); + ModelAndView mav2 = this.handlerAdapter.handle(this.request, this.response, handlerMethod); + + assertThat(mav1.getModel().get("modelAttributeAdviceInstance")).isNotEqualTo(mav2.getModel().get("modelAttributeAdviceInstance")); + } + + @Test public void modelAttributeAdviceInParentContext() throws Exception { StaticWebApplicationContext parent = new StaticWebApplicationContext(); @@ -322,6 +336,7 @@ private static class ModelAttributeAdvice { public void addAttributes(Model model) { model.addAttribute("attr1", "gAttr1"); model.addAttribute("attr2", "gAttr2"); + model.addAttribute("modelAttributeAdviceInstance", this); } } From fc42ca286656d7d4a910b5ea737165baa0058f5e Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 7 Dec 2019 13:39:05 +0100 Subject: [PATCH 0177/2315] Polish contribution See gh-24157 --- .../web/method/ControllerAdviceBean.java | 19 +++++++++++++------ .../RequestMappingHandlerAdapterTests.java | 11 +++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java index fbf7318c9640..dc424a862752 100644 --- a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java +++ b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java @@ -54,7 +54,8 @@ public class ControllerAdviceBean implements Ordered { */ private final Object beanOrName; - private final boolean isSingletonBean; + private final boolean isSingleton; + /** * Reference to the resolved bean instance, potentially lazily retrieved * via the {@code BeanFactory}. @@ -81,11 +82,11 @@ public class ControllerAdviceBean implements Ordered { public ControllerAdviceBean(Object bean) { Assert.notNull(bean, "Bean must not be null"); this.beanOrName = bean; + this.isSingleton = true; this.resolvedBean = bean; this.beanType = ClassUtils.getUserClass(bean.getClass()); this.beanTypePredicate = createBeanTypePredicate(this.beanType); this.beanFactory = null; - this.isSingletonBean = true; } /** @@ -117,7 +118,7 @@ public ControllerAdviceBean(String beanName, BeanFactory beanFactory, @Nullable "] does not contain specified controller advice bean '" + beanName + "'"); this.beanOrName = beanName; - this.isSingletonBean = beanFactory.isSingleton(beanName); + this.isSingleton = beanFactory.isSingleton(beanName); this.beanType = getBeanType(beanName, beanFactory); this.beanTypePredicate = (controllerAdvice != null ? createBeanTypePredicate(controllerAdvice) : createBeanTypePredicate(this.beanType)); @@ -191,13 +192,19 @@ public Class getBeanType() { * Get the bean instance for this {@code ControllerAdviceBean}, if necessary * resolving the bean name through the {@link BeanFactory}. *

    As of Spring Framework 5.2, once the bean instance has been resolved it - * will be cached, thereby avoiding repeated lookups in the {@code BeanFactory}. + * will be cached if it is a singleton, thereby avoiding repeated lookups in + * the {@code BeanFactory}. */ public Object resolveBean() { - if (!this.isSingletonBean || this.resolvedBean == null) { + if (this.resolvedBean == null) { // this.beanOrName must be a String representing the bean name if // this.resolvedBean is null. - this.resolvedBean = obtainBeanFactory().getBean((String) this.beanOrName); + Object resolvedBean = obtainBeanFactory().getBean((String) this.beanOrName); + // Don't cache non-singletons (e.g., prototypes). + if (!this.isSingleton) { + return resolvedBean; + } + this.resolvedBean = resolvedBean; } return this.resolvedBean; } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java index f97a39c5fdef..51eb3d983b61 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java @@ -207,19 +207,18 @@ public void modelAttributeAdvice() throws Exception { } @Test - public void prototypePageControllerAdvice() throws Exception { + public void prototypeControllerAdvice() throws Exception { this.webAppContext.registerPrototype("maa", ModelAttributeAdvice.class); this.webAppContext.refresh(); HandlerMethod handlerMethod = handlerMethod(new SimpleController(), "handle"); this.handlerAdapter.afterPropertiesSet(); - ModelAndView mav1 = this.handlerAdapter.handle(this.request, this.response, handlerMethod); - ModelAndView mav2 = this.handlerAdapter.handle(this.request, this.response, handlerMethod); + Map model1 = this.handlerAdapter.handle(this.request, this.response, handlerMethod).getModel(); + Map model2 = this.handlerAdapter.handle(this.request, this.response, handlerMethod).getModel(); - assertThat(mav1.getModel().get("modelAttributeAdviceInstance")).isNotEqualTo(mav2.getModel().get("modelAttributeAdviceInstance")); + assertThat(model1.get("instance")).isNotSameAs(model2.get("instance")); } - @Test public void modelAttributeAdviceInParentContext() throws Exception { StaticWebApplicationContext parent = new StaticWebApplicationContext(); @@ -336,7 +335,7 @@ private static class ModelAttributeAdvice { public void addAttributes(Model model) { model.addAttribute("attr1", "gAttr1"); model.addAttribute("attr2", "gAttr2"); - model.addAttribute("modelAttributeAdviceInstance", this); + model.addAttribute("instance", this); } } From 2108bdf876f85d4642f9f6c18aac352ed7bc1ef8 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 7 Dec 2019 18:30:56 +0100 Subject: [PATCH 0178/2315] Introduce regression test for prototype @ControllerAdvice beans See gh-24157 --- .../spr/ControllerAdviceIntegrationTests.java | 93 ++++++++++++------- 1 file changed, 57 insertions(+), 36 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java index 226d9a453b78..d15bef2efc5c 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java @@ -23,6 +23,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; import org.springframework.test.web.servlet.MockMvc; @@ -63,46 +64,45 @@ void setUpMockMvc(WebApplicationContext wac) { @Test void controllerAdviceIsAppliedOnlyOnce() throws Exception { - assertThat(SingletonControllerAdvice.counter).hasValue(0); - assertThat(RequestScopedControllerAdvice.counter).hasValue(0); - this.mockMvc.perform(get("/test").param("requestParam", "foo"))// .andExpect(status().isOk())// - .andExpect(forwardedUrl("singleton:1;request-scoped:1;requestParam:foo")); + .andExpect(forwardedUrl("singleton:1;prototype:1;request-scoped:1;requestParam:foo")); - assertThat(SingletonControllerAdvice.counter).hasValue(1); - assertThat(RequestScopedControllerAdvice.counter).hasValue(1); + assertThat(SingletonControllerAdvice.invocationCount).hasValue(1); + assertThat(PrototypeControllerAdvice.invocationCount).hasValue(1); + assertThat(RequestScopedControllerAdvice.invocationCount).hasValue(1); } @Test - void requestScopedControllerAdviceBeanIsNotCached() throws Exception { - assertThat(SingletonControllerAdvice.instanceCounter).hasValue(0); - assertThat(RequestScopedControllerAdvice.instanceCounter).hasValue(0); - + void prototypeAndRequestScopedControllerAdviceBeansAreNotCached() throws Exception { this.mockMvc.perform(get("/test").param("requestParam", "foo"))// .andExpect(status().isOk())// - .andExpect(forwardedUrl("singleton:1;request-scoped:1;requestParam:foo")); + .andExpect(forwardedUrl("singleton:1;prototype:1;request-scoped:1;requestParam:foo")); - // A singleton @ControllerAdvice bean should not be instantiated again. - assertThat(SingletonControllerAdvice.instanceCounter).hasValue(0); - // A request-scoped @ControllerAdvice bean should be instantiated once per request. - assertThat(RequestScopedControllerAdvice.instanceCounter).hasValue(1); + // singleton @ControllerAdvice beans should not be instantiated again. + assertThat(SingletonControllerAdvice.instanceCount).hasValue(0); + // prototype and request-scoped @ControllerAdvice beans should be instantiated once per request. + assertThat(PrototypeControllerAdvice.instanceCount).hasValue(1); + assertThat(RequestScopedControllerAdvice.instanceCount).hasValue(1); this.mockMvc.perform(get("/test").param("requestParam", "bar"))// .andExpect(status().isOk())// - .andExpect(forwardedUrl("singleton:2;request-scoped:2;requestParam:bar")); + .andExpect(forwardedUrl("singleton:2;prototype:2;request-scoped:2;requestParam:bar")); - // A singleton @ControllerAdvice bean should not be instantiated again. - assertThat(SingletonControllerAdvice.instanceCounter).hasValue(0); - // A request-scoped @ControllerAdvice bean should be instantiated once per request. - assertThat(RequestScopedControllerAdvice.instanceCounter).hasValue(2); + // singleton @ControllerAdvice beans should not be instantiated again. + assertThat(SingletonControllerAdvice.instanceCount).hasValue(0); + // prototype and request-scoped @ControllerAdvice beans should be instantiated once per request. + assertThat(PrototypeControllerAdvice.instanceCount).hasValue(2); + assertThat(RequestScopedControllerAdvice.instanceCount).hasValue(2); } private void resetCounters() { - SingletonControllerAdvice.counter.set(0); - SingletonControllerAdvice.instanceCounter.set(0); - RequestScopedControllerAdvice.counter.set(0); - RequestScopedControllerAdvice.instanceCounter.set(0); + SingletonControllerAdvice.invocationCount.set(0); + SingletonControllerAdvice.instanceCount.set(0); + PrototypeControllerAdvice.invocationCount.set(0); + PrototypeControllerAdvice.instanceCount.set(0); + RequestScopedControllerAdvice.invocationCount.set(0); + RequestScopedControllerAdvice.instanceCount.set(0); } @Configuration @@ -119,6 +119,12 @@ SingletonControllerAdvice singletonControllerAdvice() { return new SingletonControllerAdvice(); } + @Bean + @Scope("prototype") + PrototypeControllerAdvice prototypeControllerAdvice() { + return new PrototypeControllerAdvice(); + } + @Bean @RequestScope RequestScopedControllerAdvice requestScopedControllerAdvice() { @@ -129,35 +135,49 @@ RequestScopedControllerAdvice requestScopedControllerAdvice() { @ControllerAdvice static class SingletonControllerAdvice { - static final AtomicInteger counter = new AtomicInteger(); + static final AtomicInteger instanceCount = new AtomicInteger(); + static final AtomicInteger invocationCount = new AtomicInteger(); + + { + instanceCount.incrementAndGet(); + } + + @ModelAttribute + void initModel(Model model) { + model.addAttribute("singleton", invocationCount.incrementAndGet()); + } + } + + @ControllerAdvice + static class PrototypeControllerAdvice { - static final AtomicInteger instanceCounter = new AtomicInteger(); + static final AtomicInteger instanceCount = new AtomicInteger(); + static final AtomicInteger invocationCount = new AtomicInteger(); { - instanceCounter.incrementAndGet(); + instanceCount.incrementAndGet(); } @ModelAttribute void initModel(Model model) { - model.addAttribute("singleton", counter.incrementAndGet()); + model.addAttribute("prototype", invocationCount.incrementAndGet()); } } @ControllerAdvice static class RequestScopedControllerAdvice { - static final AtomicInteger counter = new AtomicInteger(); - - static final AtomicInteger instanceCounter = new AtomicInteger(); + static final AtomicInteger instanceCount = new AtomicInteger(); + static final AtomicInteger invocationCount = new AtomicInteger(); { - instanceCounter.incrementAndGet(); + instanceCount.incrementAndGet(); } @ModelAttribute void initModel(@RequestParam String requestParam, Model model) { model.addAttribute("requestParam", requestParam); - model.addAttribute("request-scoped", counter.incrementAndGet()); + model.addAttribute("request-scoped", invocationCount.incrementAndGet()); } } @@ -166,9 +186,10 @@ static class TestController { @GetMapping("/test") String get(Model model) { - return "singleton:" + model.getAttribute("singleton") + ";request-scoped:" - + model.getAttribute("request-scoped") + ";requestParam:" - + model.getAttribute("requestParam"); + return "singleton:" + model.getAttribute("singleton") + + ";prototype:" + model.getAttribute("prototype") + + ";request-scoped:" + model.getAttribute("request-scoped") + + ";requestParam:" + model.getAttribute("requestParam"); } } From e15ccdb35d65d268a195e604f532d69706f7e92d Mon Sep 17 00:00:00 2001 From: PyvesB Date: Sat, 7 Dec 2019 21:25:00 +0000 Subject: [PATCH 0179/2315] Polish DataBufferUtils javadoc See gh-24160 --- .../org/springframework/core/io/buffer/DataBufferUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java index aaab44b9864c..b1beb6f2cbdc 100644 --- a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java +++ b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java @@ -340,7 +340,7 @@ public static Flux write( /** * Write the given stream of {@link DataBuffer DataBuffers} to the given * file {@link Path}. The optional {@code options} parameter specifies - * how the created or opened (defaults to + * how the file is created or opened (defaults to * {@link StandardOpenOption#CREATE CREATE}, * {@link StandardOpenOption#TRUNCATE_EXISTING TRUNCATE_EXISTING}, and * {@link StandardOpenOption#WRITE WRITE}). @@ -470,7 +470,7 @@ public static Flux skipUntilByteCount(Publisher Date: Mon, 9 Dec 2019 11:50:06 +0100 Subject: [PATCH 0180/2315] Fix RSocketRequester Coroutines extensions After gh-24073, some Coroutines extensions should be applied on RetrieveSpec instead of RequestSpec. Closes gh-24166 --- .../rsocket/RSocketRequesterExtensions.kt | 24 ++++++------- .../RSocketRequesterExtensionsTests.kt | 36 +++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt b/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt index 63029eb6110e..0d7635a5e019 100644 --- a/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt +++ b/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt @@ -94,61 +94,61 @@ inline fun RSocketRequester.RequestSpec.dataWithType(flow: Flo /** - * Coroutines variant of [RSocketRequester.RequestSpec.send]. + * Coroutines variant of [RSocketRequester.RetrieveSpec.send]. * * @author Sebastien Deleuze * @since 5.2 */ -suspend fun RSocketRequester.RequestSpec.sendAndAwait() { +suspend fun RSocketRequester.RetrieveSpec.sendAndAwait() { send().awaitFirstOrNull() } /** - * Coroutines variant of [RSocketRequester.RequestSpec.retrieveMono]. + * Coroutines variant of [RSocketRequester.RetrieveSpec.retrieveMono]. * * @author Sebastien Deleuze * @since 5.2 */ -suspend inline fun RSocketRequester.RequestSpec.retrieveAndAwait(): T = +suspend inline fun RSocketRequester.RetrieveSpec.retrieveAndAwait(): T = retrieveMono(object : ParameterizedTypeReference() {}).awaitSingle() /** - * Nullable coroutines variant of [RSocketRequester.RequestSpec.retrieveMono]. + * Nullable coroutines variant of [RSocketRequester.RetrieveSpec.retrieveMono]. * * @author Sebastien Deleuze * @since 5.2.1 */ -suspend inline fun RSocketRequester.RequestSpec.retrieveAndAwaitOrNull(): T? = +suspend inline fun RSocketRequester.RetrieveSpec.retrieveAndAwaitOrNull(): T? = retrieveMono(object : ParameterizedTypeReference() {}).awaitFirstOrNull() /** - * Coroutines variant of [RSocketRequester.RequestSpec.retrieveFlux]. + * Coroutines variant of [RSocketRequester.RetrieveSpec.retrieveFlux]. * * @author Sebastien Deleuze * @since 5.2 */ -inline fun RSocketRequester.RequestSpec.retrieveFlow(): Flow = +inline fun RSocketRequester.RetrieveSpec.retrieveFlow(): Flow = retrieveFlux(object : ParameterizedTypeReference() {}).asFlow() /** - * Extension for [RSocketRequester.RequestSpec.retrieveMono] providing a `retrieveMono()` + * Extension for [RSocketRequester.RetrieveSpec.retrieveMono] providing a `retrieveMono()` * variant leveraging Kotlin reified type parameters. This extension is not subject to type * erasure and retains actual generic type arguments. * * @author Sebastien Deleuze * @since 5.2 */ -inline fun RSocketRequester.RequestSpec.retrieveMono(): Mono = +inline fun RSocketRequester.RetrieveSpec.retrieveMono(): Mono = retrieveMono(object : ParameterizedTypeReference() {}) /** - * Extension for [RSocketRequester.RequestSpec.retrieveFlux] providing a `retrieveFlux()` + * Extension for [RSocketRequester.RetrieveSpec.retrieveFlux] providing a `retrieveFlux()` * variant leveraging Kotlin reified type parameters. This extension is not subject to type * erasure and retains actual generic type arguments. * * @author Sebastien Deleuze * @since 5.2 */ -inline fun RSocketRequester.RequestSpec.retrieveFlux(): Flux = +inline fun RSocketRequester.RetrieveSpec.retrieveFlux(): Flux = retrieveFlux(object : ParameterizedTypeReference() {}) diff --git a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt index 065476966e3c..b05e718ae33d 100644 --- a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt +++ b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt @@ -103,56 +103,56 @@ class RSocketRequesterExtensionsTests { @Test fun sendAndAwait() { - val requestSpec = mockk() - every { requestSpec.send() } returns Mono.empty() + val retrieveSpec = mockk() + every { retrieveSpec.send() } returns Mono.empty() runBlocking { - requestSpec.sendAndAwait() + retrieveSpec.sendAndAwait() } } @Test fun retrieveAndAwait() { val response = "foo" - val requestSpec = mockk() - every { requestSpec.retrieveMono(match>(stringTypeRefMatcher)) } returns Mono.just("foo") + val retrieveSpec = mockk() + every { retrieveSpec.retrieveMono(match>(stringTypeRefMatcher)) } returns Mono.just("foo") runBlocking { - assertThat(requestSpec.retrieveAndAwait()).isEqualTo(response) + assertThat(retrieveSpec.retrieveAndAwait()).isEqualTo(response) } } @Test fun retrieveAndAwaitOrNull() { - val requestSpec = mockk() - every { requestSpec.retrieveMono(match>(stringTypeRefMatcher)) } returns Mono.empty() + val retrieveSpec = mockk() + every { retrieveSpec.retrieveMono(match>(stringTypeRefMatcher)) } returns Mono.empty() runBlocking { - assertThat(requestSpec.retrieveAndAwaitOrNull()).isNull() + assertThat(retrieveSpec.retrieveAndAwaitOrNull()).isNull() } } @Test fun retrieveFlow() { - val requestSpec = mockk() - every { requestSpec.retrieveFlux(match>(stringTypeRefMatcher)) } returns Flux.just("foo", "bar") + val retrieveSpec = mockk() + every { retrieveSpec.retrieveFlux(match>(stringTypeRefMatcher)) } returns Flux.just("foo", "bar") runBlocking { - assertThat(requestSpec.retrieveFlow().toList()).contains("foo", "bar") + assertThat(retrieveSpec.retrieveFlow().toList()).contains("foo", "bar") } } @Test fun retrieveMono() { - val requestSpec = mockk() - every { requestSpec.retrieveMono(match>(stringTypeRefMatcher)) } returns Mono.just("foo") + val retrieveSpec = mockk() + every { retrieveSpec.retrieveMono(match>(stringTypeRefMatcher)) } returns Mono.just("foo") runBlocking { - assertThat(requestSpec.retrieveMono().block()).isEqualTo("foo") + assertThat(retrieveSpec.retrieveMono().block()).isEqualTo("foo") } } @Test fun retrieveFlux() { - val requestSpec = mockk() - every { requestSpec.retrieveFlux(match>(stringTypeRefMatcher)) } returns Flux.just("foo", "bar") + val retrieveSpec = mockk() + every { retrieveSpec.retrieveFlux(match>(stringTypeRefMatcher)) } returns Flux.just("foo", "bar") runBlocking { - assertThat(requestSpec.retrieveFlux().collectList().block()).contains("foo", "bar") + assertThat(retrieveSpec.retrieveFlux().collectList().block()).contains("foo", "bar") } } } From ebbb562cb93d507257f76669d5c7c0ebd4caef65 Mon Sep 17 00:00:00 2001 From: stsypanov Date: Sun, 8 Dec 2019 23:39:38 +0200 Subject: [PATCH 0181/2315] Hoist constant result of SerializableTypeWrapper.unwrap() out of loop --- .../src/main/java/org/springframework/core/ResolvableType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/core/ResolvableType.java b/spring-core/src/main/java/org/springframework/core/ResolvableType.java index 994a395cf7d0..e17d50957744 100644 --- a/spring-core/src/main/java/org/springframework/core/ResolvableType.java +++ b/spring-core/src/main/java/org/springframework/core/ResolvableType.java @@ -1496,9 +1496,9 @@ public TypeVariablesVariableResolver(TypeVariable[] variables, ResolvableType @Override @Nullable public ResolvableType resolveVariable(TypeVariable variable) { + TypeVariable v2 = SerializableTypeWrapper.unwrap(variable); for (int i = 0; i < this.variables.length; i++) { TypeVariable v1 = SerializableTypeWrapper.unwrap(this.variables[i]); - TypeVariable v2 = SerializableTypeWrapper.unwrap(variable); if (ObjectUtils.nullSafeEquals(v1, v2)) { return this.generics[i]; } From 119dd04ae53433f186bb73a2ed347961dc7b2650 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 9 Dec 2019 13:28:39 +0100 Subject: [PATCH 0182/2315] Avoid ByteArrayOutputStream for source values without the need to be encoded Closes gh-24152 --- .../web/util/HierarchicalUriComponents.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java index a78bc26f7c3f..1aaa56f5a12d 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java @@ -335,8 +335,21 @@ static String encodeUriComponent(String source, Charset charset, Type type) { Assert.notNull(type, "Type must not be null"); byte[] bytes = source.getBytes(charset); + boolean original = true; + for (byte b : bytes) { + if (b < 0) { + b += 256; + } + if (!type.isAllowed(b)) { + original = false; + break; + } + } + if (original) { + return source; + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length); - boolean changed = false; for (byte b : bytes) { if (b < 0) { b += 256; @@ -350,10 +363,9 @@ static String encodeUriComponent(String source, Charset charset, Type type) { char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, 16)); bos.write(hex1); bos.write(hex2); - changed = true; } } - return (changed ? new String(bos.toByteArray(), charset) : source); + return new String(bos.toByteArray(), charset); } private Type getHostType() { @@ -416,12 +428,10 @@ else if (!type.isAllowed(ch)) { @Override protected HierarchicalUriComponents expandInternal(UriTemplateVariables uriVariables) { - Assert.state(!this.encodeState.equals(EncodeState.FULLY_ENCODED), "URI components already encoded, and could not possibly contain '{' or '}'."); - // Array-based vars rely on the below order.. - + // Array-based vars rely on the order below... String schemeTo = expandUriComponent(getScheme(), uriVariables, this.variableEncoder); String userInfoTo = expandUriComponent(this.userInfo, uriVariables, this.variableEncoder); String hostTo = expandUriComponent(this.host, uriVariables, this.variableEncoder); From a4f75e9c6a04b81925a617f6547e10fac1eba0a6 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 9 Dec 2019 13:29:00 +0100 Subject: [PATCH 0183/2315] Polishing --- .../main/java/org/springframework/core/ResolvableType.java | 6 +++--- .../ApplicationListenerMethodTransactionalAdapter.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/ResolvableType.java b/spring-core/src/main/java/org/springframework/core/ResolvableType.java index e17d50957744..890ca5d747d7 100644 --- a/spring-core/src/main/java/org/springframework/core/ResolvableType.java +++ b/spring-core/src/main/java/org/springframework/core/ResolvableType.java @@ -1496,10 +1496,10 @@ public TypeVariablesVariableResolver(TypeVariable[] variables, ResolvableType @Override @Nullable public ResolvableType resolveVariable(TypeVariable variable) { - TypeVariable v2 = SerializableTypeWrapper.unwrap(variable); + TypeVariable variableToCompare = SerializableTypeWrapper.unwrap(variable); for (int i = 0; i < this.variables.length; i++) { - TypeVariable v1 = SerializableTypeWrapper.unwrap(this.variables[i]); - if (ObjectUtils.nullSafeEquals(v1, v2)) { + TypeVariable resolvedVariable = SerializableTypeWrapper.unwrap(this.variables[i]); + if (ObjectUtils.nullSafeEquals(resolvedVariable, variableToCompare)) { return this.generics[i]; } } diff --git a/spring-tx/src/main/java/org/springframework/transaction/event/ApplicationListenerMethodTransactionalAdapter.java b/spring-tx/src/main/java/org/springframework/transaction/event/ApplicationListenerMethodTransactionalAdapter.java index a4f32cca9628..b39e8c352046 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/event/ApplicationListenerMethodTransactionalAdapter.java +++ b/spring-tx/src/main/java/org/springframework/transaction/event/ApplicationListenerMethodTransactionalAdapter.java @@ -60,8 +60,8 @@ public ApplicationListenerMethodTransactionalAdapter(String beanName, Class t @Override public void onApplicationEvent(ApplicationEvent event) { - if (TransactionSynchronizationManager.isSynchronizationActive() - && TransactionSynchronizationManager.isActualTransactionActive()) { + if (TransactionSynchronizationManager.isSynchronizationActive() && + TransactionSynchronizationManager.isActualTransactionActive()) { TransactionSynchronization transactionSynchronization = createTransactionSynchronization(event); TransactionSynchronizationManager.registerSynchronization(transactionSynchronization); } From 2d2993dffbe5975d253738491a9e533d6a2d9005 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 9 Dec 2019 14:03:56 +0100 Subject: [PATCH 0184/2315] Cleanup of "varaible" typos in ResolvableTypeTests --- .../core/ResolvableTypeTests.java | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java index 7a781bb7e7d1..c59423a77130 100644 --- a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java +++ b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java @@ -684,14 +684,14 @@ void doesResolveFromOuterOwner() throws Exception { @Test void resolveBoundedTypeVariableResult() throws Exception { - ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("boundedTypeVaraibleResult")); + ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("boundedTypeVariableResult")); assertThat(type.resolve()).isEqualTo(CharSequence.class); } @Test void resolveBoundedTypeVariableWildcardResult() throws Exception { - ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("boundedTypeVaraibleWildcardResult")); + ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("boundedTypeVariableWildcardResult")); assertThat(type.getGeneric(1).asCollection().resolveGeneric()).isEqualTo(CharSequence.class); } @@ -702,27 +702,14 @@ void resolveVariableNotFound() throws Exception { } @Test - void resolveTypeVaraibleFromMethodReturn() throws Exception { - ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("typedReturn")); - assertThat(type.resolve()).isNull(); - } - - @Test - void resolveTypeVaraibleFromMethodReturnWithInstanceClass() throws Exception { - ResolvableType type = ResolvableType.forMethodReturnType( - Methods.class.getMethod("typedReturn"), TypedMethods.class); - assertThat(type.resolve()).isEqualTo(String.class); - } - - @Test - void resolveTypeVaraibleFromSimpleInterfaceType() { + void resolveTypeVariableFromSimpleInterfaceType() { ResolvableType type = ResolvableType.forClass( MySimpleInterfaceType.class).as(MyInterfaceType.class); assertThat(type.resolveGeneric()).isEqualTo(String.class); } @Test - void resolveTypeVaraibleFromSimpleCollectionInterfaceType() { + void resolveTypeVariableFromSimpleCollectionInterfaceType() { ResolvableType type = ResolvableType.forClass( MyCollectionInterfaceType.class).as(MyInterfaceType.class); assertThat(type.resolveGeneric()).isEqualTo(Collection.class); @@ -730,14 +717,14 @@ void resolveTypeVaraibleFromSimpleCollectionInterfaceType() { } @Test - void resolveTypeVaraibleFromSimpleSuperclassType() { + void resolveTypeVariableFromSimpleSuperclassType() { ResolvableType type = ResolvableType.forClass( MySimpleSuperclassType.class).as(MySuperclassType.class); assertThat(type.resolveGeneric()).isEqualTo(String.class); } @Test - void resolveTypeVaraibleFromSimpleCollectionSuperclassType() { + void resolveTypeVariableFromSimpleCollectionSuperclassType() { ResolvableType type = ResolvableType.forClass( MyCollectionSuperclassType.class).as(MySuperclassType.class); assertThat(type.resolveGeneric()).isEqualTo(Collection.class); @@ -1422,9 +1409,9 @@ interface Methods { void charSequenceParameter(List cs); - R boundedTypeVaraibleResult(); + R boundedTypeVariableResult(); - Map> boundedTypeVaraibleWildcardResult(); + Map> boundedTypeVariableWildcardResult(); void nested(Map, Map> p); From 2c03246f0086db718acc9c5e124e40c271728332 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 9 Dec 2019 15:58:21 +0100 Subject: [PATCH 0185/2315] Polishing --- build.gradle | 2 +- .../src/main/java/org/springframework/core/ResolvableType.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 8d7911daa626..0b0a6d9699b2 100644 --- a/build.gradle +++ b/build.gradle @@ -372,7 +372,7 @@ configure([rootProject] + javaProjects) { project -> "https://tiles.apache.org/tiles-request/apidocs/", "https://tiles.apache.org/framework/apidocs/", "https://www.eclipse.org/aspectj/doc/released/aspectj5rt-api/", - "https://www.ehcache.org/apidocs/2.10.4", + "https://www.ehcache.org/apidocs/2.10.4/", "https://www.quartz-scheduler.org/api/2.3.0/", "https://fasterxml.github.io/jackson-core/javadoc/2.10/", "https://fasterxml.github.io/jackson-databind/javadoc/2.10/", diff --git a/spring-core/src/main/java/org/springframework/core/ResolvableType.java b/spring-core/src/main/java/org/springframework/core/ResolvableType.java index 890ca5d747d7..162f152802aa 100644 --- a/spring-core/src/main/java/org/springframework/core/ResolvableType.java +++ b/spring-core/src/main/java/org/springframework/core/ResolvableType.java @@ -986,7 +986,7 @@ public String toString() { * using the full generic type information for assignability checks. * For example: {@code ResolvableType.forClass(MyArrayList.class)}. * @param clazz the class to introspect ({@code null} is semantically - * equivalent to {@code Object.class} for typical use cases here} + * equivalent to {@code Object.class} for typical use cases here) * @return a {@link ResolvableType} for the specified class * @see #forClass(Class, Class) * @see #forClassWithGenerics(Class, Class...) From 0a2046e81c155ac781abd3a8b8f4fa56e1729801 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 10 Dec 2019 00:24:26 +0100 Subject: [PATCH 0186/2315] Upgrade to Hibernate ORM 5.4.10, Protobuf 3.11.1, Joda-Time 2.10.5, Commons Pool 2.7 --- build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 0b0a6d9699b2..47892290579f 100644 --- a/build.gradle +++ b/build.gradle @@ -84,7 +84,7 @@ configure(allprojects) { project -> exclude group: "stax", name: "stax-api" } dependency "com.google.code.gson:gson:2.8.6" - dependency "com.google.protobuf:protobuf-java-util:3.11.0" + dependency "com.google.protobuf:protobuf-java-util:3.11.1" dependency "com.googlecode.protobuf-java-format:protobuf-java-format:1.4" dependency("com.thoughtworks.xstream:xstream:1.4.11.1") { exclude group: "xpp3", name: "xpp3_min" @@ -116,7 +116,7 @@ configure(allprojects) { project -> entry 'activemq-stomp' } dependency "org.apache.bcel:bcel:6.0" - dependency "org.apache.commons:commons-pool2:2.6.0" + dependency "org.apache.commons:commons-pool2:2.7.0" dependencySet(group: 'org.apache.derby', version: '10.14.2.0') { entry 'derby' entry 'derbyclient' @@ -130,7 +130,7 @@ configure(allprojects) { project -> dependency "net.sf.ehcache:ehcache:2.10.6" dependency "org.ehcache:jcache:1.0.1" dependency "org.ehcache:ehcache:3.4.0" - dependency "org.hibernate:hibernate-core:5.4.9.Final" + dependency "org.hibernate:hibernate-core:5.4.10.Final" dependency "org.hibernate:hibernate-validator:6.1.0.Final" dependency "org.webjars:webjars-locator-core:0.43" dependency "org.webjars:underscorejs:1.8.3" @@ -239,7 +239,7 @@ configure(allprojects) { project -> dependency "com.ibm.websphere:uow:6.0.2.17" dependency "com.jamonapi:jamon:2.81" - dependency "joda-time:joda-time:2.10.4" + dependency "joda-time:joda-time:2.10.5" dependency "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.5" dependency "org.javamoney:moneta:1.3" From 1e83e889aa227d9f84c8c212fe6d8772afe33614 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Tue, 10 Dec 2019 12:35:32 +0900 Subject: [PATCH 0187/2315] Use hasSize() where possible See gh-24172 --- .../annotation/AnnotationConfigApplicationContextTests.java | 6 +++--- .../scheduling/config/ScheduledTaskRegistrarTests.java | 2 +- .../test/context/event/CustomTestEventTests.java | 2 +- .../junit/jupiter/SpringExtensionParameterizedTests.java | 2 +- .../GenericComicCharactersInterfaceDefaultMethodsTests.java | 2 +- .../junit/jupiter/generics/GenericComicCharactersTests.java | 2 +- .../accept/MappingMediaTypeFileExtensionResolverTests.java | 2 +- .../RequestScopedControllerAdviceIntegrationTests.java | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java index 0e7f8d39907d..d544438c769d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java @@ -56,7 +56,7 @@ void scanAndRefresh() { context.getBean(uncapitalize(ComponentForScanning.class.getSimpleName())); context.getBean(uncapitalize(Jsr330NamedForScanning.class.getSimpleName())); Map beans = context.getBeansWithAnnotation(Configuration.class); - assertThat(beans).size().isEqualTo(1); + assertThat(beans).hasSize(1); } @Test @@ -68,7 +68,7 @@ void registerAndRefresh() { context.getBean("testBean"); context.getBean("name"); Map beans = context.getBeansWithAnnotation(Configuration.class); - assertThat(beans).size().isEqualTo(2); + assertThat(beans).hasSize(2); } @Test @@ -80,7 +80,7 @@ void getBeansWithAnnotation() { context.getBean("testBean"); context.getBean("name"); Map beans = context.getBeansWithAnnotation(Configuration.class); - assertThat(beans).size().isEqualTo(2); + assertThat(beans).hasSize(2); } @Test diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTaskRegistrarTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTaskRegistrarTests.java index 14f49a37c31c..9b9828c90e75 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTaskRegistrarTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTaskRegistrarTests.java @@ -79,7 +79,7 @@ void getFixedDelayTasks() { @Test void addCronTaskWithValidExpression() { this.taskRegistrar.addCronTask(no_op, "* * * * * ?"); - assertThat(this.taskRegistrar.getCronTaskList()).size().isEqualTo(1); + assertThat(this.taskRegistrar.getCronTaskList()).hasSize(1); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/context/event/CustomTestEventTests.java b/spring-test/src/test/java/org/springframework/test/context/event/CustomTestEventTests.java index 96b580c79343..e84e184c3048 100644 --- a/spring-test/src/test/java/org/springframework/test/context/event/CustomTestEventTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/event/CustomTestEventTests.java @@ -57,7 +57,7 @@ public void clearEvents() { @Test public void customTestEventPublished() { - assertThat(events).size().isEqualTo(1); + assertThat(events).hasSize(1); CustomEvent customEvent = events.get(0); assertThat(customEvent.getSource()).isEqualTo(getClass()); assertThat(customEvent.getTestName()).isEqualTo("customTestEventPublished"); diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringExtensionParameterizedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringExtensionParameterizedTests.java index ac3cdaa0f34f..ac2326febccb 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringExtensionParameterizedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringExtensionParameterizedTests.java @@ -50,7 +50,7 @@ class SpringExtensionParameterizedTests { @ParameterizedTest @ValueSource(strings = { "Dilbert", "Wally" }) void people(String name, @Autowired List people) { - assertThat(people.stream().map(Person::getName).filter(name::equals)).size().isEqualTo(1); + assertThat(people.stream().map(Person::getName).filter(name::equals)).hasSize(1); } @ParameterizedTest diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/defaultmethods/GenericComicCharactersInterfaceDefaultMethodsTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/defaultmethods/GenericComicCharactersInterfaceDefaultMethodsTests.java index 3fc606cf7265..5fdbafba293a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/defaultmethods/GenericComicCharactersInterfaceDefaultMethodsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/defaultmethods/GenericComicCharactersInterfaceDefaultMethodsTests.java @@ -45,7 +45,7 @@ interface GenericComicCharactersInterfaceDefaultMethodsTests characters) { - assertThat(characters).as("Number of characters in context").size().isEqualTo(getExpectedNumCharacters()); + assertThat(characters).as("Number of characters in context").hasSize(getExpectedNumCharacters()); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/generics/GenericComicCharactersTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/generics/GenericComicCharactersTests.java index dd2180d75296..3957d9a5b9c5 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/generics/GenericComicCharactersTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/generics/GenericComicCharactersTests.java @@ -53,7 +53,7 @@ abstract class GenericComicCharactersTests { void autowiredFields() { assertThat(this.character).as("Character should have been @Autowired by Spring").isNotNull(); assertThat(this.character).as("character's name").extracting(Character::getName).isEqualTo(getExpectedName()); - assertThat(this.characters).as("Number of characters in context").size().isEqualTo(getExpectedNumCharacters()); + assertThat(this.characters).as("Number of characters in context").hasSize(getExpectedNumCharacters()); } @Test diff --git a/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java b/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java index 300dadf7e4a8..873f521a9e7d 100644 --- a/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java @@ -41,7 +41,7 @@ public class MappingMediaTypeFileExtensionResolverTests { public void resolveExtensions() { List extensions = this.resolver.resolveFileExtensions(MediaType.APPLICATION_JSON); - assertThat(extensions).size().isEqualTo(1); + assertThat(extensions).hasSize(1); assertThat(extensions.get(0)).isEqualTo("json"); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java index 8669d4b64fc8..84ae04c7b148 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java @@ -51,7 +51,7 @@ void loadContextWithRequestScopedControllerAdvice() { assertThatCode(context::refresh).doesNotThrowAnyException(); List adviceBeans = ControllerAdviceBean.findAnnotatedBeans(context); - assertThat(adviceBeans).size().isEqualTo(1); + assertThat(adviceBeans).hasSize(1); assertThat(adviceBeans.get(0))// .returns(RequestScopedControllerAdvice.class, ControllerAdviceBean::getBeanType)// .returns(42, ControllerAdviceBean::getOrder); From 4466114cfaae5083a68900b4231e49d8025c40a7 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 10 Dec 2019 13:14:11 +0100 Subject: [PATCH 0188/2315] Polishing --- .../AnnotationTypeMappingsTests.java | 364 +++++++----------- 1 file changed, 130 insertions(+), 234 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java index c90fd3012bf5..abe1a19bc0ef 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java @@ -213,49 +213,40 @@ void forAnnotationTypeWhenAliasWithExplicitMirrorAndDifferentDefaults() { @Test void getDistanceReturnsDistance() { - AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( - Mapped.class); + AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(Mapped.class); assertThat(mappings.get(0).getDistance()).isEqualTo(0); assertThat(mappings.get(1).getDistance()).isEqualTo(1); } @Test void getAnnotationTypeReturnsAnnotationType() { - AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( - Mapped.class); + AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(Mapped.class); assertThat(mappings.get(0).getAnnotationType()).isEqualTo(Mapped.class); assertThat(mappings.get(1).getAnnotationType()).isEqualTo(MappedTarget.class); } @Test void getMetaTypeReturnsTypes() { - AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( - ThreeDeepA.class); + AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(ThreeDeepA.class); AnnotationTypeMapping mappingC = mappings.get(2); - assertThat(mappingC.getMetaTypes()).containsExactly( - ThreeDeepA.class, ThreeDeepB.class, ThreeDeepC.class); + assertThat(mappingC.getMetaTypes()).containsExactly(ThreeDeepA.class, ThreeDeepB.class, ThreeDeepC.class); } @Test void getAnnotationWhenRootReturnsNull() { - AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( - Mapped.class); + AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(Mapped.class); assertThat(mappings.get(0).getAnnotation()).isNull(); } @Test void getAnnotationWhenMetaAnnotationReturnsAnnotation() { - AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( - Mapped.class); - assertThat(mappings.get(1).getAnnotation()).isEqualTo( - Mapped.class.getAnnotation(MappedTarget.class)); - + AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(Mapped.class); + assertThat(mappings.get(1).getAnnotation()).isEqualTo(Mapped.class.getAnnotation(MappedTarget.class)); } @Test void getAttributesReturnsAttributes() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - Mapped.class).get(0); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(Mapped.class).get(0); AttributeMethods attributes = mapping.getAttributes(); assertThat(attributes.size()).isEqualTo(2); assertThat(attributes.get(0).getName()).isEqualTo("alias"); @@ -264,24 +255,19 @@ void getAttributesReturnsAttributes() { @Test void getAliasMappingReturnsAttributes() throws Exception { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - Mapped.class).get(1); - assertThat(getAliasMapping(mapping, 0)).isEqualTo( - Mapped.class.getDeclaredMethod("alias")); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(Mapped.class).get(1); + assertThat(getAliasMapping(mapping, 0)).isEqualTo(Mapped.class.getDeclaredMethod("alias")); } @Test void getConventionMappingReturnsAttributes() throws Exception { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - Mapped.class).get(1); - assertThat(getConventionMapping(mapping, 1)).isEqualTo( - Mapped.class.getDeclaredMethod("convention")); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(Mapped.class).get(1); + assertThat(getConventionMapping(mapping, 1)).isEqualTo(Mapped.class.getDeclaredMethod("convention")); } @Test void getMirrorSetWhenAliasPairReturnsMirrors() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - AliasPair.class).get(0); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0); MirrorSets mirrorSets = mapping.getMirrorSets(); assertThat(mirrorSets.size()).isEqualTo(1); assertThat(mirrorSets.get(0).size()).isEqualTo(2); @@ -291,8 +277,7 @@ void getMirrorSetWhenAliasPairReturnsMirrors() { @Test void getMirrorSetWhenImplicitMirrorsReturnsMirrors() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - ImplicitMirrors.class).get(0); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ImplicitMirrors.class).get(0); MirrorSets mirrorSets = mapping.getMirrorSets(); assertThat(mirrorSets.size()).isEqualTo(1); assertThat(mirrorSets.get(0).size()).isEqualTo(2); @@ -302,8 +287,7 @@ void getMirrorSetWhenImplicitMirrorsReturnsMirrors() { @Test void getMirrorSetWhenThreeDeepReturnsMirrors() { - AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( - ThreeDeepA.class); + AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(ThreeDeepA.class); AnnotationTypeMapping mappingA = mappings.get(0); MirrorSets mirrorSetsA = mappingA.getMirrorSets(); assertThat(mirrorSetsA.size()).isEqualTo(2); @@ -319,8 +303,7 @@ void getMirrorSetWhenThreeDeepReturnsMirrors() { @Test void getAliasMappingWhenThreeDeepReturnsMappedAttributes() { - AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( - ThreeDeepA.class); + AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(ThreeDeepA.class); AnnotationTypeMapping mappingA = mappings.get(0); assertThat(getAliasMapping(mappingA, 0)).isNull(); assertThat(getAliasMapping(mappingA, 1)).isNull(); @@ -337,50 +320,41 @@ void getAliasMappingWhenThreeDeepReturnsMappedAttributes() { @Test void getAliasMappingsWhenHasDefinedAttributesReturnsMappedAttributes() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - DefinedAttributes.class).get(1); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(DefinedAttributes.class).get(1); assertThat(getAliasMapping(mapping, 0)).isNull(); assertThat(getAliasMapping(mapping, 1).getName()).isEqualTo("value"); } @Test void resolveMirrorsWhenAliasPairResolves() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - AliasPair.class).get(0); - Method[] resolvedA = resolveMirrorSets(mapping, WithAliasPairA.class, - AliasPair.class); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0); + Method[] resolvedA = resolveMirrorSets(mapping, WithAliasPairA.class, AliasPair.class); assertThat(resolvedA[0].getName()).isEqualTo("a"); assertThat(resolvedA[1].getName()).isEqualTo("a"); - Method[] resolvedB = resolveMirrorSets(mapping, WithAliasPairB.class, - AliasPair.class); + Method[] resolvedB = resolveMirrorSets(mapping, WithAliasPairB.class, AliasPair.class); assertThat(resolvedB[0].getName()).isEqualTo("b"); assertThat(resolvedB[1].getName()).isEqualTo("b"); } @Test void resolveMirrorsWhenHasSameValuesUsesFirst() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - AliasPair.class).get(0); - Method[] resolved = resolveMirrorSets(mapping, WithSameValueAliasPair.class, - AliasPair.class); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0); + Method[] resolved = resolveMirrorSets(mapping, WithSameValueAliasPair.class, AliasPair.class); assertThat(resolved[0].getName()).isEqualTo("a"); assertThat(resolved[1].getName()).isEqualTo("a"); } @Test void resolveMirrorsWhenOnlyHasDefaultValuesUsesFirst() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - AliasPair.class).get(0); - Method[] resolved = resolveMirrorSets(mapping, WithDefaultValueAliasPair.class, - AliasPair.class); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0); + Method[] resolved = resolveMirrorSets(mapping, WithDefaultValueAliasPair.class, AliasPair.class); assertThat(resolved[0].getName()).isEqualTo("a"); assertThat(resolved[1].getName()).isEqualTo("a"); } @Test void resolveMirrorsWhenHasDifferentValuesThrowsException() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - AliasPair.class).get(0); + 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 [" @@ -391,77 +365,58 @@ void resolveMirrorsWhenHasDifferentValuesThrowsException() { @Test void resolveMirrorsWhenHasWithMulipleRoutesToAliasReturnsMirrors() { - AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( - MulipleRoutesToAliasA.class); - AnnotationTypeMapping mappingsA = getMapping(mappings, - MulipleRoutesToAliasA.class); + AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MulipleRoutesToAliasA.class); + AnnotationTypeMapping mappingsA = getMapping(mappings, MulipleRoutesToAliasA.class); assertThat(mappingsA.getMirrorSets().size()).isZero(); - AnnotationTypeMapping mappingsB = getMapping(mappings, - MulipleRoutesToAliasB.class); - assertThat(getNames(mappingsB.getMirrorSets().get(0))).containsExactly("b1", "b2", - "b3"); - AnnotationTypeMapping mappingsC = getMapping(mappings, - MulipleRoutesToAliasC.class); - assertThat(getNames(mappingsC.getMirrorSets().get(0))).containsExactly("c1", - "c2"); + AnnotationTypeMapping mappingsB = getMapping(mappings, MulipleRoutesToAliasB.class); + assertThat(getNames(mappingsB.getMirrorSets().get(0))).containsExactly("b1", "b2", "b3"); + AnnotationTypeMapping mappingsC = getMapping(mappings, MulipleRoutesToAliasC.class); + assertThat(getNames(mappingsC.getMirrorSets().get(0))).containsExactly("c1", "c2"); } @Test void getAliasMappingWhenHasWithMulipleRoutesToAliasReturnsMappedAttributes() { - AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( - MulipleRoutesToAliasA.class); - AnnotationTypeMapping mappingsA = getMapping(mappings, - MulipleRoutesToAliasA.class); + AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MulipleRoutesToAliasA.class); + AnnotationTypeMapping mappingsA = getMapping(mappings, MulipleRoutesToAliasA.class); assertThat(getAliasMapping(mappingsA, 0)).isNull(); - AnnotationTypeMapping mappingsB = getMapping(mappings, - MulipleRoutesToAliasB.class); + AnnotationTypeMapping mappingsB = getMapping(mappings, MulipleRoutesToAliasB.class); assertThat(getAliasMapping(mappingsB, 0).getName()).isEqualTo("a1"); assertThat(getAliasMapping(mappingsB, 1).getName()).isEqualTo("a1"); assertThat(getAliasMapping(mappingsB, 2).getName()).isEqualTo("a1"); - AnnotationTypeMapping mappingsC = getMapping(mappings, - MulipleRoutesToAliasC.class); + AnnotationTypeMapping mappingsC = getMapping(mappings, MulipleRoutesToAliasC.class); assertThat(getAliasMapping(mappingsC, 0).getName()).isEqualTo("a1"); assertThat(getAliasMapping(mappingsC, 1).getName()).isEqualTo("a1"); } @Test void getConventionMappingWhenConventionToExplicitAliasesReturnsMappedAttributes() { - AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( - ConventionToExplicitAliases.class); - AnnotationTypeMapping mapping = getMapping(mappings, - ConventionToExplicitAliasesTarget.class); + AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(ConventionToExplicitAliases.class); + AnnotationTypeMapping mapping = getMapping(mappings, ConventionToExplicitAliasesTarget.class); assertThat(mapping.getConventionMapping(0)).isEqualTo(0); assertThat(mapping.getConventionMapping(1)).isEqualTo(0); } @Test void isEquivalentToDefaultValueWhenValueAndDefaultAreNullReturnsTrue() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - ClassValue.class).get(0); - assertThat(mapping.isEquivalentToDefaultValue(0, null, - ReflectionUtils::invokeMethod)).isTrue(); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ClassValue.class).get(0); + assertThat(mapping.isEquivalentToDefaultValue(0, null, ReflectionUtils::invokeMethod)).isTrue(); } @Test void isEquivalentToDefaultValueWhenValueAndDefaultMatchReturnsTrue() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - ClassValueWithDefault.class).get(0); - assertThat(mapping.isEquivalentToDefaultValue(0, InputStream.class, - ReflectionUtils::invokeMethod)).isTrue(); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ClassValueWithDefault.class).get(0); + assertThat(mapping.isEquivalentToDefaultValue(0, InputStream.class, ReflectionUtils::invokeMethod)).isTrue(); } @Test void isEquivalentToDefaultValueWhenClassAndStringNamesMatchReturnsTrue() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - ClassValueWithDefault.class).get(0); - assertThat(mapping.isEquivalentToDefaultValue(0, "java.io.InputStream", - ReflectionUtils::invokeMethod)).isTrue(); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ClassValueWithDefault.class).get(0); + assertThat(mapping.isEquivalentToDefaultValue(0, "java.io.InputStream", ReflectionUtils::invokeMethod)).isTrue(); } @Test void isEquivalentToDefaultValueWhenClassArrayAndStringArrayNamesMatchReturnsTrue() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - ClassArrayValueWithDefault.class).get(0); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ClassArrayValueWithDefault.class).get(0); assertThat(mapping.isEquivalentToDefaultValue(0, new String[] { "java.io.InputStream", "java.io.OutputStream" }, ReflectionUtils::invokeMethod)).isTrue(); @@ -469,31 +424,24 @@ void isEquivalentToDefaultValueWhenClassArrayAndStringArrayNamesMatchReturnsTrue @Test void isEquivalentToDefaultValueWhenNestedAnnotationAndExtractedValuesMatchReturnsTrue() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - NestedValue.class).get(0); - Map value = Collections.singletonMap("value", - "java.io.InputStream"); - assertThat(mapping.isEquivalentToDefaultValue(0, value, - this::extractFromMap)).isTrue(); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(NestedValue.class).get(0); + Map value = Collections.singletonMap("value", "java.io.InputStream"); + assertThat(mapping.isEquivalentToDefaultValue(0, value, this::extractFromMap)).isTrue(); } @Test void isEquivalentToDefaultValueWhenNotMatchingReturnsFalse() { - AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( - ClassValueWithDefault.class).get(0); - assertThat(mapping.isEquivalentToDefaultValue(0, OutputStream.class, - ReflectionUtils::invokeMethod)).isFalse(); + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ClassValueWithDefault.class).get(0); + assertThat(mapping.isEquivalentToDefaultValue(0, OutputStream.class, ReflectionUtils::invokeMethod)).isFalse(); } private Method[] resolveMirrorSets(AnnotationTypeMapping mapping, Class element, Class annotationClass) { Annotation annotation = element.getAnnotation(annotationClass); - int[] resolved = mapping.getMirrorSets().resolve(element.getName(), annotation, - ReflectionUtils::invokeMethod); + int[] resolved = mapping.getMirrorSets().resolve(element.getName(), annotation, ReflectionUtils::invokeMethod); Method[] result = new Method[resolved.length]; for (int i = 0; i < resolved.length; i++) { - result[i] = resolved[i] != -1 ? mapping.getAttributes().get(resolved[i]) - : null; + result[i] = resolved[i] != -1 ? mapping.getAttributes().get(resolved[i]) : null; } return result; } @@ -505,14 +453,14 @@ private Method getAliasMapping(AnnotationTypeMapping mapping, int attributeIndex } @Nullable - private Method getConventionMapping(AnnotationTypeMapping mapping, - int attributeIndex) { + private Method getConventionMapping(AnnotationTypeMapping mapping, int attributeIndex) { int mapped = mapping.getConventionMapping(attributeIndex); return mapped != -1 ? mapping.getRoot().getAttributes().get(mapped) : null; } private AnnotationTypeMapping getMapping(AnnotationTypeMappings mappings, Class annotationType) { + for (AnnotationTypeMapping candidate : getAll(mappings)) { if (candidate.getAnnotationType() == annotationType) { return candidate; @@ -544,89 +492,76 @@ private Object extractFromMap(Method attribute, Object map) { return map != null ? ((Map) map).get(attribute.getName()) : null; } + @Retention(RetentionPolicy.RUNTIME) @interface SimpleAnnotation { - } @Retention(RetentionPolicy.RUNTIME) @Inherited @UsesSunMisc @interface WithSpringLangAnnotation { - - } - - @Retention(RetentionPolicy.RUNTIME) - @A - @B - @interface MetaAnnotated { - } @Retention(RetentionPolicy.RUNTIME) - @AA - @AB - @interface A { - + @interface AA { } @Retention(RetentionPolicy.RUNTIME) - @interface AA { - + @interface ABC { } @Retention(RetentionPolicy.RUNTIME) @ABC @interface AB { - } @Retention(RetentionPolicy.RUNTIME) - @interface ABC { - + @AA + @AB + @interface A { } @Retention(RetentionPolicy.RUNTIME) @interface B { + } + @Retention(RetentionPolicy.RUNTIME) + @A + @B + @interface MetaAnnotated { } @Retention(RetentionPolicy.RUNTIME) - @Repeating - @Repeating - @interface WithRepeatedMetaAnnotations { + @interface Repeatings { + Repeating[] value(); } @Retention(RetentionPolicy.RUNTIME) @Repeatable(Repeatings.class) @interface Repeating { - } @Retention(RetentionPolicy.RUNTIME) - @interface Repeatings { - - Repeating[] value(); - + @Repeating + @Repeating + @interface WithRepeatedMetaAnnotations { } @Retention(RetentionPolicy.RUNTIME) @SelfAnnotated @interface SelfAnnotated { - } @Retention(RetentionPolicy.RUNTIME) @LoopB @interface LoopA { - } @Retention(RetentionPolicy.RUNTIME) @LoopA @interface LoopB { - } @Retention(RetentionPolicy.RUNTIME) @@ -634,7 +569,6 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor(value = "bar", attribute = "foo") String test(); - } @Retention(RetentionPolicy.RUNTIME) @@ -644,7 +578,12 @@ private Object extractFromMap(Method attribute, Object map) { String test() default ""; String other() default ""; + } + @Retention(RetentionPolicy.RUNTIME) + @interface AliasForToOtherNonExistingAttributeTarget { + + String other() default ""; } @Retention(RetentionPolicy.RUNTIME) @@ -653,14 +592,6 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor(annotation = AliasForToOtherNonExistingAttributeTarget.class, attribute = "missing") String test() default ""; - - } - - @Retention(RetentionPolicy.RUNTIME) - @interface AliasForToOtherNonExistingAttributeTarget { - - String other() default ""; - } @Retention(RetentionPolicy.RUNTIME) @@ -668,7 +599,12 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor("test") String test() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @interface AliasForWithArrayCompatibleReturnTypesTarget { + String[] test() default {}; } @Retention(RetentionPolicy.RUNTIME) @@ -677,14 +613,12 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor(annotation = AliasForWithArrayCompatibleReturnTypesTarget.class) String test() default ""; - } @Retention(RetentionPolicy.RUNTIME) - @interface AliasForWithArrayCompatibleReturnTypesTarget { - - String[] test() default {}; + @interface AliasForWithIncompatibleReturnTypesTarget { + String test() default ""; } @Retention(RetentionPolicy.RUNTIME) @@ -692,14 +626,6 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor(annotation = AliasForWithIncompatibleReturnTypesTarget.class) String[] test() default {}; - - } - - @Retention(RetentionPolicy.RUNTIME) - @interface AliasForWithIncompatibleReturnTypesTarget { - - String test() default ""; - } @Retention(RetentionPolicy.RUNTIME) @@ -713,7 +639,6 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor("a") String c() default ""; - } @Retention(RetentionPolicy.RUNTIME) @@ -721,14 +646,12 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor(annotation = AliasForNonMetaAnnotatedTarget.class) String test() default ""; - } @Retention(RetentionPolicy.RUNTIME) @interface AliasForNonMetaAnnotatedTarget { String test() default ""; - } @Retention(RetentionPolicy.RUNTIME) @@ -739,7 +662,6 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor("a") String b() default "b"; - } @Retention(RetentionPolicy.RUNTIME) @@ -750,7 +672,12 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor("a") String b(); + } + + @Retention(RetentionPolicy.RUNTIME) + @interface AliasWithExplicitMirrorAndDifferentDefaultsTarget { + String a() default ""; } @Retention(RetentionPolicy.RUNTIME) @@ -765,14 +692,14 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor(annotation = AliasWithExplicitMirrorAndDifferentDefaultsTarget.class, attribute = "a") String c() default "y"; - } @Retention(RetentionPolicy.RUNTIME) - @interface AliasWithExplicitMirrorAndDifferentDefaultsTarget { + @interface MappedTarget { - String a() default ""; + String convention() default ""; + String aliasTarget() default ""; } @Retention(RetentionPolicy.RUNTIME) @@ -783,16 +710,6 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor(annotation = MappedTarget.class, attribute = "aliasTarget") String alias() default ""; - - } - - @Retention(RetentionPolicy.RUNTIME) - @interface MappedTarget { - - String convention() default ""; - - String aliasTarget() default ""; - } @Retention(RetentionPolicy.RUNTIME) @@ -803,7 +720,16 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor("a") String b() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @interface ImplicitMirrorsTarget { + + @AliasFor("d") + String c() default ""; + @AliasFor("c") + String d() default ""; } @Retention(RetentionPolicy.RUNTIME) @@ -815,18 +741,26 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor(annotation = ImplicitMirrorsTarget.class, attribute = "c") String b() default ""; - } + @Retention(RetentionPolicy.RUNTIME) - @interface ImplicitMirrorsTarget { + @interface ThreeDeepC { - @AliasFor("d") - String c() default ""; + String c1() default ""; - @AliasFor("c") - String d() default ""; + String c2() default ""; + } + @Retention(RetentionPolicy.RUNTIME) + @ThreeDeepC + @interface ThreeDeepB { + + @AliasFor(annotation = ThreeDeepC.class, attribute = "c1") + String b1() default ""; + + @AliasFor(annotation = ThreeDeepC.class, attribute = "c1") + String b2() default ""; } @Retention(RetentionPolicy.RUNTIME) @@ -847,28 +781,14 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor(annotation = ThreeDeepC.class, attribute = "c2") String a5() default ""; - - } - - @Retention(RetentionPolicy.RUNTIME) - @ThreeDeepC - @interface ThreeDeepB { - - @AliasFor(annotation = ThreeDeepC.class, attribute = "c1") - String b1() default ""; - - @AliasFor(annotation = ThreeDeepC.class, attribute = "c1") - String b2() default ""; - } @Retention(RetentionPolicy.RUNTIME) - @interface ThreeDeepC { - - String c1() default ""; + @interface DefinedAttributesTarget { - String c2() default ""; + String a(); + String b() default ""; } @Retention(RetentionPolicy.RUNTIME) @@ -877,50 +797,36 @@ private Object extractFromMap(Method attribute, Object map) { @AliasFor(annotation = DefinedAttributesTarget.class, attribute = "b") String value(); - - } - - @Retention(RetentionPolicy.RUNTIME) - @interface DefinedAttributesTarget { - - String a(); - - String b() default ""; - } @AliasPair(a = "test") static class WithAliasPairA { - } @AliasPair(b = "test") static class WithAliasPairB { - } @AliasPair(a = "test", b = "test") static class WithSameValueAliasPair { - } @AliasPair(a = "test1", b = "test2") static class WithDifferentValueAliasPair { - } @AliasPair static class WithDefaultValueAliasPair { - } @Retention(RetentionPolicy.RUNTIME) - @MulipleRoutesToAliasB - @interface MulipleRoutesToAliasA { + @interface MulipleRoutesToAliasC { - @AliasFor(annotation = MulipleRoutesToAliasB.class, attribute = "b2") - String a1() default ""; + @AliasFor("c2") + String c1() default ""; + @AliasFor("c1") + String c2() default ""; } @Retention(RetentionPolicy.RUNTIME) @@ -935,26 +841,14 @@ static class WithDefaultValueAliasPair { @AliasFor(annotation = MulipleRoutesToAliasC.class, attribute = "c1") String b3() default ""; - } @Retention(RetentionPolicy.RUNTIME) - @interface MulipleRoutesToAliasC { - - @AliasFor("c2") - String c1() default ""; - - @AliasFor("c1") - String c2() default ""; - - } - - @Retention(RetentionPolicy.RUNTIME) - @ConventionToExplicitAliasesTarget - @interface ConventionToExplicitAliases { - - String test() default ""; + @MulipleRoutesToAliasB + @interface MulipleRoutesToAliasA { + @AliasFor(annotation = MulipleRoutesToAliasB.class, attribute = "b2") + String a1() default ""; } @Retention(RetentionPolicy.RUNTIME) @@ -965,35 +859,37 @@ static class WithDefaultValueAliasPair { @AliasFor("value") String test() default ""; + } + @Retention(RetentionPolicy.RUNTIME) + @ConventionToExplicitAliasesTarget + @interface ConventionToExplicitAliases { + + String test() default ""; } @Retention(RetentionPolicy.RUNTIME) @interface ClassValue { Class value(); - } @Retention(RetentionPolicy.RUNTIME) @interface ClassValueWithDefault { Class value() default InputStream.class; - } @Retention(RetentionPolicy.RUNTIME) @interface ClassArrayValueWithDefault { Class[] value() default { InputStream.class, OutputStream.class }; - } @Retention(RetentionPolicy.RUNTIME) @interface NestedValue { ClassValue value() default @ClassValue(InputStream.class); - } } From 2bd821c9091d5633146368971f58d299aa53c629 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 10 Dec 2019 14:09:55 +0100 Subject: [PATCH 0189/2315] Improve exception for mixed explicit/implicit aliases with @AliasFor Given the following improperly configured composed @RequestMapping annotation: @Retention(RetentionPolicy.RUNTIME) @RequestMapping @interface PostApi { @AliasFor("value") String[] path() default {}; @AliasFor(annotation = RequestMapping.class, attribute = "path") String[] value() default {}; } Prior to this commit, an attempt to process the above annotation resulted in an exception similar to the following, which is not especially helpful to discern the problem. > Attribute 'value' in annotation [PostApi] must be declared as an > @AliasFor 'path', not 'path'. This commit improves the exception message for such scenarios, resulting in an exception message similar to the following. > Attribute 'value' in annotation [PostApi] must be declared as an > @AliasFor attribute 'path' in annotation [PostApi], not attribute > 'path' in annotation [RequestMapping]. Closes gh-24168 --- .../annotation/AnnotationTypeMapping.java | 4 +- .../AnnotationTypeMappingsTests.java | 73 +++++++++++++++---- 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java index bab16eaeda63..f788127cc7f3 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java @@ -182,9 +182,9 @@ private Method resolveAliasTarget(Method attribute, AliasFor aliasFor, boolean c Method mirror = resolveAliasTarget(target, targetAliasFor, false); if (!mirror.equals(attribute)) { throw new AnnotationConfigurationException(String.format( - "%s must be declared as an @AliasFor '%s', not '%s'.", + "%s must be declared as an @AliasFor %s, not %s.", StringUtils.capitalize(AttributeMethods.describe(target)), - attribute.getName(), mirror.getName())); + AttributeMethods.describe(attribute), AttributeMethods.describe(mirror))); } } } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java index abe1a19bc0ef..f5cb39ec6d20 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java @@ -160,11 +160,28 @@ void forAnnotationTypeWhenAliasForWithIncompatibleReturnTypes() { @Test void forAnnotationTypeWhenAliasForToSelfAnnotatedToOtherAttribute() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> - AnnotationTypeMappings.forAnnotationType(AliasForToSelfAnnotatedToOtherAttribute.class)) - .withMessage("Attribute 'b' in annotation [" - + AliasForToSelfAnnotatedToOtherAttribute.class.getName() - + "] must be declared as an @AliasFor 'a', not 'c'."); + 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 + "]."); + } + + @Test + void forAnnotationTypeWhenAliasForHasMixedImplicitAndExplicitAliases() { + assertMixedImplicitAndExplicitAliases(AliasForWithMixedImplicitAndExplicitAliasesV1.class, "b"); + assertMixedImplicitAndExplicitAliases(AliasForWithMixedImplicitAndExplicitAliasesV2.class, "a"); + } + + private void assertMixedImplicitAndExplicitAliases(Class annotationType, String overriddenAttribute) { + String annotationName = annotationType.getName(); + 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 + "]."); } @Test @@ -641,6 +658,42 @@ private Object extractFromMap(Method attribute, Object map) { String c() default ""; } + @Retention(RetentionPolicy.RUNTIME) + @interface AliasPair { + + @AliasFor("b") + String a() default ""; + + @AliasFor("a") + String b() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @AliasPair + @interface AliasForWithMixedImplicitAndExplicitAliasesV1 { + + // attempted implicit alias via attribute override + @AliasFor(annotation = AliasPair.class, attribute = "b") + String b() default ""; + + // explicit local alias + @AliasFor("b") + String a() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @AliasPair + @interface AliasForWithMixedImplicitAndExplicitAliasesV2 { + + // attempted implicit alias via attribute override + @AliasFor(annotation = AliasPair.class, attribute = "a") + String b() default ""; + + // explicit local alias + @AliasFor("b") + String a() default ""; + } + @Retention(RetentionPolicy.RUNTIME) @interface AliasForNonMetaAnnotated { @@ -712,16 +765,6 @@ private Object extractFromMap(Method attribute, Object map) { String alias() default ""; } - @Retention(RetentionPolicy.RUNTIME) - @interface AliasPair { - - @AliasFor("b") - String a() default ""; - - @AliasFor("a") - String b() default ""; - } - @Retention(RetentionPolicy.RUNTIME) @interface ImplicitMirrorsTarget { From 1b172c1d20ecf96839abc02a67ae2a763af2815e Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 10 Dec 2019 15:10:13 +0000 Subject: [PATCH 0190/2315] Expose localAddress in WebFlux server Closes gh-24174 --- .../reactive/MockServerHttpRequest.java | 33 ++++++++++++++--- .../function/server/MockServerRequest.java | 33 +++++++++++++---- .../DefaultServerHttpRequestBuilder.java | 14 ++++---- .../reactive/ReactorServerHttpRequest.java | 7 +++- .../server/reactive/ServerHttpRequest.java | 9 +++++ .../reactive/ServerHttpRequestDecorator.java | 7 +++- .../reactive/ServletServerHttpRequest.java | 7 +++- .../reactive/UndertowServerHttpRequest.java | 5 +++ .../reactive/test/MockServerHttpRequest.java | 35 +++++++++++++++--- .../function/server/DefaultServerRequest.java | 5 +++ .../function/server/RequestPredicates.java | 5 +++ .../function/server/ServerRequest.java | 6 ++++ .../server/support/ServerRequestWrapper.java | 5 +++ .../function/server/MockServerRequest.java | 36 +++++++++++++++---- 14 files changed, 176 insertions(+), 31 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java b/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java index f94bacde936f..66c741eb6b9f 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -61,6 +61,9 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest { @Nullable private final InetSocketAddress remoteAddress; + @Nullable + private final InetSocketAddress localAddress; + @Nullable private final SslInfo sslInfo; @@ -69,13 +72,14 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest { private MockServerHttpRequest(HttpMethod httpMethod, URI uri, @Nullable String contextPath, HttpHeaders headers, MultiValueMap cookies, - @Nullable InetSocketAddress remoteAddress, @Nullable SslInfo sslInfo, - Publisher body) { + @Nullable InetSocketAddress remoteAddress, @Nullable InetSocketAddress localAddress, + @Nullable SslInfo sslInfo, Publisher body) { super(uri, contextPath, headers); this.httpMethod = httpMethod; this.cookies = cookies; this.remoteAddress = remoteAddress; + this.localAddress = localAddress; this.sslInfo = sslInfo; this.body = Flux.from(body); } @@ -97,6 +101,12 @@ public InetSocketAddress getRemoteAddress() { return this.remoteAddress; } + @Nullable + @Override + public InetSocketAddress getLocalAddress() { + return this.localAddress; + } + @Nullable @Override protected SslInfo initSslInfo() { @@ -254,6 +264,12 @@ public interface BaseBuilder> { */ B remoteAddress(InetSocketAddress remoteAddress); + /** + * Set the local address to return. + * @since 5.2.3 + */ + B localAddress(InetSocketAddress localAddress); + /** * Set SSL session information and certificates. */ @@ -408,6 +424,9 @@ private static class DefaultBodyBuilder implements BodyBuilder { @Nullable private InetSocketAddress remoteAddress; + @Nullable + private InetSocketAddress localAddress; + @Nullable private SslInfo sslInfo; @@ -441,6 +460,12 @@ public BodyBuilder remoteAddress(InetSocketAddress remoteAddress) { return this; } + @Override + public BodyBuilder localAddress(InetSocketAddress localAddress) { + this.localAddress = localAddress; + return this; + } + @Override public void sslInfo(SslInfo sslInfo) { this.sslInfo = sslInfo; @@ -545,7 +570,7 @@ private Charset getCharset() { public MockServerHttpRequest body(Publisher body) { applyCookiesIfNecessary(); return new MockServerHttpRequest(this.method, getUrlToUse(), this.contextPath, - this.headers, this.cookies, this.remoteAddress, this.sslInfo, body); + this.headers, this.cookies, this.remoteAddress, this.localAddress, this.sslInfo, body); } private void applyCookiesIfNecessary() { diff --git a/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java b/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java index 0ae85abbe176..d3dde94ada2e 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java @@ -93,6 +93,9 @@ public final class MockServerRequest implements ServerRequest { @Nullable private final InetSocketAddress remoteAddress; + @Nullable + private final InetSocketAddress localAddress; + private final List> messageReaders; @Nullable @@ -103,8 +106,8 @@ private MockServerRequest(HttpMethod method, URI uri, String contextPath, MockHe MultiValueMap cookies, @Nullable Object body, Map attributes, MultiValueMap queryParams, Map pathVariables, @Nullable WebSession session, @Nullable Principal principal, - @Nullable InetSocketAddress remoteAddress, List> messageReaders, - @Nullable ServerWebExchange exchange) { + @Nullable InetSocketAddress remoteAddress, @Nullable InetSocketAddress localAddress, + List> messageReaders, @Nullable ServerWebExchange exchange) { this.method = method; this.uri = uri; @@ -118,6 +121,7 @@ private MockServerRequest(HttpMethod method, URI uri, String contextPath, MockHe this.session = session; this.principal = principal; this.remoteAddress = remoteAddress; + this.localAddress = localAddress; this.messageReaders = messageReaders; this.exchange = exchange; } @@ -163,6 +167,11 @@ public Optional remoteAddress() { return Optional.ofNullable(this.remoteAddress); } + @Override + public Optional localAddress() { + return Optional.ofNullable(this.localAddress); + } + @Override public List> messageReaders() { return this.messageReaders; @@ -303,6 +312,8 @@ public interface Builder { Builder remoteAddress(InetSocketAddress remoteAddress); + Builder localAddress(InetSocketAddress localAddress); + Builder messageReaders(List> messageReaders); Builder exchange(ServerWebExchange exchange); @@ -343,6 +354,9 @@ private static class BuilderImpl implements Builder { @Nullable private InetSocketAddress remoteAddress; + @Nullable + private InetSocketAddress localAddress; + private List> messageReaders = HandlerStrategies.withDefaults().messageReaders(); @Nullable @@ -470,6 +484,13 @@ public Builder remoteAddress(InetSocketAddress remoteAddress) { return this; } + @Override + public Builder localAddress(InetSocketAddress localAddress) { + Assert.notNull(localAddress, "'localAddress' must not be null"); + this.localAddress = localAddress; + return this; + } + @Override public Builder messageReaders(List> messageReaders) { Assert.notNull(messageReaders, "'messageReaders' must not be null"); @@ -489,16 +510,16 @@ public MockServerRequest body(Object body) { this.body = body; return new MockServerRequest(this.method, this.uri, this.contextPath, this.headers, this.cookies, this.body, this.attributes, this.queryParams, this.pathVariables, - this.session, this.principal, this.remoteAddress, this.messageReaders, - this.exchange); + this.session, this.principal, this.remoteAddress, this.localAddress, + this.messageReaders, this.exchange); } @Override public MockServerRequest build() { return new MockServerRequest(this.method, this.uri, this.contextPath, this.headers, this.cookies, null, this.attributes, this.queryParams, this.pathVariables, - this.session, this.principal, this.remoteAddress, this.messageReaders, - this.exchange); + this.session, this.principal, this.remoteAddress, this.localAddress, + this.messageReaders, this.exchange); } } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/DefaultServerHttpRequestBuilder.java b/spring-web/src/main/java/org/springframework/http/server/reactive/DefaultServerHttpRequestBuilder.java index 963f5356d614..ce5a3d2b3739 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/DefaultServerHttpRequestBuilder.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/DefaultServerHttpRequestBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -181,9 +181,6 @@ private static class MutatedServerHttpRequest extends AbstractServerHttpRequest private final MultiValueMap cookies; - @Nullable - private final InetSocketAddress remoteAddress; - @Nullable private final SslInfo sslInfo; @@ -199,7 +196,6 @@ public MutatedServerHttpRequest(URI uri, @Nullable String contextPath, super(uri, contextPath, headers); this.methodValue = methodValue; this.cookies = cookies; - this.remoteAddress = originalRequest.getRemoteAddress(); this.sslInfo = sslInfo != null ? sslInfo : originalRequest.getSslInfo(); this.body = body; this.originalRequest = originalRequest; @@ -218,7 +214,13 @@ protected MultiValueMap initCookies() { @Nullable @Override public InetSocketAddress getRemoteAddress() { - return this.remoteAddress; + return this.originalRequest.getRemoteAddress(); + } + + @Nullable + @Override + public InetSocketAddress getLocalAddress() { + return this.originalRequest.getLocalAddress(); } @Nullable diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java index c6d60c01ab47..e05f992c97df 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -151,6 +151,11 @@ public InetSocketAddress getRemoteAddress() { return this.request.remoteAddress(); } + @Override + public InetSocketAddress getLocalAddress() { + return this.request.hostAddress(); + } + @Override @Nullable protected SslInfo initSslInfo() { diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequest.java index 47b2e4c128dc..fd866d13503c 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequest.java @@ -72,6 +72,15 @@ default InetSocketAddress getRemoteAddress() { return null; } + /** + * Return the local address the request was accepted on, if available. + * 5.2.3 + */ + @Nullable + default InetSocketAddress getLocalAddress() { + return null; + } + /** * Return the SSL session information if the request has been transmitted * over a secure protocol including SSL certificates, if available. diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java index c24f79ef4f65..a526108d4637 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -101,6 +101,11 @@ public InetSocketAddress getRemoteAddress() { return getDelegate().getRemoteAddress(); } + @Override + public InetSocketAddress getLocalAddress() { + return getDelegate().getLocalAddress(); + } + @Nullable @Override public SslInfo getSslInfo() { diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java index 9385b455f1d5..6ea6e9404d6b 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -178,6 +178,11 @@ public InetSocketAddress getRemoteAddress() { return new InetSocketAddress(this.request.getRemoteHost(), this.request.getRemotePort()); } + @Override + public InetSocketAddress getLocalAddress() { + return new InetSocketAddress(this.request.getLocalAddr(), this.request.getLocalPort()); + } + @Override @Nullable protected SslInfo initSslInfo() { diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java index 060804dfab8f..11b4418951f4 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java @@ -102,6 +102,11 @@ public InetSocketAddress getRemoteAddress() { return this.exchange.getSourceAddress(); } + @Override + public InetSocketAddress getLocalAddress() { + return this.exchange.getDestinationAddress(); + } + @Nullable @Override protected SslInfo initSslInfo() { diff --git a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java b/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java index 1615258e464a..3b7ecb116510 100644 --- a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java +++ b/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -52,7 +52,7 @@ * @author Rossen Stoyanchev * @since 5.0 */ -public class MockServerHttpRequest extends AbstractServerHttpRequest { +public final class MockServerHttpRequest extends AbstractServerHttpRequest { private final HttpMethod httpMethod; @@ -61,6 +61,9 @@ public class MockServerHttpRequest extends AbstractServerHttpRequest { @Nullable private final InetSocketAddress remoteAddress; + @Nullable + private final InetSocketAddress localAddress; + @Nullable private final SslInfo sslInfo; @@ -69,13 +72,14 @@ public class MockServerHttpRequest extends AbstractServerHttpRequest { private MockServerHttpRequest(HttpMethod httpMethod, URI uri, @Nullable String contextPath, HttpHeaders headers, MultiValueMap cookies, - @Nullable InetSocketAddress remoteAddress, @Nullable SslInfo sslInfo, - Publisher body) { + @Nullable InetSocketAddress remoteAddress, @Nullable InetSocketAddress localAddress, + @Nullable SslInfo sslInfo, Publisher body) { super(uri, contextPath, headers); this.httpMethod = httpMethod; this.cookies = cookies; this.remoteAddress = remoteAddress; + this.localAddress = localAddress; this.sslInfo = sslInfo; this.body = Flux.from(body); } @@ -97,6 +101,12 @@ public InetSocketAddress getRemoteAddress() { return this.remoteAddress; } + @Nullable + @Override + public InetSocketAddress getLocalAddress() { + return this.localAddress; + } + @Nullable @Override protected SslInfo initSslInfo() { @@ -254,6 +264,12 @@ public interface BaseBuilder> { */ B remoteAddress(InetSocketAddress remoteAddress); + /** + * Set the local address to return. + * @since 5.2.3 + */ + B localAddress(InetSocketAddress localAddress); + /** * Set SSL session information and certificates. */ @@ -408,6 +424,9 @@ private static class DefaultBodyBuilder implements BodyBuilder { @Nullable private InetSocketAddress remoteAddress; + @Nullable + private InetSocketAddress localAddress; + @Nullable private SslInfo sslInfo; @@ -441,6 +460,12 @@ public BodyBuilder remoteAddress(InetSocketAddress remoteAddress) { return this; } + @Override + public BodyBuilder localAddress(InetSocketAddress localAddress) { + this.localAddress = localAddress; + return this; + } + @Override public void sslInfo(SslInfo sslInfo) { this.sslInfo = sslInfo; @@ -545,7 +570,7 @@ private Charset getCharset() { public MockServerHttpRequest body(Publisher body) { applyCookiesIfNecessary(); return new MockServerHttpRequest(this.method, getUrlToUse(), this.contextPath, - this.headers, this.cookies, this.remoteAddress, this.sslInfo, body); + this.headers, this.cookies, this.remoteAddress, this.localAddress, this.sslInfo, body); } private void applyCookiesIfNecessary() { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java index cdfa46cb324f..74a6a710936c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java @@ -122,6 +122,11 @@ public Optional remoteAddress() { return Optional.ofNullable(request().getRemoteAddress()); } + @Override + public Optional localAddress() { + return Optional.ofNullable(request().getLocalAddress()); + } + @Override public List> messageReaders() { return this.messageReaders; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java index ee28004a90af..cbb3a1795dfa 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java @@ -947,6 +947,11 @@ public Optional remoteAddress() { return this.request.remoteAddress(); } + @Override + public Optional localAddress() { + return this.request.localAddress(); + } + @Override public List> messageReaders() { return this.request.messageReaders(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java index 72147d68985e..4bca08b45443 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java @@ -124,6 +124,12 @@ default PathContainer pathContainer() { */ Optional remoteAddress(); + /** + * Get the remote address to which this request is connected, if available. + * @since 5.2.3 + */ + Optional localAddress(); + /** * Get the readers used to convert the body of this request. * @since 5.1 diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java index 4ae5fea57b54..9b92d77cd1bc 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java @@ -123,6 +123,11 @@ public Optional remoteAddress() { return this.delegate.remoteAddress(); } + @Override + public Optional localAddress() { + return this.delegate.localAddress(); + } + @Override public List> messageReaders() { return this.delegate.messageReaders(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/MockServerRequest.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/MockServerRequest.java index 964140255832..4332dc4afa90 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/MockServerRequest.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/MockServerRequest.java @@ -61,7 +61,7 @@ * @author Arjen Poutsma * @since 5.0 */ -public class MockServerRequest implements ServerRequest { +public final class MockServerRequest implements ServerRequest { private final HttpMethod method; @@ -91,6 +91,9 @@ public class MockServerRequest implements ServerRequest { @Nullable private final InetSocketAddress remoteAddress; + @Nullable + private final InetSocketAddress localAddress; + private final List> messageReaders; @Nullable @@ -101,8 +104,8 @@ private MockServerRequest(HttpMethod method, URI uri, String contextPath, MockHe MultiValueMap cookies, @Nullable Object body, Map attributes, MultiValueMap queryParams, Map pathVariables, @Nullable WebSession session, @Nullable Principal principal, - @Nullable InetSocketAddress remoteAddress, List> messageReaders, - @Nullable ServerWebExchange exchange) { + @Nullable InetSocketAddress remoteAddress, @Nullable InetSocketAddress localAddress, + List> messageReaders, @Nullable ServerWebExchange exchange) { this.method = method; this.uri = uri; @@ -116,6 +119,7 @@ private MockServerRequest(HttpMethod method, URI uri, String contextPath, MockHe this.session = session; this.principal = principal; this.remoteAddress = remoteAddress; + this.localAddress = localAddress; this.messageReaders = messageReaders; this.exchange = exchange; } @@ -161,6 +165,11 @@ public Optional remoteAddress() { return Optional.ofNullable(this.remoteAddress); } + @Override + public Optional localAddress() { + return Optional.ofNullable(this.localAddress); + } + @Override public List> messageReaders() { return this.messageReaders; @@ -291,6 +300,7 @@ public interface Builder { Builder session(WebSession session); /** + * Sets the request {@link Principal}. * @deprecated in favor of {@link #principal(Principal)} */ @Deprecated @@ -300,6 +310,8 @@ public interface Builder { Builder remoteAddress(InetSocketAddress remoteAddress); + Builder localAddress(InetSocketAddress localAddress); + Builder messageReaders(List> messageReaders); Builder exchange(ServerWebExchange exchange); @@ -340,6 +352,9 @@ private static class BuilderImpl implements Builder { @Nullable private InetSocketAddress remoteAddress; + @Nullable + private InetSocketAddress localAddress; + private List> messageReaders = HandlerStrategies.withDefaults().messageReaders(); @Nullable @@ -467,6 +482,13 @@ public Builder remoteAddress(InetSocketAddress remoteAddress) { return this; } + @Override + public Builder localAddress(InetSocketAddress localAddress) { + Assert.notNull(localAddress, "'localAddress' must not be null"); + this.localAddress = localAddress; + return this; + } + @Override public Builder messageReaders(List> messageReaders) { Assert.notNull(messageReaders, "'messageReaders' must not be null"); @@ -486,16 +508,16 @@ public MockServerRequest body(Object body) { this.body = body; return new MockServerRequest(this.method, this.uri, this.contextPath, this.headers, this.cookies, this.body, this.attributes, this.queryParams, this.pathVariables, - this.session, this.principal, this.remoteAddress, this.messageReaders, - this.exchange); + this.session, this.principal, this.remoteAddress, this.localAddress, + this.messageReaders, this.exchange); } @Override public MockServerRequest build() { return new MockServerRequest(this.method, this.uri, this.contextPath, this.headers, this.cookies, null, this.attributes, this.queryParams, this.pathVariables, - this.session, this.principal, this.remoteAddress, this.messageReaders, - this.exchange); + this.session, this.principal, this.remoteAddress, this.localAddress, + this.messageReaders, this.exchange); } } From f180bf7652dc1cde3191b98c5fe208d440e414ed Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 10 Dec 2019 15:18:04 +0000 Subject: [PATCH 0191/2315] Add "application/*+xml" to XML decoders Closes gh-24164 --- .../org/springframework/http/codec/xml/Jaxb2XmlDecoder.java | 3 ++- .../org/springframework/http/codec/xml/XmlEventDecoder.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/xml/Jaxb2XmlDecoder.java b/spring-web/src/main/java/org/springframework/http/codec/xml/Jaxb2XmlDecoder.java index 4e341a9d0ed0..c364094af3f5 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/xml/Jaxb2XmlDecoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/xml/Jaxb2XmlDecoder.java @@ -52,6 +52,7 @@ import org.springframework.core.io.buffer.DataBufferLimitException; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.log.LogFormatUtils; +import org.springframework.http.MediaType; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -92,7 +93,7 @@ public class Jaxb2XmlDecoder extends AbstractDecoder { public Jaxb2XmlDecoder() { - super(MimeTypeUtils.APPLICATION_XML, MimeTypeUtils.TEXT_XML); + super(MimeTypeUtils.APPLICATION_XML, MimeTypeUtils.TEXT_XML, new MediaType("application", "*+xml")); } /** diff --git a/spring-web/src/main/java/org/springframework/http/codec/xml/XmlEventDecoder.java b/spring-web/src/main/java/org/springframework/http/codec/xml/XmlEventDecoder.java index 2305525a0998..f3008b948759 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/xml/XmlEventDecoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/xml/XmlEventDecoder.java @@ -42,6 +42,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferLimitException; import org.springframework.core.io.buffer.DataBufferUtils; +import org.springframework.http.MediaType; import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import org.springframework.util.MimeType; @@ -94,7 +95,7 @@ public class XmlEventDecoder extends AbstractDecoder { public XmlEventDecoder() { - super(MimeTypeUtils.APPLICATION_XML, MimeTypeUtils.TEXT_XML); + super(MimeTypeUtils.APPLICATION_XML, MimeTypeUtils.TEXT_XML, new MediaType("application", "*+xml")); } From c8bce9686f3dca2013aee875b3c86d87aa897662 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 10 Dec 2019 15:38:28 +0000 Subject: [PATCH 0192/2315] ContentDisposition trims charset in filename Closes gh-24112 --- .../java/org/springframework/http/ContentDisposition.java | 2 +- .../org/springframework/http/ContentDispositionTests.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java index 37d912005751..ac77d45c7e65 100644 --- a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java +++ b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java @@ -282,7 +282,7 @@ else if (attribute.equals("filename*") ) { int idx1 = value.indexOf('\''); int idx2 = value.indexOf('\'', idx1 + 1); if (idx1 != -1 && idx2 != -1) { - charset = Charset.forName(value.substring(0, idx1)); + charset = Charset.forName(value.substring(0, idx1).trim()); Assert.isTrue(UTF_8.equals(charset) || ISO_8859_1.equals(charset), "Charset should be UTF-8 or ISO-8859-1"); filename = decodeFilename(value.substring(idx2 + 1), charset); diff --git a/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java b/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java index a647871b0e6b..26b5ae57eab8 100644 --- a/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java +++ b/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java @@ -70,6 +70,14 @@ public void parseEncodedFilename() { .build()); } + @Test // gh-24112 + public void parseEncodedFilenameWithPaddedCharset() { + assertThat(parse("attachment; filename*= UTF-8''some-file.zip")) + .isEqualTo(ContentDisposition.builder("attachment") + .filename("some-file.zip", StandardCharsets.UTF_8) + .build()); + } + @Test public void parseEncodedFilenameWithoutCharset() { assertThat(parse("form-data; name=\"name\"; filename*=test.txt")) From 70a0c93d6916efa60a338906277ab9b543acffb1 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 10 Dec 2019 16:01:33 +0000 Subject: [PATCH 0193/2315] Correct WebFlux docs on BindingResult with @RequestBody Closes gh-22997 --- src/docs/asciidoc/web/webflux.adoc | 44 +++++++++++++----------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index b6e03ff12844..b0493abda2c8 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -1857,9 +1857,8 @@ and others) and is equivalent to `required=false`. See "`Any other argument`" later in this table. | `Errors`, `BindingResult` -| For access to errors from validation and data binding for a command object - (that is, a `@ModelAttribute` argument) or errors from the validation of a `@RequestBody` or - `@RequestPart` argument. An `Errors`, or `BindingResult` argument must be declared +| For access to errors from validation and data binding for a command object, i.e. a + `@ModelAttribute` argument. An `Errors`, or `BindingResult` argument must be declared immediately after the validated method argument. | `SessionStatus` + class-level `@SessionAttributes` @@ -2707,35 +2706,30 @@ you can declare a concrete target `Object`, instead of `Part`, as the following ---- <1> Using `@RequestPart` to get the metadata. -You can use `@RequestPart` combination with `javax.validation.Valid` or Spring's -`@Validated` annotation, which causes Standard Bean Validation to be applied. -By default, validation errors cause a `WebExchangeBindException`, which is turned -into a 400 (`BAD_REQUEST`) response. Alternatively, you can handle validation errors locally -within the controller through an `Errors` or `BindingResult` argument, as the following example shows: +You can use `@RequestPart` in combination with `javax.validation.Valid` or Spring's +`@Validated` annotation, which causes Standard Bean Validation to be applied. Validation +errors lead to a `WebExchangeBindException` that results in a 400 (BAD_REQUEST) response. +The exception contains a `BindingResult` with the error details and can also be handled +in the controller method by declaring the argument with an async wrapper and then using +error related operators: [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java ---- @PostMapping("/") - public String handle(@Valid @RequestPart("meta-data") MetaData metadata, // <1> - BindingResult result) { <2> - // ... + public String handle(@Valid @RequestPart("meta-data") Mono metadata) { + // use one of the onError* operators... } ---- -<1> Using a `@Valid` annotation. -<2> Using a `BindingResult` argument. [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin ---- @PostMapping("/") - fun handle(@Valid @RequestPart("meta-data") metadata: MetaData, // <1> - result: BindingResult): String { // <2> + fun handle(@Valid @RequestPart("meta-data") metadata: MetaData): String { // ... } ---- -<1> Using a `@Valid` annotation. -<2> Using a `BindingResult` argument. To access all multipart data as a `MultiValueMap`, you can use `@RequestBody`, as the following example shows: @@ -2835,25 +2829,25 @@ You can use the <> option of the < account) { + // use one of the onError* operators... } ---- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin ---- @PostMapping("/accounts") - fun handle(@Valid @RequestBody account: Account, result: BindingResult) { + fun handle(@Valid @RequestBody account: Mono) { // ... } ---- From 9b30d46ff4653c411ee4c8edb89b9bafa11b2ee9 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 10 Dec 2019 16:37:31 +0000 Subject: [PATCH 0194/2315] JSON charset handling in StringHttpMessageConverter This commit restores the interpretation of JSON as UTF-8 by default that was removed in #bc205e0 and also ensures a charset is not appended automatically to "application/json". Closes gh-24123 --- .../converter/StringHttpMessageConverter.java | 16 ++++++++++++++ .../StringHttpMessageConverterTests.java | 22 +++++++++++++++++++ ...nnotationControllerHandlerMethodTests.java | 4 ++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java index d1365943a5a8..7abccf5a06fd 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java @@ -100,6 +100,18 @@ protected Long getContentLength(String str, @Nullable MediaType contentType) { return (long) str.getBytes(charset).length; } + + @Override + protected void addDefaultHeaders(HttpHeaders headers, String s, @Nullable MediaType mediaType) throws IOException { + if (headers.getContentType() == null ) { + if (mediaType != null && mediaType.isCompatibleWith(MediaType.APPLICATION_JSON)) { + // Prevent charset parameter for JSON.. + headers.setContentType(mediaType); + } + } + super.addDefaultHeaders(headers, s, mediaType); + } + @Override protected void writeInternal(String str, HttpOutputMessage outputMessage) throws IOException { HttpHeaders headers = outputMessage.getHeaders(); @@ -130,6 +142,10 @@ private Charset getContentTypeCharset(@Nullable MediaType contentType) { if (contentType != null && contentType.getCharset() != null) { return contentType.getCharset(); } + else if (contentType != null && contentType.isCompatibleWith(MediaType.APPLICATION_JSON)) { + // Matching to AbstractJackson2HttpMessageConverter#DEFAULT_CHARSET + return StandardCharsets.UTF_8; + } else { Charset charset = getDefaultCharset(); Assert.state(charset != null, "No default charset"); diff --git a/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java index 8c66bc4de965..c0e8792d33f6 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java @@ -70,6 +70,16 @@ public void read() throws IOException { assertThat(result).as("Invalid result").isEqualTo(body); } + @Test // gh-24123 + public void readJson() throws IOException { + String body = "{\"result\":\"\u0414\u0410\"}"; + MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8)); + inputMessage.getHeaders().setContentType(MediaType.APPLICATION_JSON); + String result = this.converter.read(String.class, inputMessage); + + assertThat(result).as("Invalid result").isEqualTo(body); + } + @Test public void writeDefaultCharset() throws IOException { String body = "H\u00e9llo W\u00f6rld"; @@ -82,6 +92,18 @@ public void writeDefaultCharset() throws IOException { assertThat(headers.getAcceptCharset().isEmpty()).isTrue(); } + @Test // gh-24123 + public void writeJson() throws IOException { + String body = "{\"foo\":\"bar\"}"; + this.converter.write(body, MediaType.APPLICATION_JSON, this.outputMessage); + + HttpHeaders headers = this.outputMessage.getHeaders(); + assertThat(this.outputMessage.getBodyAsString(StandardCharsets.UTF_8)).isEqualTo(body); + assertThat(headers.getContentType()).isEqualTo(MediaType.APPLICATION_JSON); + assertThat(headers.getContentLength()).isEqualTo(body.getBytes(StandardCharsets.UTF_8).length); + assertThat(headers.getAcceptCharset().isEmpty()).isTrue(); + } + @Test public void writeUTF8() throws IOException { String body = "H\u00e9llo W\u00f6rld"; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index 502b11ab5c8f..565f785d296f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -1011,7 +1011,7 @@ public void overlappingMessageConvertersRequestBody() throws Exception { request.addHeader("Accept", "application/json, text/javascript, */*"); MockHttpServletResponse response = new MockHttpServletResponse(); getServlet().service(request, response); - assertThat(response.getHeader("Content-Type")).as("Invalid content-type").isEqualTo("application/json;charset=ISO-8859-1"); + assertThat(response.getHeader("Content-Type")).as("Invalid content-type").isEqualTo("application/json"); } @Test @@ -1548,7 +1548,7 @@ public void testHeadersCondition() throws Exception { getServlet().service(request, response); assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.getHeader("Content-Type")).isEqualTo("application/json;charset=ISO-8859-1"); + assertThat(response.getHeader("Content-Type")).isEqualTo("application/json"); assertThat(response.getContentAsString()).isEqualTo("homeJson"); } From 76bc5815288140b9d634333900228df10e92577a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 10 Dec 2019 22:06:22 +0100 Subject: [PATCH 0195/2315] Polishing --- .../SynthesizedMergedAnnotationInvocationHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java b/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java index 1a19f499e257..e226accd5c6b 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java @@ -134,8 +134,8 @@ private Integer computeHashCode() { } private int getValueHashCode(Object value) { - // Use Arrays.hashCode since ObjectUtils doesn't comply to to - // Annotation#hashCode() + // Use Arrays.hashCode(...) since Spring's ObjectUtils doesn't comply + // with the requirements specified in Annotation#hashCode(). if (value instanceof boolean[]) { return Arrays.hashCode((boolean[]) value); } From 16ed7e2a19c074b26a99acc43fddb373db752fb7 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 10 Dec 2019 22:08:26 +0100 Subject: [PATCH 0196/2315] Only load enclosing class for TYPE_HIERARCHY_AND_ENCLOSING_CLASSES strategy Prior to this commit, the enclosing class was always eagerly loaded even if the annotation search strategy was not explicitly TYPE_HIERARCHY_AND_ENCLOSING_CLASSES. See gh-24136 --- .../core/annotation/AnnotationsScanner.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java index de1323493690..c41a67b73dfb 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java @@ -230,12 +230,14 @@ private static R processClassHierarchy(C context, int[] aggregateIndex, C return superclassResult; } } - Class enclosingClass = source.getEnclosingClass(); - if (includeEnclosing && enclosingClass != null) { - R enclosingResult = processClassHierarchy(context, aggregateIndex, + if (includeEnclosing) { + Class enclosingClass = source.getEnclosingClass(); + if (enclosingClass != null) { + R enclosingResult = processClassHierarchy(context, aggregateIndex, enclosingClass, processor, classFilter, includeInterfaces, true); - if (enclosingResult != null) { - return enclosingResult; + if (enclosingResult != null) { + return enclosingResult; + } } } return null; From 6e21b19999e967e4f4933bfda10b7a85206def34 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 10 Dec 2019 22:38:55 +0100 Subject: [PATCH 0197/2315] Make TYPE_HIERARCHY_AND_ENCLOSING_CLASSES annotation search strategy defensive Prior to this commit, when searching for annotations using the TYPE_HIERARCHY_AND_ENCLOSING_CLASSES strategy an exception could be thrown while attempting to load the enclosing class (e.g., a NoClassDefFoundError), thereby halting the entire annotation scanning process. This commit makes this search strategy defensive by logging exceptions encountered while processing the enclosing class hierarchy instead of allowing the exception to halt the entire annotation scanning process. The exception handling is performed by AnnotationUtils.handleIntrospectionFailure() which only allows an AnnotationConfigurationException to propagate. See gh-24136 --- .../core/annotation/AnnotationUtils.java | 9 ++++---- .../core/annotation/AnnotationsScanner.java | 22 ++++++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index f27e81ac802d..f80d0c7c335c 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -1087,16 +1087,17 @@ private static void rethrowAnnotationConfigurationException(Throwable ex) { *

    If the supplied exception is an {@link AnnotationConfigurationException}, * it will simply be thrown, allowing it to propagate to the caller, and * nothing will be logged. - *

    Otherwise, this method logs an introspection failure (in particular - * {@code TypeNotPresentExceptions}) before moving on, assuming nested - * Class values were not resolvable within annotation attributes and + *

    Otherwise, this method logs an introspection failure (in particular for + * a {@link TypeNotPresentException}) before moving on, assuming nested + * {@code Class} values were not resolvable within annotation attributes and * thereby effectively pretending there were no annotations on the specified * element. * @param element the element that we tried to introspect annotations on * @param ex the exception that we encountered * @see #rethrowAnnotationConfigurationException + * @see IntrospectionFailureLogger */ - private static void handleIntrospectionFailure(@Nullable AnnotatedElement element, Throwable ex) { + static void handleIntrospectionFailure(@Nullable AnnotatedElement element, Throwable ex) { rethrowAnnotationConfigurationException(ex); IntrospectionFailureLogger logger = IntrospectionFailureLogger.INFO; boolean meta = false; diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java index c41a67b73dfb..33c1ce305c71 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java @@ -231,14 +231,24 @@ private static R processClassHierarchy(C context, int[] aggregateIndex, C } } if (includeEnclosing) { - Class enclosingClass = source.getEnclosingClass(); - if (enclosingClass != null) { - R enclosingResult = processClassHierarchy(context, aggregateIndex, - enclosingClass, processor, classFilter, includeInterfaces, true); - if (enclosingResult != null) { - return enclosingResult; + // Since merely attempting to load the enclosing class may result in + // automatic loading of sibling nested classes that in turn results + // in an exception such as NoClassDefFoundError, we wrap the following + // in its own dedicated try-catch block in order not to preemptively + // halt the annotation scanning process. + try { + Class enclosingClass = source.getEnclosingClass(); + if (enclosingClass != null) { + R enclosingResult = processClassHierarchy(context, aggregateIndex, + enclosingClass, processor, classFilter, includeInterfaces, true); + if (enclosingResult != null) { + return enclosingResult; + } } } + catch (Throwable ex) { + AnnotationUtils.handleIntrospectionFailure(source, ex); + } } return null; } From 8ac222467b65bb3fde8efd83cd5b1c63800c5141 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 12 Dec 2019 00:46:47 +0900 Subject: [PATCH 0198/2315] Short-circuit boolean logic in AbstractBeanDefinition.equals() Closes gh-24185 --- .../support/AbstractBeanDefinition.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java index 96887d80e2d1..6912cfe2e280 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java @@ -1161,30 +1161,30 @@ public boolean equals(@Nullable Object other) { return false; } AbstractBeanDefinition that = (AbstractBeanDefinition) other; - boolean rtn = ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName()); - rtn = rtn && ObjectUtils.nullSafeEquals(this.scope, that.scope); - rtn = rtn && this.abstractFlag == that.abstractFlag; - rtn = rtn && this.lazyInit == that.lazyInit; - rtn = rtn && this.autowireMode == that.autowireMode; - rtn = rtn && this.dependencyCheck == that.dependencyCheck; - rtn = rtn && Arrays.equals(this.dependsOn, that.dependsOn); - rtn = rtn && this.autowireCandidate == that.autowireCandidate; - rtn = rtn && ObjectUtils.nullSafeEquals(this.qualifiers, that.qualifiers); - rtn = rtn && this.primary == that.primary; - rtn = rtn && this.nonPublicAccessAllowed == that.nonPublicAccessAllowed; - rtn = rtn && this.lenientConstructorResolution == that.lenientConstructorResolution; - rtn = rtn && ObjectUtils.nullSafeEquals(this.constructorArgumentValues, that.constructorArgumentValues); - rtn = rtn && ObjectUtils.nullSafeEquals(this.propertyValues, that.propertyValues); - rtn = rtn && ObjectUtils.nullSafeEquals(this.methodOverrides, that.methodOverrides); - rtn = rtn && ObjectUtils.nullSafeEquals(this.factoryBeanName, that.factoryBeanName); - rtn = rtn && ObjectUtils.nullSafeEquals(this.factoryMethodName, that.factoryMethodName); - rtn = rtn && ObjectUtils.nullSafeEquals(this.initMethodName, that.initMethodName); - rtn = rtn && this.enforceInitMethod == that.enforceInitMethod; - rtn = rtn && ObjectUtils.nullSafeEquals(this.destroyMethodName, that.destroyMethodName); - rtn = rtn && this.enforceDestroyMethod == that.enforceDestroyMethod; - rtn = rtn && this.synthetic == that.synthetic; - rtn = rtn && this.role == that.role; - return rtn && super.equals(other); + return ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName()) + && ObjectUtils.nullSafeEquals(this.scope, that.scope) + && this.abstractFlag == that.abstractFlag + && this.lazyInit == that.lazyInit + && this.autowireMode == that.autowireMode + && this.dependencyCheck == that.dependencyCheck + && Arrays.equals(this.dependsOn, that.dependsOn) + && this.autowireCandidate == that.autowireCandidate + && ObjectUtils.nullSafeEquals(this.qualifiers, that.qualifiers) + && this.primary == that.primary + && this.nonPublicAccessAllowed == that.nonPublicAccessAllowed + && this.lenientConstructorResolution == that.lenientConstructorResolution + && ObjectUtils.nullSafeEquals(this.constructorArgumentValues, that.constructorArgumentValues) + && ObjectUtils.nullSafeEquals(this.propertyValues, that.propertyValues) + && ObjectUtils.nullSafeEquals(this.methodOverrides, that.methodOverrides) + && ObjectUtils.nullSafeEquals(this.factoryBeanName, that.factoryBeanName) + && ObjectUtils.nullSafeEquals(this.factoryMethodName, that.factoryMethodName) + && ObjectUtils.nullSafeEquals(this.initMethodName, that.initMethodName) + && this.enforceInitMethod == that.enforceInitMethod + && ObjectUtils.nullSafeEquals(this.destroyMethodName, that.destroyMethodName) + && this.enforceDestroyMethod == that.enforceDestroyMethod + && this.synthetic == that.synthetic + && this.role == that.role + && super.equals(other); } @Override From 9af8dc0980c8e0ab4105c9cd6cfec7c869418cb1 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 11 Dec 2019 17:04:49 +0100 Subject: [PATCH 0199/2315] Polishing --- .../beans/CachedIntrospectionResults.java | 9 ++-- .../support/AbstractBeanDefinition.java | 48 +++++++++---------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java index ca14d6995d20..5b0af83467fb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java +++ b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -43,9 +43,9 @@ * Internal class that caches JavaBeans {@link java.beans.PropertyDescriptor} * information for a Java class. Not intended for direct use by application code. * - *

    Necessary for own caching of descriptors within the application's - * ClassLoader, rather than rely on the JDK's system-wide BeanInfo cache - * (in order to avoid leaks on ClassLoader shutdown). + *

    Necessary for Spring's own caching of bean descriptors within the application + * {@link ClassLoader}, rather than relying on the JDK's system-wide {@link BeanInfo} + * cache (in order to avoid leaks on individual application shutdown in a shared JVM). * *

    Information is cached statically, so we don't need to create new * objects of this class for every JavaBean we manipulate. Hence, this class @@ -163,7 +163,6 @@ public static void clearClassLoader(@Nullable ClassLoader classLoader) { * @return the corresponding CachedIntrospectionResults * @throws BeansException in case of introspection failure */ - @SuppressWarnings("unchecked") static CachedIntrospectionResults forClass(Class beanClass) throws BeansException { CachedIntrospectionResults results = strongClassCache.get(beanClass); if (results != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java index 6912cfe2e280..0fccf96455c8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java @@ -1161,30 +1161,30 @@ public boolean equals(@Nullable Object other) { return false; } AbstractBeanDefinition that = (AbstractBeanDefinition) other; - return ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName()) - && ObjectUtils.nullSafeEquals(this.scope, that.scope) - && this.abstractFlag == that.abstractFlag - && this.lazyInit == that.lazyInit - && this.autowireMode == that.autowireMode - && this.dependencyCheck == that.dependencyCheck - && Arrays.equals(this.dependsOn, that.dependsOn) - && this.autowireCandidate == that.autowireCandidate - && ObjectUtils.nullSafeEquals(this.qualifiers, that.qualifiers) - && this.primary == that.primary - && this.nonPublicAccessAllowed == that.nonPublicAccessAllowed - && this.lenientConstructorResolution == that.lenientConstructorResolution - && ObjectUtils.nullSafeEquals(this.constructorArgumentValues, that.constructorArgumentValues) - && ObjectUtils.nullSafeEquals(this.propertyValues, that.propertyValues) - && ObjectUtils.nullSafeEquals(this.methodOverrides, that.methodOverrides) - && ObjectUtils.nullSafeEquals(this.factoryBeanName, that.factoryBeanName) - && ObjectUtils.nullSafeEquals(this.factoryMethodName, that.factoryMethodName) - && ObjectUtils.nullSafeEquals(this.initMethodName, that.initMethodName) - && this.enforceInitMethod == that.enforceInitMethod - && ObjectUtils.nullSafeEquals(this.destroyMethodName, that.destroyMethodName) - && this.enforceDestroyMethod == that.enforceDestroyMethod - && this.synthetic == that.synthetic - && this.role == that.role - && super.equals(other); + return (ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName()) && + ObjectUtils.nullSafeEquals(this.scope, that.scope) && + this.abstractFlag == that.abstractFlag && + this.lazyInit == that.lazyInit && + this.autowireMode == that.autowireMode && + this.dependencyCheck == that.dependencyCheck && + Arrays.equals(this.dependsOn, that.dependsOn) && + this.autowireCandidate == that.autowireCandidate && + ObjectUtils.nullSafeEquals(this.qualifiers, that.qualifiers) && + this.primary == that.primary && + this.nonPublicAccessAllowed == that.nonPublicAccessAllowed && + this.lenientConstructorResolution == that.lenientConstructorResolution && + ObjectUtils.nullSafeEquals(this.constructorArgumentValues, that.constructorArgumentValues) && + ObjectUtils.nullSafeEquals(this.propertyValues, that.propertyValues) && + ObjectUtils.nullSafeEquals(this.methodOverrides, that.methodOverrides) && + ObjectUtils.nullSafeEquals(this.factoryBeanName, that.factoryBeanName) && + ObjectUtils.nullSafeEquals(this.factoryMethodName, that.factoryMethodName) && + ObjectUtils.nullSafeEquals(this.initMethodName, that.initMethodName) && + this.enforceInitMethod == that.enforceInitMethod && + ObjectUtils.nullSafeEquals(this.destroyMethodName, that.destroyMethodName) && + this.enforceDestroyMethod == that.enforceDestroyMethod && + this.synthetic == that.synthetic && + this.role == that.role && + super.equals(other)); } @Override From d757f739028c7608b0d870bf0e9f23b91e57298b Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 11 Dec 2019 18:22:13 +0100 Subject: [PATCH 0200/2315] Handle exceptions in annotation searches again Prior to Spring Framework 5.2, most annotation search algorithms made use of AnnotationUtils.handleIntrospectionFailure() to handle exceptions thrown while attempting to introspect annotation metadata. With the introduction of the new MergedAnnotation API in Spring Framework 5.2, this exception handling was accidentally removed. This commit introduces the use of handleIntrospectionFailure() within the new MergedAnnotation internals in order to (hopefully) align with the previous behavior. Closes gh-24188 --- .../core/annotation/AnnotationsScanner.java | 276 ++++++++++-------- 1 file changed, 151 insertions(+), 125 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java index 33c1ce305c71..67ccd303244f 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java @@ -136,51 +136,56 @@ private static R processClass(C context, Class source, private static R processClassInheritedAnnotations(C context, Class source, SearchStrategy searchStrategy, AnnotationsProcessor processor, @Nullable BiPredicate> classFilter) { - if (isWithoutHierarchy(source, searchStrategy)) { - return processElement(context, source, processor, classFilter); - } - Annotation[] relevant = null; - int remaining = Integer.MAX_VALUE; - int aggregateIndex = 0; - Class root = source; - while (source != null && source != Object.class && remaining > 0 && - !hasPlainJavaAnnotationsOnly(source)) { - R result = processor.doWithAggregate(context, aggregateIndex); - if (result != null) { - return result; - } - if (isFiltered(source, context, classFilter)) { - continue; - } - Annotation[] declaredAnnotations = - getDeclaredAnnotations(context, source, classFilter, true); - if (relevant == null && declaredAnnotations.length > 0) { - relevant = root.getAnnotations(); - remaining = relevant.length; + try { + if (isWithoutHierarchy(source, searchStrategy)) { + return processElement(context, source, processor, classFilter); } - for (int i = 0; i < declaredAnnotations.length; i++) { - if (declaredAnnotations[i] != null) { - boolean isRelevant = false; - for (int relevantIndex = 0; relevantIndex < relevant.length; relevantIndex++) { - if (relevant[relevantIndex] != null && - declaredAnnotations[i].annotationType() == relevant[relevantIndex].annotationType()) { - isRelevant = true; - relevant[relevantIndex] = null; - remaining--; - break; + Annotation[] relevant = null; + int remaining = Integer.MAX_VALUE; + int aggregateIndex = 0; + Class root = source; + while (source != null && source != Object.class && remaining > 0 && + !hasPlainJavaAnnotationsOnly(source)) { + R result = processor.doWithAggregate(context, aggregateIndex); + if (result != null) { + return result; + } + if (isFiltered(source, context, classFilter)) { + continue; + } + Annotation[] declaredAnnotations = + getDeclaredAnnotations(context, source, classFilter, true); + if (relevant == null && declaredAnnotations.length > 0) { + relevant = root.getAnnotations(); + remaining = relevant.length; + } + for (int i = 0; i < declaredAnnotations.length; i++) { + if (declaredAnnotations[i] != null) { + boolean isRelevant = false; + for (int relevantIndex = 0; relevantIndex < relevant.length; relevantIndex++) { + if (relevant[relevantIndex] != null && + declaredAnnotations[i].annotationType() == relevant[relevantIndex].annotationType()) { + isRelevant = true; + relevant[relevantIndex] = null; + remaining--; + break; + } + } + if (!isRelevant) { + declaredAnnotations[i] = null; } - } - if (!isRelevant) { - declaredAnnotations[i] = null; } } + result = processor.doWithAnnotations(context, aggregateIndex, source, declaredAnnotations); + if (result != null) { + return result; + } + source = source.getSuperclass(); + aggregateIndex++; } - result = processor.doWithAnnotations(context, aggregateIndex, source, declaredAnnotations); - if (result != null) { - return result; - } - source = source.getSuperclass(); - aggregateIndex++; + } + catch (Throwable ex) { + AnnotationUtils.handleIntrospectionFailure(source, ex); } return null; } @@ -190,8 +195,7 @@ private static R processClassHierarchy(C context, Class source, AnnotationsProcessor processor, @Nullable BiPredicate> classFilter, boolean includeInterfaces, boolean includeEnclosing) { - int[] aggregateIndex = new int[] {0}; - return processClassHierarchy(context, aggregateIndex, source, processor, + return processClassHierarchy(context, new int[] {0}, source, processor, classFilter, includeInterfaces, includeEnclosing); } @@ -200,56 +204,61 @@ private static R processClassHierarchy(C context, int[] aggregateIndex, C AnnotationsProcessor processor, @Nullable BiPredicate> classFilter, boolean includeInterfaces, boolean includeEnclosing) { - R result = processor.doWithAggregate(context, aggregateIndex[0]); - if (result != null) { - return result; - } - if (hasPlainJavaAnnotationsOnly(source)) { - return null; - } - Annotation[] annotations = getDeclaredAnnotations(context, source, classFilter, false); - result = processor.doWithAnnotations(context, aggregateIndex[0], source, annotations); - if (result != null) { - return result; - } - aggregateIndex[0]++; - if (includeInterfaces) { - for (Class interfaceType : source.getInterfaces()) { - R interfacesResult = processClassHierarchy(context, aggregateIndex, + try { + R result = processor.doWithAggregate(context, aggregateIndex[0]); + if (result != null) { + return result; + } + if (hasPlainJavaAnnotationsOnly(source)) { + return null; + } + Annotation[] annotations = getDeclaredAnnotations(context, source, classFilter, false); + result = processor.doWithAnnotations(context, aggregateIndex[0], source, annotations); + if (result != null) { + return result; + } + aggregateIndex[0]++; + if (includeInterfaces) { + for (Class interfaceType : source.getInterfaces()) { + R interfacesResult = processClassHierarchy(context, aggregateIndex, interfaceType, processor, classFilter, true, includeEnclosing); - if (interfacesResult != null) { - return interfacesResult; + if (interfacesResult != null) { + return interfacesResult; + } } } - } - Class superclass = source.getSuperclass(); - if (superclass != Object.class && superclass != null) { - R superclassResult = processClassHierarchy(context, aggregateIndex, + Class superclass = source.getSuperclass(); + if (superclass != Object.class && superclass != null) { + R superclassResult = processClassHierarchy(context, aggregateIndex, superclass, processor, classFilter, includeInterfaces, includeEnclosing); - if (superclassResult != null) { - return superclassResult; + if (superclassResult != null) { + return superclassResult; + } } - } - if (includeEnclosing) { - // Since merely attempting to load the enclosing class may result in - // automatic loading of sibling nested classes that in turn results - // in an exception such as NoClassDefFoundError, we wrap the following - // in its own dedicated try-catch block in order not to preemptively - // halt the annotation scanning process. - try { - Class enclosingClass = source.getEnclosingClass(); - if (enclosingClass != null) { - R enclosingResult = processClassHierarchy(context, aggregateIndex, - enclosingClass, processor, classFilter, includeInterfaces, true); - if (enclosingResult != null) { - return enclosingResult; + if (includeEnclosing) { + // Since merely attempting to load the enclosing class may result in + // automatic loading of sibling nested classes that in turn results + // in an exception such as NoClassDefFoundError, we wrap the following + // in its own dedicated try-catch block in order not to preemptively + // halt the annotation scanning process. + try { + Class enclosingClass = source.getEnclosingClass(); + if (enclosingClass != null) { + R enclosingResult = processClassHierarchy(context, aggregateIndex, + enclosingClass, processor, classFilter, includeInterfaces, true); + if (enclosingResult != null) { + return enclosingResult; + } } } - } - catch (Throwable ex) { - AnnotationUtils.handleIntrospectionFailure(source, ex); + catch (Throwable ex) { + AnnotationUtils.handleIntrospectionFailure(source, ex); + } } } + catch (Throwable ex) { + AnnotationUtils.handleIntrospectionFailure(source, ex); + } return null; } @@ -277,9 +286,15 @@ private static R processMethod(C context, Method source, private static R processMethodInheritedAnnotations(C context, Method source, AnnotationsProcessor processor, @Nullable BiPredicate> classFilter) { - R result = processor.doWithAggregate(context, 0); - return (result != null ? result : + try { + R result = processor.doWithAggregate(context, 0); + return (result != null ? result : processMethodAnnotations(context, 0, source, processor, classFilter)); + } + catch (Throwable ex) { + AnnotationUtils.handleIntrospectionFailure(source, ex); + } + return null; } @Nullable @@ -288,57 +303,62 @@ private static R processMethodHierarchy(C context, int[] aggregateIndex, @Nullable BiPredicate> classFilter, Method rootMethod, boolean includeInterfaces) { - R result = processor.doWithAggregate(context, aggregateIndex[0]); - if (result != null) { - return result; - } - if (hasPlainJavaAnnotationsOnly(sourceClass)) { - return null; - } - boolean calledProcessor = false; - if (sourceClass == rootMethod.getDeclaringClass()) { - result = processMethodAnnotations(context, aggregateIndex[0], - rootMethod, processor, classFilter); - calledProcessor = true; + try { + R result = processor.doWithAggregate(context, aggregateIndex[0]); if (result != null) { return result; } - } - else { - for (Method candidateMethod : getBaseTypeMethods(context, sourceClass, classFilter)) { - if (candidateMethod != null && isOverride(rootMethod, candidateMethod)) { - result = processMethodAnnotations(context, aggregateIndex[0], + if (hasPlainJavaAnnotationsOnly(sourceClass)) { + return null; + } + boolean calledProcessor = false; + if (sourceClass == rootMethod.getDeclaringClass()) { + result = processMethodAnnotations(context, aggregateIndex[0], + rootMethod, processor, classFilter); + calledProcessor = true; + if (result != null) { + return result; + } + } + else { + for (Method candidateMethod : getBaseTypeMethods(context, sourceClass, classFilter)) { + if (candidateMethod != null && isOverride(rootMethod, candidateMethod)) { + result = processMethodAnnotations(context, aggregateIndex[0], candidateMethod, processor, classFilter); - calledProcessor = true; - if (result != null) { - return result; + calledProcessor = true; + if (result != null) { + return result; + } } } } - } - if (Modifier.isPrivate(rootMethod.getModifiers())) { - return null; - } - if (calledProcessor) { - aggregateIndex[0]++; - } - if (includeInterfaces) { - for (Class interfaceType : sourceClass.getInterfaces()) { - R interfacesResult = processMethodHierarchy(context, aggregateIndex, + if (Modifier.isPrivate(rootMethod.getModifiers())) { + return null; + } + if (calledProcessor) { + aggregateIndex[0]++; + } + if (includeInterfaces) { + for (Class interfaceType : sourceClass.getInterfaces()) { + R interfacesResult = processMethodHierarchy(context, aggregateIndex, interfaceType, processor, classFilter, rootMethod, true); - if (interfacesResult != null) { - return interfacesResult; + if (interfacesResult != null) { + return interfacesResult; + } } } - } - Class superclass = sourceClass.getSuperclass(); - if (superclass != Object.class && superclass != null) { - R superclassResult = processMethodHierarchy(context, aggregateIndex, + Class superclass = sourceClass.getSuperclass(); + if (superclass != Object.class && superclass != null) { + R superclassResult = processMethodHierarchy(context, aggregateIndex, superclass, processor, classFilter, rootMethod, includeInterfaces); - if (superclassResult != null) { - return superclassResult; + if (superclassResult != null) { + return superclassResult; + } } } + catch (Throwable ex) { + AnnotationUtils.handleIntrospectionFailure(rootMethod, ex); + } return null; } @@ -434,9 +454,15 @@ private static R processMethodAnnotations(C context, int aggregateIndex, private static R processElement(C context, AnnotatedElement source, AnnotationsProcessor processor, @Nullable BiPredicate> classFilter) { - R result = processor.doWithAggregate(context, 0); - return (result != null ? result : processor.doWithAnnotations( + try { + R result = processor.doWithAggregate(context, 0); + return (result != null ? result : processor.doWithAnnotations( context, 0, source, getDeclaredAnnotations(context, source, classFilter, false))); + } + catch (Throwable ex) { + AnnotationUtils.handleIntrospectionFailure(source, ex); + } + return null; } private static Annotation[] getDeclaredAnnotations(C context, From dafe57fc6e1b019fe011fcdf99f32f9b11c01bb0 Mon Sep 17 00:00:00 2001 From: perceptron8 Date: Thu, 12 Dec 2019 12:17:02 +0100 Subject: [PATCH 0201/2315] Add BeanPropertyRowMapper.newInstance(mappedClass, conversionService) Similar to SingleColumnRowMapper.newInstance(requiredType, conversionService) which was added in #1678. --- .../jdbc/core/BeanPropertyRowMapper.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java index c041af56b4e1..7ce4110575f4 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java @@ -388,4 +388,16 @@ public static BeanPropertyRowMapper newInstance(Class mappedClass) { return new BeanPropertyRowMapper<>(mappedClass); } + /** + * Static factory method to create a new {@code BeanPropertyRowMapper} + * (with the required type specified only once). + * @param mappedClass the class that each row should be mapped to + * @param conversionService the {@link ConversionService} for binding JDBC values to bean properties, or {@code null} for none + */ + public static BeanPropertyRowMapper newInstance(Class mappedClass, @Nullable ConversionService conversionService) { + BeanPropertyRowMapper rowMapper = newInstance(mappedClass); + rowMapper.setConversionService(conversionService); + return rowMapper; + } + } From 02b40223e591a8f06a54c8cae9240d0f7578ca11 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 12 Dec 2019 16:43:00 +0100 Subject: [PATCH 0202/2315] Polishing --- .../jdbc/core/BeanPropertyRowMapper.java | 13 ++++++++++--- .../jdbc/core/SingleColumnRowMapper.java | 12 +++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java index 7ce4110575f4..5a5ece73d2cd 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -383,6 +383,7 @@ protected Object getColumnValue(ResultSet rs, int index, PropertyDescriptor pd) * Static factory method to create a new {@code BeanPropertyRowMapper} * (with the mapped class specified only once). * @param mappedClass the class that each row should be mapped to + * @see #newInstance(Class, ConversionService) */ public static BeanPropertyRowMapper newInstance(Class mappedClass) { return new BeanPropertyRowMapper<>(mappedClass); @@ -392,9 +393,15 @@ public static BeanPropertyRowMapper newInstance(Class mappedClass) { * Static factory method to create a new {@code BeanPropertyRowMapper} * (with the required type specified only once). * @param mappedClass the class that each row should be mapped to - * @param conversionService the {@link ConversionService} for binding JDBC values to bean properties, or {@code null} for none + * @param conversionService the {@link ConversionService} for binding + * JDBC values to bean properties, or {@code null} for none + * @since 5.2.3 + * @see #newInstance(Class) + * @see #setConversionService */ - public static BeanPropertyRowMapper newInstance(Class mappedClass, @Nullable ConversionService conversionService) { + public static BeanPropertyRowMapper newInstance( + Class mappedClass, @Nullable ConversionService conversionService) { + BeanPropertyRowMapper rowMapper = newInstance(mappedClass); rowMapper.setConversionService(conversionService); return rowMapper; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SingleColumnRowMapper.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SingleColumnRowMapper.java index 31f70680467f..0a2e9cb491c9 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SingleColumnRowMapper.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SingleColumnRowMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -220,6 +220,7 @@ else if (this.conversionService != null && this.conversionService.canConvert(val * (with the required type specified only once). * @param requiredType the type that each result object is expected to match * @since 4.1 + * @see #newInstance(Class, ConversionService) */ public static SingleColumnRowMapper newInstance(Class requiredType) { return new SingleColumnRowMapper<>(requiredType); @@ -229,10 +230,15 @@ public static SingleColumnRowMapper newInstance(Class requiredType) { * Static factory method to create a new {@code SingleColumnRowMapper} * (with the required type specified only once). * @param requiredType the type that each result object is expected to match - * @param conversionService the {@link ConversionService} for converting a fetched value + * @param conversionService the {@link ConversionService} for converting a + * fetched value, or {@code null} for none * @since 5.0.4 + * @see #newInstance(Class) + * @see #setConversionService */ - public static SingleColumnRowMapper newInstance(Class requiredType, @Nullable ConversionService conversionService) { + public static SingleColumnRowMapper newInstance( + Class requiredType, @Nullable ConversionService conversionService) { + SingleColumnRowMapper rowMapper = newInstance(requiredType); rowMapper.setConversionService(conversionService); return rowMapper; From b679c3b6ecaf6f6b4ac28623430da4779e9ce8dc Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 12 Dec 2019 16:44:21 +0100 Subject: [PATCH 0203/2315] Upgrade to Tomcat 9.0.30 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 47892290579f..73bbb2c39246 100644 --- a/build.gradle +++ b/build.gradle @@ -135,14 +135,14 @@ configure(allprojects) { project -> dependency "org.webjars:webjars-locator-core:0.43" dependency "org.webjars:underscorejs:1.8.3" - dependencySet(group: 'org.apache.tomcat', version: '9.0.29') { + dependencySet(group: 'org.apache.tomcat', version: '9.0.30') { entry 'tomcat-util' entry('tomcat-websocket') { exclude group: "org.apache.tomcat", name: "tomcat-websocket-api" exclude group: "org.apache.tomcat", name: "tomcat-servlet-api" } } - dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.29') { + dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.30') { entry 'tomcat-embed-core' entry 'tomcat-embed-websocket' } From fa8f08391f97de87730ace8034d31de648e57026 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 12 Dec 2019 17:21:41 +0100 Subject: [PATCH 0204/2315] Consistent use of annotation-api dependency instead of tomcat-embed-core --- spring-beans/spring-beans.gradle | 2 +- spring-core/spring-core.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-beans/spring-beans.gradle b/spring-beans/spring-beans.gradle index d19807870b50..0409b9e910d8 100644 --- a/spring-beans/spring-beans.gradle +++ b/spring-beans/spring-beans.gradle @@ -10,7 +10,7 @@ dependencies { optional("org.codehaus.groovy:groovy-xml") optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") - testCompile("org.apache.tomcat.embed:tomcat-embed-core") + testCompile("javax.annotation:javax.annotation-api") } // This module does joint compilation for Java and Groovy code with the compileGroovy task. diff --git a/spring-core/spring-core.gradle b/spring-core/spring-core.gradle index 866b4e295c89..48fd9976b504 100644 --- a/spring-core/spring-core.gradle +++ b/spring-core/spring-core.gradle @@ -53,7 +53,7 @@ dependencies { optional("io.reactivex.rxjava2:rxjava") optional("io.netty:netty-buffer") testCompile("io.projectreactor:reactor-test") - testCompile("org.apache.tomcat.embed:tomcat-embed-core") + testCompile("javax.annotation:javax.annotation-api") testCompile("com.google.code.findbugs:jsr305") testCompile("org.xmlunit:xmlunit-assertj") testCompile("org.xmlunit:xmlunit-matchers") From 9d65830133c96da18676555818f88c24a0b12753 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 12 Dec 2019 17:01:01 +0000 Subject: [PATCH 0205/2315] CodecConfigurer implementation refactoring See gh-24124 --- .../http/codec/ClientCodecConfigurer.java | 2 + .../http/codec/CodecConfigurer.java | 9 +- .../http/codec/ServerCodecConfigurer.java | 3 + .../multipart/MultipartHttpMessageWriter.java | 10 ++ .../http/codec/support/BaseDefaultCodecs.java | 150 +++++++++++++----- .../support/ClientDefaultCodecsImpl.java | 19 +-- .../support/ServerDefaultCodecsImpl.java | 22 +-- .../support/ClientCodecConfigurerTests.java | 87 ++++++---- .../support/ServerCodecConfigurerTests.java | 58 +++---- 9 files changed, 232 insertions(+), 128 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java index e41ec7348117..070b0610ee1f 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java @@ -95,6 +95,8 @@ interface ClientDefaultCodecs extends DefaultCodecs { *

    By default if this is not set, and Jackson is available, the * {@link #jackson2JsonDecoder} override is used instead. Use this property * if you want to further customize the SSE decoder. + *

    Note that {@link #maxInMemorySize(int)}, if configured, will be + * applied to the given decoder. * @param decoder the decoder to use */ void serverSentEventDecoder(Decoder decoder); diff --git a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java index 4caf849b1af2..8263b1242067 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java @@ -109,6 +109,8 @@ interface DefaultCodecs { /** * Override the default Jackson JSON {@code Decoder}. + *

    Note that {@link #maxInMemorySize(int)}, if configured, will be + * applied to the given decoder. * @param decoder the decoder instance to use * @see org.springframework.http.codec.json.Jackson2JsonDecoder */ @@ -123,6 +125,8 @@ interface DefaultCodecs { /** * Override the default Protobuf {@code Decoder}. + *

    Note that {@link #maxInMemorySize(int)}, if configured, will be + * applied to the given decoder. * @param decoder the decoder instance to use * @since 5.1 * @see org.springframework.http.codec.protobuf.ProtobufDecoder @@ -140,6 +144,8 @@ interface DefaultCodecs { /** * Override the default JAXB2 {@code Decoder}. + *

    Note that {@link #maxInMemorySize(int)}, if configured, will be + * applied to the given decoder. * @param decoder the decoder instance to use * @since 5.1.3 * @see org.springframework.http.codec.xml.Jaxb2XmlDecoder @@ -245,7 +251,8 @@ interface DefaultCodecConfig { * Whether to log form data at DEBUG level, and headers at TRACE level. * Both may contain sensitive information. */ - boolean isEnableLoggingRequestDetails(); + @Nullable + Boolean isEnableLoggingRequestDetails(); } } diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/ServerCodecConfigurer.java index 3d49092f593f..4bbefc8c939c 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerCodecConfigurer.java @@ -91,6 +91,9 @@ interface ServerDefaultCodecs extends DefaultCodecs { * MultipartHttpMessageReader} created with an instance of * {@link org.springframework.http.codec.multipart.SynchronossPartHttpMessageReader * SynchronossPartHttpMessageReader}. + *

    Note that {@link #maxInMemorySize(int)} and/or + * {@link #enableLoggingRequestDetails(boolean)}, if configured, will be + * applied to the given reader, if applicable. * @param reader the message reader to use for multipart requests. * @since 5.1.11 */ diff --git a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java index f5245b61fa73..13a1dfdc684a 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java @@ -149,6 +149,16 @@ public List> getPartWriters() { return Collections.unmodifiableList(this.partWriters); } + + /** + * Return the configured form writer. + * @since 5.1.13 + */ + @Nullable + public HttpMessageWriter> getFormWriter() { + return this.formWriter; + } + /** * Set the character set to use for part headers such as * "Content-Disposition" (and its filename parameter). diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java index c3a7fa385912..3b9678984124 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java @@ -36,15 +36,20 @@ import org.springframework.http.codec.DecoderHttpMessageReader; import org.springframework.http.codec.EncoderHttpMessageWriter; import org.springframework.http.codec.FormHttpMessageReader; +import org.springframework.http.codec.FormHttpMessageWriter; import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.codec.HttpMessageWriter; import org.springframework.http.codec.ResourceHttpMessageReader; import org.springframework.http.codec.ResourceHttpMessageWriter; +import org.springframework.http.codec.ServerSentEventHttpMessageReader; import org.springframework.http.codec.json.AbstractJackson2Decoder; import org.springframework.http.codec.json.Jackson2JsonDecoder; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.codec.json.Jackson2SmileDecoder; import org.springframework.http.codec.json.Jackson2SmileEncoder; +import org.springframework.http.codec.multipart.MultipartHttpMessageReader; +import org.springframework.http.codec.multipart.MultipartHttpMessageWriter; +import org.springframework.http.codec.multipart.SynchronossPartHttpMessageReader; import org.springframework.http.codec.protobuf.ProtobufDecoder; import org.springframework.http.codec.protobuf.ProtobufEncoder; import org.springframework.http.codec.protobuf.ProtobufHttpMessageWriter; @@ -70,6 +75,8 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure private static final boolean protobufPresent; + static final boolean synchronossMultipartPresent; + static { ClassLoader classLoader = BaseCodecConfigurer.class.getClassLoader(); jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) && @@ -77,6 +84,7 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure jackson2SmilePresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory", classLoader); jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", classLoader); protobufPresent = ClassUtils.isPresent("com.google.protobuf.Message", classLoader); + synchronossMultipartPresent = ClassUtils.isPresent("org.synchronoss.cloud.nio.multipart.NioMultipartParser", classLoader); } @@ -101,7 +109,8 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure @Nullable private Integer maxInMemorySize; - private boolean enableLoggingRequestDetails = false; + @Nullable + private Boolean enableLoggingRequestDetails; private boolean registerDefaults = true; @@ -171,7 +180,8 @@ public void enableLoggingRequestDetails(boolean enable) { } @Override - public boolean isEnableLoggingRequestDetails() { + @Nullable + public Boolean isEnableLoggingRequestDetails() { return this.enableLoggingRequestDetails; } @@ -191,48 +201,107 @@ final List> getTypedReaders() { return Collections.emptyList(); } List> readers = new ArrayList<>(); - readers.add(new DecoderHttpMessageReader<>(init(new ByteArrayDecoder()))); - readers.add(new DecoderHttpMessageReader<>(init(new ByteBufferDecoder()))); - readers.add(new DecoderHttpMessageReader<>(init(new DataBufferDecoder()))); - readers.add(new ResourceHttpMessageReader(init(new ResourceDecoder()))); - readers.add(new DecoderHttpMessageReader<>(init(StringDecoder.textPlainOnly()))); + addCodec(readers, new DecoderHttpMessageReader<>(new ByteArrayDecoder())); + addCodec(readers, new DecoderHttpMessageReader<>(new ByteBufferDecoder())); + addCodec(readers, new DecoderHttpMessageReader<>(new DataBufferDecoder())); + addCodec(readers, new ResourceHttpMessageReader(new ResourceDecoder())); + addCodec(readers, new DecoderHttpMessageReader<>(StringDecoder.textPlainOnly())); if (protobufPresent) { - Decoder decoder = this.protobufDecoder != null ? this.protobufDecoder : init(new ProtobufDecoder()); - readers.add(new DecoderHttpMessageReader<>(decoder)); - } - - FormHttpMessageReader formReader = new FormHttpMessageReader(); - if (this.maxInMemorySize != null) { - formReader.setMaxInMemorySize(this.maxInMemorySize); + Decoder decoder = this.protobufDecoder != null ? this.protobufDecoder : new ProtobufDecoder(); + addCodec(readers, new DecoderHttpMessageReader<>(decoder)); } - formReader.setEnableLoggingRequestDetails(this.enableLoggingRequestDetails); - readers.add(formReader); + addCodec(readers, new FormHttpMessageReader()); + // client vs server.. extendTypedReaders(readers); return readers; } - private > T init(T decoder) { - if (this.maxInMemorySize != null) { - if (decoder instanceof AbstractDataBufferDecoder) { - ((AbstractDataBufferDecoder) decoder).setMaxInMemorySize(this.maxInMemorySize); + /** + * Initialize a codec and add it to the List. + * @since 5.1.13 + */ + protected void addCodec(List codecs, T codec) { + initCodec(codec); + codecs.add(codec); + } + + /** + * Apply {@link #maxInMemorySize()} and {@link #enableLoggingRequestDetails}, + * if configured by the application, to the given codec , including any + * codec it contains. + */ + private void initCodec(@Nullable Object codec) { + + if (codec instanceof DecoderHttpMessageReader) { + codec = ((DecoderHttpMessageReader) codec).getDecoder(); + } + else if (codec instanceof ServerSentEventHttpMessageReader) { + codec = ((ServerSentEventHttpMessageReader) codec).getDecoder(); + } + + if (codec == null) { + return; + } + + Integer size = this.maxInMemorySize; + if (size != null) { + if (codec instanceof AbstractDataBufferDecoder) { + ((AbstractDataBufferDecoder) codec).setMaxInMemorySize(size); } - if (decoder instanceof ProtobufDecoder) { - ((ProtobufDecoder) decoder).setMaxMessageSize(this.maxInMemorySize); + if (protobufPresent) { + if (codec instanceof ProtobufDecoder) { + ((ProtobufDecoder) codec).setMaxMessageSize(size); + } } if (jackson2Present) { - if (decoder instanceof AbstractJackson2Decoder) { - ((AbstractJackson2Decoder) decoder).setMaxInMemorySize(this.maxInMemorySize); + if (codec instanceof AbstractJackson2Decoder) { + ((AbstractJackson2Decoder) codec).setMaxInMemorySize(size); } } if (jaxb2Present) { - if (decoder instanceof Jaxb2XmlDecoder) { - ((Jaxb2XmlDecoder) decoder).setMaxInMemorySize(this.maxInMemorySize); + if (codec instanceof Jaxb2XmlDecoder) { + ((Jaxb2XmlDecoder) codec).setMaxInMemorySize(size); } } + if (codec instanceof FormHttpMessageReader) { + ((FormHttpMessageReader) codec).setMaxInMemorySize(size); + } + if (synchronossMultipartPresent) { + if (codec instanceof SynchronossPartHttpMessageReader) { + ((SynchronossPartHttpMessageReader) codec).setMaxInMemorySize(size); + } + } + } + + Boolean enable = this.enableLoggingRequestDetails; + if (enable != null) { + if (codec instanceof FormHttpMessageReader) { + ((FormHttpMessageReader) codec).setEnableLoggingRequestDetails(enable); + } + if (codec instanceof MultipartHttpMessageReader) { + ((MultipartHttpMessageReader) codec).setEnableLoggingRequestDetails(enable); + } + if (synchronossMultipartPresent) { + if (codec instanceof SynchronossPartHttpMessageReader) { + ((SynchronossPartHttpMessageReader) codec).setEnableLoggingRequestDetails(enable); + } + } + if (codec instanceof FormHttpMessageWriter) { + ((FormHttpMessageWriter) codec).setEnableLoggingRequestDetails(enable); + } + if (codec instanceof MultipartHttpMessageWriter) { + ((MultipartHttpMessageWriter) codec).setEnableLoggingRequestDetails(enable); + } + } + + if (codec instanceof MultipartHttpMessageReader) { + initCodec(((MultipartHttpMessageReader) codec).getPartReader()); + } + else if (codec instanceof MultipartHttpMessageWriter) { + initCodec(((MultipartHttpMessageWriter) codec).getFormWriter()); } - return decoder; } /** @@ -250,16 +319,19 @@ final List> getObjectReaders() { } List> readers = new ArrayList<>(); if (jackson2Present) { - readers.add(new DecoderHttpMessageReader<>(init(getJackson2JsonDecoder()))); + addCodec(readers, new DecoderHttpMessageReader<>(getJackson2JsonDecoder())); } if (jackson2SmilePresent) { - readers.add(new DecoderHttpMessageReader<>(init(new Jackson2SmileDecoder()))); + addCodec(readers, new DecoderHttpMessageReader<>(new Jackson2SmileDecoder())); } if (jaxb2Present) { - Decoder decoder = this.jaxb2Decoder != null ? this.jaxb2Decoder : init(new Jaxb2XmlDecoder()); - readers.add(new DecoderHttpMessageReader<>(decoder)); + Decoder decoder = this.jaxb2Decoder != null ? this.jaxb2Decoder : new Jaxb2XmlDecoder(); + addCodec(readers, new DecoderHttpMessageReader<>(decoder)); } + + // client vs server.. extendObjectReaders(readers); + return readers; } @@ -276,9 +348,9 @@ final List> getCatchAllReaders() { if (!this.registerDefaults) { return Collections.emptyList(); } - List> result = new ArrayList<>(); - result.add(new DecoderHttpMessageReader<>(init(StringDecoder.allMimeTypes()))); - return result; + List> readers = new ArrayList<>(); + addCodec(readers, new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes())); + return readers; } /** @@ -365,11 +437,17 @@ List> getCatchAllWriters() { // Accessors for use in subclasses... protected Decoder getJackson2JsonDecoder() { - return (this.jackson2JsonDecoder != null ? this.jackson2JsonDecoder : new Jackson2JsonDecoder()); + if (this.jackson2JsonDecoder == null) { + this.jackson2JsonDecoder = new Jackson2JsonDecoder(); + } + return this.jackson2JsonDecoder; } protected Encoder getJackson2JsonEncoder() { - return (this.jackson2JsonEncoder != null ? this.jackson2JsonEncoder : new Jackson2JsonEncoder()); + if (this.jackson2JsonEncoder == null) { + this.jackson2JsonEncoder = new Jackson2JsonEncoder(); + } + return this.jackson2JsonEncoder; } } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java b/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java index e764cb969612..dae7b25704d2 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java @@ -95,24 +95,17 @@ public ClientDefaultCodecsImpl clone() { @Override protected void extendObjectReaders(List> objectReaders) { - objectReaders.add(new ServerSentEventHttpMessageReader(getSseDecoder())); - } - @Nullable - private Decoder getSseDecoder() { - return (this.sseDecoder != null ? this.sseDecoder : jackson2Present ? getJackson2JsonDecoder() : null); + Decoder decoder = (this.sseDecoder != null ? + this.sseDecoder : + jackson2Present ? getJackson2JsonDecoder() : null); + + addCodec(objectReaders, new ServerSentEventHttpMessageReader(decoder)); } @Override protected void extendTypedWriters(List> typedWriters) { - - FormHttpMessageWriter formWriter = new FormHttpMessageWriter(); - formWriter.setEnableLoggingRequestDetails(isEnableLoggingRequestDetails()); - - MultipartHttpMessageWriter multipartWriter = new MultipartHttpMessageWriter(getPartWriters(), formWriter); - multipartWriter.setEnableLoggingRequestDetails(isEnableLoggingRequestDetails()); - - typedWriters.add(multipartWriter); + addCodec(typedWriters, new MultipartHttpMessageWriter(getPartWriters(), new FormHttpMessageWriter())); } private List> getPartWriters() { diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java b/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java index 1d997c3777b1..eaab4e3237c4 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java @@ -25,7 +25,6 @@ import org.springframework.http.codec.multipart.MultipartHttpMessageReader; import org.springframework.http.codec.multipart.SynchronossPartHttpMessageReader; import org.springframework.lang.Nullable; -import org.springframework.util.ClassUtils; /** * Default implementation of {@link ServerCodecConfigurer.ServerDefaultCodecs}. @@ -34,11 +33,6 @@ */ class ServerDefaultCodecsImpl extends BaseDefaultCodecs implements ServerCodecConfigurer.ServerDefaultCodecs { - private static final boolean synchronossMultipartPresent = - ClassUtils.isPresent("org.synchronoss.cloud.nio.multipart.NioMultipartParser", - DefaultServerCodecConfigurer.class.getClassLoader()); - - @Nullable private HttpMessageReader multipartReader; @@ -70,23 +64,13 @@ public void serverSentEventEncoder(Encoder encoder) { @Override protected void extendTypedReaders(List> typedReaders) { if (this.multipartReader != null) { - typedReaders.add(this.multipartReader); + addCodec(typedReaders, this.multipartReader); return; } if (synchronossMultipartPresent) { - boolean enable = isEnableLoggingRequestDetails(); - SynchronossPartHttpMessageReader partReader = new SynchronossPartHttpMessageReader(); - Integer size = maxInMemorySize(); - if (size != null) { - partReader.setMaxInMemorySize(size); - } - partReader.setEnableLoggingRequestDetails(enable); - typedReaders.add(partReader); - - MultipartHttpMessageReader reader = new MultipartHttpMessageReader(partReader); - reader.setEnableLoggingRequestDetails(enable); - typedReaders.add(reader); + addCodec(typedReaders, partReader); + addCodec(typedReaders, new MultipartHttpMessageReader(partReader)); } } diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java index 5faea0c90ed2..1553916771cd 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; @@ -37,6 +36,7 @@ import org.springframework.core.codec.DataBufferEncoder; import org.springframework.core.codec.Decoder; import org.springframework.core.codec.Encoder; +import org.springframework.core.codec.ResourceDecoder; import org.springframework.core.codec.StringDecoder; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.MediaType; @@ -44,6 +44,7 @@ import org.springframework.http.codec.DecoderHttpMessageReader; import org.springframework.http.codec.EncoderHttpMessageWriter; import org.springframework.http.codec.FormHttpMessageReader; +import org.springframework.http.codec.FormHttpMessageWriter; import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.codec.HttpMessageWriter; import org.springframework.http.codec.ResourceHttpMessageReader; @@ -116,12 +117,45 @@ public void jackson2EncoderOverride() { Jackson2JsonDecoder decoder = new Jackson2JsonDecoder(); this.configurer.defaultCodecs().jackson2JsonDecoder(decoder); - assertThat(this.configurer.getReaders().stream() - .filter(reader -> ServerSentEventHttpMessageReader.class.equals(reader.getClass())) - .map(reader -> (ServerSentEventHttpMessageReader) reader) - .findFirst() - .map(ServerSentEventHttpMessageReader::getDecoder) - .filter(e -> e == decoder).orElse(null)).isSameAs(decoder); + List> readers = this.configurer.getReaders(); + assertThat(findCodec(readers, ServerSentEventHttpMessageReader.class).getDecoder()).isSameAs(decoder); + } + + @Test + public void maxInMemorySize() { + int size = 99; + this.configurer.defaultCodecs().maxInMemorySize(size); + List> readers = this.configurer.getReaders(); + assertThat(readers.size()).isEqualTo(12); + assertThat(((ByteArrayDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); + assertThat(((ByteBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); + assertThat(((DataBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); + assertThat(((ResourceDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); + assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); + assertThat(((ProtobufDecoder) getNextDecoder(readers)).getMaxMessageSize()).isEqualTo(size); + assertThat(((FormHttpMessageReader) nextReader(readers)).getMaxInMemorySize()).isEqualTo(size); + + assertThat(((Jackson2JsonDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); + assertThat(((Jackson2SmileDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); + assertThat(((Jaxb2XmlDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); + + ServerSentEventHttpMessageReader reader = (ServerSentEventHttpMessageReader) nextReader(readers); + assertThat(((Jackson2JsonDecoder) reader.getDecoder()).getMaxInMemorySize()).isEqualTo(size); + + assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); + } + + @Test + public void enableLoggingRequestDetails() { + this.configurer.defaultCodecs().enableLoggingRequestDetails(true); + + List> writers = this.configurer.getWriters(); + MultipartHttpMessageWriter multipartWriter = findCodec(writers, MultipartHttpMessageWriter.class); + assertThat(multipartWriter.isEnableLoggingRequestDetails()).isTrue(); + + FormHttpMessageWriter formWriter = (FormHttpMessageWriter) multipartWriter.getFormWriter(); + assertThat(formWriter).isNotNull(); + assertThat(formWriter.isEnableLoggingRequestDetails()).isTrue(); } @Test @@ -135,49 +169,42 @@ public void cloneConfigurer() { // Clone has the customizations - Decoder sseDecoder = clone.getReaders().stream() - .filter(reader -> reader instanceof ServerSentEventHttpMessageReader) - .map(reader -> ((ServerSentEventHttpMessageReader) reader).getDecoder()) - .findFirst() - .get(); - - List> multipartWriters = clone.getWriters().stream() - .filter(writer -> writer instanceof MultipartHttpMessageWriter) - .flatMap(writer -> ((MultipartHttpMessageWriter) writer).getPartWriters().stream()) - .collect(Collectors.toList()); + Decoder sseDecoder = findCodec(clone.getReaders(), ServerSentEventHttpMessageReader.class).getDecoder(); + List> writers = findCodec(clone.getWriters(), MultipartHttpMessageWriter.class).getPartWriters(); assertThat(sseDecoder).isSameAs(jackson2Decoder); - assertThat(multipartWriters).hasSize(2); + assertThat(writers).hasSize(2); // Original does not have the customizations - sseDecoder = this.configurer.getReaders().stream() - .filter(reader -> reader instanceof ServerSentEventHttpMessageReader) - .map(reader -> ((ServerSentEventHttpMessageReader) reader).getDecoder()) - .findFirst() - .get(); - - multipartWriters = this.configurer.getWriters().stream() - .filter(writer -> writer instanceof MultipartHttpMessageWriter) - .flatMap(writer -> ((MultipartHttpMessageWriter) writer).getPartWriters().stream()) - .collect(Collectors.toList()); + sseDecoder = findCodec(this.configurer.getReaders(), ServerSentEventHttpMessageReader.class).getDecoder(); + writers = findCodec(this.configurer.getWriters(), MultipartHttpMessageWriter.class).getPartWriters(); assertThat(sseDecoder).isNotSameAs(jackson2Decoder); - assertThat(multipartWriters).hasSize(10); + assertThat(writers).hasSize(10); } private Decoder getNextDecoder(List> readers) { HttpMessageReader reader = readers.get(this.index.getAndIncrement()); - assertThat(reader.getClass()).isEqualTo(DecoderHttpMessageReader.class); + assertThat(reader).isInstanceOf(DecoderHttpMessageReader.class); return ((DecoderHttpMessageReader) reader).getDecoder(); } + private HttpMessageReader nextReader(List> readers) { + return readers.get(this.index.getAndIncrement()); + } + private Encoder getNextEncoder(List> writers) { HttpMessageWriter writer = writers.get(this.index.getAndIncrement()); assertThat(writer.getClass()).isEqualTo(EncoderHttpMessageWriter.class); return ((EncoderHttpMessageWriter) writer).getEncoder(); } + @SuppressWarnings("unchecked") + private T findCodec(List codecs, Class type) { + return (T) codecs.stream().filter(type::isInstance).findFirst().get(); + } + @SuppressWarnings("unchecked") private void assertStringDecoder(Decoder decoder, boolean textOnly) { assertThat(decoder.getClass()).isEqualTo(StringDecoder.class); diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java index 023ec5af9b98..0aa1bede0b31 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java @@ -134,11 +134,7 @@ public void maxInMemorySize() { assertThat(((ByteArrayDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); assertThat(((ByteBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); assertThat(((DataBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); - - ResourceHttpMessageReader resourceReader = (ResourceHttpMessageReader) nextReader(readers); - ResourceDecoder decoder = (ResourceDecoder) resourceReader.getDecoder(); - assertThat(decoder.getMaxInMemorySize()).isEqualTo(size); - + assertThat(((ResourceDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); assertThat(((ProtobufDecoder) getNextDecoder(readers)).getMaxMessageSize()).isEqualTo(size); assertThat(((FormHttpMessageReader) nextReader(readers)).getMaxInMemorySize()).isEqualTo(size); @@ -154,6 +150,20 @@ public void maxInMemorySize() { assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); } + @Test + public void enableRequestLoggingDetails() { + this.configurer.defaultCodecs().enableLoggingRequestDetails(true); + + List> readers = this.configurer.getReaders(); + assertThat(findCodec(readers, FormHttpMessageReader.class).isEnableLoggingRequestDetails()).isTrue(); + + MultipartHttpMessageReader multipartReader = findCodec(readers, MultipartHttpMessageReader.class); + assertThat(multipartReader.isEnableLoggingRequestDetails()).isTrue(); + + SynchronossPartHttpMessageReader reader = (SynchronossPartHttpMessageReader) multipartReader.getPartReader(); + assertThat(reader.isEnableLoggingRequestDetails()).isTrue(); + } + @Test public void cloneConfigurer() { ServerCodecConfigurer clone = this.configurer.clone(); @@ -165,42 +175,27 @@ public void cloneConfigurer() { // Clone has the customizations - HttpMessageReader actualReader = clone.getReaders().stream() - .filter(r -> r instanceof MultipartHttpMessageReader) - .findFirst() - .get(); - - Encoder actualEncoder = clone.getWriters().stream() - .filter(writer -> writer instanceof ServerSentEventHttpMessageWriter) - .map(writer -> ((ServerSentEventHttpMessageWriter) writer).getEncoder()) - .findFirst() - .get(); + HttpMessageReader actualReader = + findCodec(clone.getReaders(), MultipartHttpMessageReader.class); + ServerSentEventHttpMessageWriter actualWriter = + findCodec(clone.getWriters(), ServerSentEventHttpMessageWriter.class); assertThat(actualReader).isSameAs(reader); - assertThat(actualEncoder).isSameAs(encoder); + assertThat(actualWriter.getEncoder()).isSameAs(encoder); // Original does not have the customizations - actualReader = this.configurer.getReaders().stream() - .filter(r -> r instanceof MultipartHttpMessageReader) - .findFirst() - .get(); - - actualEncoder = this.configurer.getWriters().stream() - .filter(writer -> writer instanceof ServerSentEventHttpMessageWriter) - .map(writer -> ((ServerSentEventHttpMessageWriter) writer).getEncoder()) - .findFirst() - .get(); - + actualReader = findCodec(this.configurer.getReaders(), MultipartHttpMessageReader.class); + actualWriter = findCodec(this.configurer.getWriters(), ServerSentEventHttpMessageWriter.class); assertThat(actualReader).isNotSameAs(reader); - assertThat(actualEncoder).isNotSameAs(encoder); + assertThat(actualWriter.getEncoder()).isNotSameAs(encoder); } private Decoder getNextDecoder(List> readers) { HttpMessageReader reader = nextReader(readers); - assertThat(reader.getClass()).isEqualTo(DecoderHttpMessageReader.class); + assertThat(reader).isInstanceOf(DecoderHttpMessageReader.class); return ((DecoderHttpMessageReader) reader).getDecoder(); } @@ -214,6 +209,11 @@ private Encoder getNextEncoder(List> writers) { return ((EncoderHttpMessageWriter) writer).getEncoder(); } + @SuppressWarnings("unchecked") + private T findCodec(List codecs, Class type) { + return (T) codecs.stream().filter(type::isInstance).findFirst().get(); + } + @SuppressWarnings("unchecked") private void assertStringDecoder(Decoder decoder, boolean textOnly) { assertThat(decoder.getClass()).isEqualTo(StringDecoder.class); From 11e321b8e7f4e7f35c0ac18d222e20466c615728 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 12 Dec 2019 18:06:12 +0000 Subject: [PATCH 0206/2315] Add register methods to CodecConfigurer.CustomCodecs The new register methods replace the now deprecated encoder, decoder, reader, and writer methods, and also offer a choice to opt into default properties such maxInMemorySize, if configured. See gh-24124 --- .../http/codec/CodecConfigurer.java | 65 +++++++++- .../codec/support/BaseCodecConfigurer.java | 114 ++++++++++++------ .../http/codec/support/BaseDefaultCodecs.java | 16 +++ .../codec/support/CodecConfigurerTests.java | 41 ++++--- .../support/ServerCodecConfigurerTests.java | 40 +++++- .../WebFluxConfigurationSupportTests.java | 8 +- .../ControllerMethodResolverTests.java | 4 +- 7 files changed, 220 insertions(+), 68 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java index 8263b1242067..972fc70ce234 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java @@ -191,18 +191,66 @@ interface DefaultCodecs { */ interface CustomCodecs { + /** + * Register a custom codec. This is expected to be one of the following: + *

      + *
    • {@link HttpMessageReader} + *
    • {@link HttpMessageWriter} + *
    • {@link Encoder} (wrapped internally with {@link EncoderHttpMessageWriter}) + *
    • {@link Decoder} (wrapped internally with {@link DecoderHttpMessageReader}) + *
    + * @param codec the codec to register + * @since 5.2.3 + */ + void register(Object codec); + + /** + * Variant of {@link #register(Object)} that also applies the below + * properties, if configured, via {@link #defaultCodecs()}: + *
      + *
    • {@link CodecConfigurer.DefaultCodecs#maxInMemorySize(int) maxInMemorySize} + *
    • {@link CodecConfigurer.DefaultCodecs#enableLoggingRequestDetails(boolean) enableLoggingRequestDetails} + *
    + *

    The properties are applied every time {@link #getReaders()} or + * {@link #getWriters()} are used to obtain the list of configured + * readers or writers. + * @param codec the codec to register and apply default config to + * @since 5.2.3 + */ + void registerWithDefaultConfig(Object codec); + + /** + * Variant of {@link #register(Object)} that also allows the caller to + * apply the properties from {@link DefaultCodecConfig} to the given + * codec. If you want to apply all the properties, prefer using + * {@link #registerWithDefaultConfig(Object)}. + *

    The consumer is called every time {@link #getReaders()} or + * {@link #getWriters()} are used to obtain the list of configured + * readers or writers. + * @param codec the codec to register + * @param configConsumer consumer of the default config + * @since 5.2.3 + */ + void registerWithDefaultConfig(Object codec, Consumer configConsumer); + /** * Add a custom {@code Decoder} internally wrapped with * {@link DecoderHttpMessageReader}). * @param decoder the decoder to add + * @deprecated as of 5.1.13, use {@link #register(Object)} or + * {@link #registerWithDefaultConfig(Object)} instead. */ + @Deprecated void decoder(Decoder decoder); /** * Add a custom {@code Encoder}, internally wrapped with * {@link EncoderHttpMessageWriter}. * @param encoder the encoder to add + * @deprecated as of 5.1.13, use {@link #register(Object)} or + * {@link #registerWithDefaultConfig(Object)} instead. */ + @Deprecated void encoder(Encoder encoder); /** @@ -210,7 +258,10 @@ interface CustomCodecs { * {@link DecoderHttpMessageReader} consider using the shortcut * {@link #decoder(Decoder)} instead. * @param reader the reader to add + * @deprecated as of 5.1.13, use {@link #register(Object)} or + * {@link #registerWithDefaultConfig(Object)} instead. */ + @Deprecated void reader(HttpMessageReader reader); /** @@ -218,7 +269,10 @@ interface CustomCodecs { * {@link EncoderHttpMessageWriter} consider using the shortcut * {@link #encoder(Encoder)} instead. * @param writer the writer to add + * @deprecated as of 5.1.13, use {@link #register(Object)} or + * {@link #registerWithDefaultConfig(Object)} instead. */ + @Deprecated void writer(HttpMessageWriter writer); /** @@ -227,16 +281,21 @@ interface CustomCodecs { * guidelines applied to default ones, such as logging details and limiting * the amount of buffered data. * @param codecsConfigConsumer the default codecs configuration callback - * @since 5.1.12 + * @deprecated as of 5.1.13, use {@link #registerWithDefaultConfig(Object)} + * or {@link #registerWithDefaultConfig(Object, Consumer)} instead. */ + @Deprecated void withDefaultCodecConfig(Consumer codecsConfigConsumer); } /** - * Common options applied to default codecs and passed in a callback to custom codecs - * so they get a chance to align their behavior on the default ones. + * Exposes the values of properties configured through + * {@link #defaultCodecs()} that are applied to default codecs. + * The main purpose of this interface is to provide access to them so they + * can also be applied to custom codecs if needed. * @since 5.1.12 + * @see CustomCodecs#registerWithDefaultConfig(Object, Consumer) */ interface DefaultCodecConfig { diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java index 325c407e5e3d..cac8a5e7d8b8 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java @@ -17,7 +17,9 @@ package org.springframework.http.codec.support; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.function.Consumer; import org.springframework.core.ResolvableType; @@ -40,8 +42,6 @@ */ abstract class BaseCodecConfigurer implements CodecConfigurer { - protected boolean customCodecsInitialized; - protected final BaseDefaultCodecs defaultCodecs; protected final DefaultCustomCodecs customCodecs; @@ -91,21 +91,20 @@ public CustomCodecs customCodecs() { @Override public List> getReaders() { - initializeCustomCodecs(); - List> result = new ArrayList<>(); + this.defaultCodecs.applyDefaultConfig(this.customCodecs); - result.addAll(this.customCodecs.getTypedReaders()); + List> result = new ArrayList<>(); + result.addAll(this.customCodecs.getTypedReaders().keySet()); result.addAll(this.defaultCodecs.getTypedReaders()); - - result.addAll(this.customCodecs.getObjectReaders()); + result.addAll(this.customCodecs.getObjectReaders().keySet()); result.addAll(this.defaultCodecs.getObjectReaders()); - result.addAll(this.defaultCodecs.getCatchAllReaders()); return result; } @Override public List> getWriters() { + this.defaultCodecs.applyDefaultConfig(this.customCodecs); return getWritersInternal(false); } @@ -117,13 +116,12 @@ public List> getWriters() { * same except for the multipart writer itself. */ protected List> getWritersInternal(boolean forMultipart) { - initializeCustomCodecs(); List> result = new ArrayList<>(); - result.addAll(this.customCodecs.getTypedWriters()); + result.addAll(this.customCodecs.getTypedWriters().keySet()); result.addAll(this.defaultCodecs.getTypedWriters(forMultipart)); - result.addAll(this.customCodecs.getObjectWriters()); + result.addAll(this.customCodecs.getObjectWriters().keySet()); result.addAll(this.defaultCodecs.getObjectWriters(forMultipart)); result.addAll(this.defaultCodecs.getCatchAllWriters()); @@ -133,28 +131,21 @@ protected List> getWritersInternal(boolean forMultipart) { @Override public abstract CodecConfigurer clone(); - private void initializeCustomCodecs() { - if(!this.customCodecsInitialized) { - this.customCodecs.configConsumers.forEach(consumer -> consumer.accept(this.defaultCodecs)); - this.customCodecsInitialized = true; - } - } - /** * Default implementation of {@code CustomCodecs}. */ protected static final class DefaultCustomCodecs implements CustomCodecs { - private final List> typedReaders = new ArrayList<>(); + private final Map, Boolean> typedReaders = new LinkedHashMap<>(4); - private final List> typedWriters = new ArrayList<>(); + private final Map, Boolean> typedWriters = new LinkedHashMap<>(4); - private final List> objectReaders = new ArrayList<>(); + private final Map, Boolean> objectReaders = new LinkedHashMap<>(4); - private final List> objectWriters = new ArrayList<>(); + private final Map, Boolean> objectWriters = new LinkedHashMap<>(4); - private final List> configConsumers = new ArrayList<>(); + private final List> defaultConfigConsumers = new ArrayList<>(4); DefaultCustomCodecs() { } @@ -164,56 +155,103 @@ protected static final class DefaultCustomCodecs implements CustomCodecs { * @since 5.1.12 */ DefaultCustomCodecs(DefaultCustomCodecs other) { - other.typedReaders.addAll(this.typedReaders); - other.typedWriters.addAll(this.typedWriters); - other.objectReaders.addAll(this.objectReaders); - other.objectWriters.addAll(this.objectWriters); + other.typedReaders.putAll(this.typedReaders); + other.typedWriters.putAll(this.typedWriters); + other.objectReaders.putAll(this.objectReaders); + other.objectWriters.putAll(this.objectWriters); + } + + @Override + public void register(Object codec) { + addCodec(codec, false); } + @Override + public void registerWithDefaultConfig(Object codec) { + addCodec(codec, true); + } + + @Override + public void registerWithDefaultConfig(Object codec, Consumer configConsumer) { + addCodec(codec, false); + this.defaultConfigConsumers.add(configConsumer); + } + + @SuppressWarnings("deprecation") @Override public void decoder(Decoder decoder) { - reader(new DecoderHttpMessageReader<>(decoder)); + addCodec(decoder, false); } + @SuppressWarnings("deprecation") @Override public void encoder(Encoder encoder) { - writer(new EncoderHttpMessageWriter<>(encoder)); + addCodec(encoder, false); } + @SuppressWarnings("deprecation") @Override public void reader(HttpMessageReader reader) { - boolean canReadToObject = reader.canRead(ResolvableType.forClass(Object.class), null); - (canReadToObject ? this.objectReaders : this.typedReaders).add(reader); + addCodec(reader, false); } + @SuppressWarnings("deprecation") @Override public void writer(HttpMessageWriter writer) { - boolean canWriteObject = writer.canWrite(ResolvableType.forClass(Object.class), null); - (canWriteObject ? this.objectWriters : this.typedWriters).add(writer); + addCodec(writer, false); } + @SuppressWarnings("deprecation") @Override public void withDefaultCodecConfig(Consumer codecsConfigConsumer) { - this.configConsumers.add(codecsConfigConsumer); + this.defaultConfigConsumers.add(codecsConfigConsumer); + } + + private void addCodec(Object codec, boolean applyDefaultConfig) { + + if (codec instanceof Decoder) { + codec = new DecoderHttpMessageReader<>((Decoder) codec); + } + else if (codec instanceof Encoder) { + codec = new EncoderHttpMessageWriter<>((Encoder) codec); + } + + if (codec instanceof HttpMessageReader) { + HttpMessageReader reader = (HttpMessageReader) codec; + boolean canReadToObject = reader.canRead(ResolvableType.forClass(Object.class), null); + (canReadToObject ? this.objectReaders : this.typedReaders).put(reader, applyDefaultConfig); + } + else if (codec instanceof HttpMessageWriter) { + HttpMessageWriter writer = (HttpMessageWriter) codec; + boolean canWriteObject = writer.canWrite(ResolvableType.forClass(Object.class), null); + (canWriteObject ? this.objectWriters : this.typedWriters).put(writer, applyDefaultConfig); + } + else { + throw new IllegalArgumentException("Unexpected codec type: " + codec.getClass().getName()); + } } // Package private accessors... - List> getTypedReaders() { + Map, Boolean> getTypedReaders() { return this.typedReaders; } - List> getTypedWriters() { + Map, Boolean> getTypedWriters() { return this.typedWriters; } - List> getObjectReaders() { + Map, Boolean> getObjectReaders() { return this.objectReaders; } - List> getObjectWriters() { + Map, Boolean> getObjectWriters() { return this.objectWriters; } + + List> getDefaultConfigConsumers() { + return this.defaultConfigConsumers; + } } } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java index 3b9678984124..4dce1d044e35 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Map; import org.springframework.core.codec.AbstractDataBufferDecoder; import org.springframework.core.codec.ByteArrayDecoder; @@ -433,6 +434,21 @@ List> getCatchAllWriters() { return result; } + void applyDefaultConfig(BaseCodecConfigurer.DefaultCustomCodecs customCodecs) { + applyDefaultConfig(customCodecs.getTypedReaders()); + applyDefaultConfig(customCodecs.getObjectReaders()); + applyDefaultConfig(customCodecs.getTypedWriters()); + applyDefaultConfig(customCodecs.getObjectWriters()); + customCodecs.getDefaultConfigConsumers().forEach(consumer -> consumer.accept(this)); + } + + private void applyDefaultConfig(Map readers) { + readers.entrySet().stream() + .filter(Map.Entry::getValue) + .map(Map.Entry::getKey) + .forEach(this::initCodec); + } + // Accessors for use in subclasses... diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java index 938c225178a3..b2ca4667d5cd 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java @@ -121,11 +121,11 @@ public void defaultAndCustomReaders() { given(customReader1.canRead(ResolvableType.forClass(Object.class), null)).willReturn(false); given(customReader2.canRead(ResolvableType.forClass(Object.class), null)).willReturn(true); - this.configurer.customCodecs().decoder(customDecoder1); - this.configurer.customCodecs().decoder(customDecoder2); + this.configurer.customCodecs().register(customDecoder1); + this.configurer.customCodecs().register(customDecoder2); - this.configurer.customCodecs().reader(customReader1); - this.configurer.customCodecs().reader(customReader2); + this.configurer.customCodecs().register(customReader1); + this.configurer.customCodecs().register(customReader2); List> readers = this.configurer.getReaders(); @@ -161,11 +161,11 @@ public void defaultAndCustomWriters() { given(customWriter1.canWrite(ResolvableType.forClass(Object.class), null)).willReturn(false); given(customWriter2.canWrite(ResolvableType.forClass(Object.class), null)).willReturn(true); - this.configurer.customCodecs().encoder(customEncoder1); - this.configurer.customCodecs().encoder(customEncoder2); + this.configurer.customCodecs().register(customEncoder1); + this.configurer.customCodecs().register(customEncoder2); - this.configurer.customCodecs().writer(customWriter1); - this.configurer.customCodecs().writer(customWriter2); + this.configurer.customCodecs().register(customWriter1); + this.configurer.customCodecs().register(customWriter2); List> writers = this.configurer.getWriters(); @@ -200,11 +200,11 @@ public void defaultsOffCustomReaders() { given(customReader1.canRead(ResolvableType.forClass(Object.class), null)).willReturn(false); given(customReader2.canRead(ResolvableType.forClass(Object.class), null)).willReturn(true); - this.configurer.customCodecs().decoder(customDecoder1); - this.configurer.customCodecs().decoder(customDecoder2); + this.configurer.customCodecs().register(customDecoder1); + this.configurer.customCodecs().register(customDecoder2); - this.configurer.customCodecs().reader(customReader1); - this.configurer.customCodecs().reader(customReader2); + this.configurer.customCodecs().register(customReader1); + this.configurer.customCodecs().register(customReader2); this.configurer.registerDefaults(false); @@ -231,11 +231,11 @@ public void defaultsOffWithCustomWriters() { given(customWriter1.canWrite(ResolvableType.forClass(Object.class), null)).willReturn(false); given(customWriter2.canWrite(ResolvableType.forClass(Object.class), null)).willReturn(true); - this.configurer.customCodecs().encoder(customEncoder1); - this.configurer.customCodecs().encoder(customEncoder2); + this.configurer.customCodecs().register(customEncoder1); + this.configurer.customCodecs().register(customEncoder2); - this.configurer.customCodecs().writer(customWriter1); - this.configurer.customCodecs().writer(customWriter2); + this.configurer.customCodecs().register(customWriter1); + this.configurer.customCodecs().register(customWriter2); this.configurer.registerDefaults(false); @@ -277,10 +277,10 @@ public void cloneCustomCodecs() { this.configurer.registerDefaults(false); CodecConfigurer clone = this.configurer.clone(); - clone.customCodecs().encoder(new Jackson2JsonEncoder()); - clone.customCodecs().decoder(new Jackson2JsonDecoder()); - clone.customCodecs().reader(new ServerSentEventHttpMessageReader()); - clone.customCodecs().writer(new ServerSentEventHttpMessageWriter()); + clone.customCodecs().register(new Jackson2JsonEncoder()); + clone.customCodecs().register(new Jackson2JsonDecoder()); + clone.customCodecs().register(new ServerSentEventHttpMessageReader()); + clone.customCodecs().register(new ServerSentEventHttpMessageWriter()); assertThat(this.configurer.getReaders().size()).isEqualTo(0); assertThat(this.configurer.getWriters().size()).isEqualTo(0); @@ -337,6 +337,7 @@ public void cloneDefaultCodecs() { assertThat(encoders).doesNotContain(jacksonEncoder, jaxb2Encoder, protoEncoder); } + @SuppressWarnings("deprecation") @Test void withDefaultCodecConfig() { AtomicBoolean callbackCalled = new AtomicBoolean(false); diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java index 0aa1bede0b31..ed18f6f8edf7 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java @@ -40,6 +40,7 @@ import org.springframework.core.codec.StringDecoder; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.MediaType; +import org.springframework.http.codec.CodecConfigurer; import org.springframework.http.codec.DecoderHttpMessageReader; import org.springframework.http.codec.EncoderHttpMessageWriter; import org.springframework.http.codec.FormHttpMessageReader; @@ -129,8 +130,8 @@ public void jackson2EncoderOverride() { public void maxInMemorySize() { int size = 99; this.configurer.defaultCodecs().maxInMemorySize(size); + List> readers = this.configurer.getReaders(); - assertThat(readers.size()).isEqualTo(13); assertThat(((ByteArrayDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); assertThat(((ByteBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); assertThat(((DataBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); @@ -150,6 +151,28 @@ public void maxInMemorySize() { assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); } + @Test + public void maxInMemorySizeWithCustomCodecs() { + + int size = 99; + this.configurer.defaultCodecs().maxInMemorySize(size); + this.configurer.registerDefaults(false); + + CodecConfigurer.CustomCodecs customCodecs = this.configurer.customCodecs(); + customCodecs.register(new ByteArrayDecoder()); + customCodecs.registerWithDefaultConfig(new ByteArrayDecoder()); + customCodecs.register(new Jackson2JsonDecoder()); + customCodecs.registerWithDefaultConfig(new Jackson2JsonDecoder()); + + this.configurer.defaultCodecs().enableLoggingRequestDetails(true); + + List> readers = this.configurer.getReaders(); + assertThat(((ByteArrayDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(256 * 1024); + assertThat(((ByteArrayDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); + assertThat(((Jackson2JsonDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(256 * 1024); + assertThat(((Jackson2JsonDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); + } + @Test public void enableRequestLoggingDetails() { this.configurer.defaultCodecs().enableLoggingRequestDetails(true); @@ -164,6 +187,21 @@ public void enableRequestLoggingDetails() { assertThat(reader.isEnableLoggingRequestDetails()).isTrue(); } + @Test + public void enableRequestLoggingDetailsWithCustomCodecs() { + + this.configurer.registerDefaults(false); + this.configurer.defaultCodecs().enableLoggingRequestDetails(true); + + CodecConfigurer.CustomCodecs customCodecs = this.configurer.customCodecs(); + customCodecs.register(new FormHttpMessageReader()); + customCodecs.registerWithDefaultConfig(new FormHttpMessageReader()); + + List> readers = this.configurer.getReaders(); + assertThat(((FormHttpMessageReader) readers.get(0)).isEnableLoggingRequestDetails()).isFalse(); + assertThat(((FormHttpMessageReader) readers.get(1)).isEnableLoggingRequestDetails()).isTrue(); + } + @Test public void cloneConfigurer() { ServerCodecConfigurer clone = this.configurer.clone(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java index 31d0433f487a..8a6e77ae0f9d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java @@ -350,10 +350,10 @@ static class CustomMessageConverterConfig extends WebFluxConfigurationSupport { @Override protected void configureHttpMessageCodecs(ServerCodecConfigurer configurer) { configurer.registerDefaults(false); - configurer.customCodecs().decoder(StringDecoder.textPlainOnly()); - configurer.customCodecs().decoder(new Jaxb2XmlDecoder()); - configurer.customCodecs().encoder(CharSequenceEncoder.textPlainOnly()); - configurer.customCodecs().encoder(new Jaxb2XmlEncoder()); + configurer.customCodecs().register(StringDecoder.textPlainOnly()); + configurer.customCodecs().register(new Jaxb2XmlDecoder()); + configurer.customCodecs().register(CharSequenceEncoder.textPlainOnly()); + configurer.customCodecs().register(new Jaxb2XmlEncoder()); } } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java index b85e6c4248e2..22db275a41a6 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java @@ -68,8 +68,8 @@ public void setup() { resolvers.addCustomResolver(new CustomSyncArgumentResolver()); ServerCodecConfigurer codecs = ServerCodecConfigurer.create(); - codecs.customCodecs().decoder(new ByteArrayDecoder()); - codecs.customCodecs().decoder(new ByteBufferDecoder()); + codecs.customCodecs().register(new ByteArrayDecoder()); + codecs.customCodecs().register(new ByteBufferDecoder()); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); applicationContext.registerBean(TestControllerAdvice.class); From dd9b6287b4c3b507f963c655144ed06dd8f5ff21 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 12 Dec 2019 20:56:03 +0000 Subject: [PATCH 0207/2315] Expose ClientCodecConfigurer in WebClient.Builder Using Consumer instead of Consumer eliminates one level of nesting that is also unnecessary since codecs are the only strategy at present. Closes gh-24124 --- .../server/DefaultWebTestClientBuilder.java | 8 ++++++ .../web/reactive/server/WebTestClient.java | 24 ++++++++++++----- .../client/DefaultWebClientBuilder.java | 11 ++++++++ .../reactive/function/client/WebClient.java | 27 +++++++++++++------ src/docs/asciidoc/web/webflux.adoc | 26 ++++++------------ 5 files changed, 63 insertions(+), 33 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java index 82006d37b255..69279499fe73 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java @@ -23,6 +23,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.http.client.reactive.ReactorClientHttpConnector; +import org.springframework.http.codec.ClientCodecConfigurer; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.MultiValueMap; @@ -136,12 +137,19 @@ public WebTestClient.Builder filters(Consumer> filt return this; } + @Override + public WebTestClient.Builder codecs(Consumer configurer) { + this.webClientBuilder.codecs(configurer); + return this; + } + @Override public WebTestClient.Builder exchangeStrategies(ExchangeStrategies strategies) { this.webClientBuilder.exchangeStrategies(strategies); return this; } + @SuppressWarnings("deprecation") @Override public WebTestClient.Builder exchangeStrategies(Consumer configurer) { this.webClientBuilder.exchangeStrategies(configurer); diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java index 814a3a9ebd09..1c772e50b404 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java @@ -37,6 +37,7 @@ import org.springframework.http.MediaType; import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.http.client.reactive.ClientHttpRequest; +import org.springframework.http.codec.ClientCodecConfigurer; import org.springframework.http.codec.ServerCodecConfigurer; import org.springframework.lang.Nullable; import org.springframework.util.MultiValueMap; @@ -442,14 +443,22 @@ interface Builder { */ Builder filters(Consumer> filtersConsumer); + /** + * Configure the codecs for the {@code WebClient} in the + * {@link #exchangeStrategies(ExchangeStrategies) underlying} + * {@code ExchangeStrategies}. + * @param configurer the configurer to apply + * @since 5.1.13 + */ + Builder codecs(Consumer configurer); + /** * Configure the {@link ExchangeStrategies} to use. - *

    Note that in a scenario where the builder is configured by - * multiple parties, it is preferable to use - * {@link #exchangeStrategies(Consumer)} in order to customize the same - * {@code ExchangeStrategies}. This method here sets the strategies that - * everyone else then can customize. - *

    By default this is {@link ExchangeStrategies#withDefaults()}. + *

    For most cases, prefer using {@link #codecs(Consumer)} which allows + * customizing the codecs in the {@code ExchangeStrategies} rather than + * replace them. That ensures multiple parties can contribute to codecs + * configuration. + *

    By default this is set to {@link ExchangeStrategies#withDefaults()}. * @param strategies the strategies to use */ Builder exchangeStrategies(ExchangeStrategies strategies); @@ -459,8 +468,9 @@ interface Builder { * {@link #exchangeStrategies(ExchangeStrategies)}. This method is * designed for use in scenarios where multiple parties wish to update * the {@code ExchangeStrategies}. - * @since 5.1.12 + * @deprecated as of 5.1.13 in favor of {@link #codecs(Consumer)} */ + @Deprecated Builder exchangeStrategies(Consumer configurer); /** diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java index 44c3164b701b..c255c439d326 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java @@ -27,6 +27,7 @@ import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.http.client.reactive.JettyClientHttpConnector; import org.springframework.http.client.reactive.ReactorClientHttpConnector; +import org.springframework.http.codec.ClientCodecConfigurer; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -206,12 +207,22 @@ public WebClient.Builder clientConnector(ClientHttpConnector connector) { return this; } + @Override + public WebClient.Builder codecs(Consumer configurer) { + if (this.strategiesConfigurers == null) { + this.strategiesConfigurers = new ArrayList<>(4); + } + this.strategiesConfigurers.add(builder -> builder.codecs(configurer)); + return this; + } + @Override public WebClient.Builder exchangeStrategies(ExchangeStrategies strategies) { this.strategies = strategies; return this; } + @SuppressWarnings("deprecation") @Override public WebClient.Builder exchangeStrategies(Consumer configurer) { if (this.strategiesConfigurers == null) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java index 8bafb691fe7d..02d0f07bf3f0 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java @@ -39,6 +39,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.http.client.reactive.ClientHttpRequest; +import org.springframework.http.codec.ClientCodecConfigurer; import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.function.BodyInserter; import org.springframework.web.reactive.function.BodyInserters; @@ -290,14 +291,22 @@ interface Builder { */ Builder clientConnector(ClientHttpConnector connector); + /** + * Configure the codecs for the {@code WebClient} in the + * {@link #exchangeStrategies(ExchangeStrategies) underlying} + * {@code ExchangeStrategies}. + * @param configurer the configurer to apply + * @since 5.1.13 + */ + Builder codecs(Consumer configurer); + /** * Configure the {@link ExchangeStrategies} to use. - *

    Note that in a scenario where the builder is configured by - * multiple parties, it is preferable to use - * {@link #exchangeStrategies(Consumer)} in order to customize the same - * {@code ExchangeStrategies}. This method here sets the strategies that - * everyone else then can customize. - *

    By default this is {@link ExchangeStrategies#withDefaults()}. + *

    For most cases, prefer using {@link #codecs(Consumer)} which allows + * customizing the codecs in the {@code ExchangeStrategies} rather than + * replace them. That ensures multiple parties can contribute to codecs + * configuration. + *

    By default this is set to {@link ExchangeStrategies#withDefaults()}. * @param strategies the strategies to use */ Builder exchangeStrategies(ExchangeStrategies strategies); @@ -307,15 +316,17 @@ interface Builder { * {@link #exchangeStrategies(ExchangeStrategies)}. This method is * designed for use in scenarios where multiple parties wish to update * the {@code ExchangeStrategies}. - * @since 5.1.12 + * @deprecated as of 5.1.13 in favor of {@link #codecs(Consumer)} */ + @Deprecated Builder exchangeStrategies(Consumer configurer); /** * Provide an {@link ExchangeFunction} pre-configured with * {@link ClientHttpConnector} and {@link ExchangeStrategies}. *

    This is an alternative to, and effectively overrides - * {@link #clientConnector}, and {@link #exchangeStrategies}. + * {@link #clientConnector}, and + * {@link #exchangeStrategies(ExchangeStrategies)}. * @param exchangeFunction the exchange function to use */ Builder exchangeFunction(ExchangeFunction exchangeFunction); diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index b0493abda2c8..704867efef20 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -979,31 +979,21 @@ The following example shows how to do so for client-side requests: [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java ---- - Consumer consumer = configurer -> { - CustomDecoder customDecoder = new CustomDecoder(); - configurer.customCodecs().decoder(customDecoder); - configurer.customCodecs().withDefaultCodecConfig(config -> - customDecoder.maxInMemorySize(config.maxInMemorySize()) - ); - } - WebClient webClient = WebClient.builder() - .exchangeStrategies(strategies -> strategies.codecs(consumer)) + .codecs(configurer -> { + CustomDecoder decoder = new CustomDecoder(); + configurer.customCodecs().registerWithDefaultConfig(decoder); + }) .build(); ---- [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin ---- - val consumer: (ClientCodecConfigurer) -> Unit = { configurer -> - val customDecoder = CustomDecoder() - configurer.customCodecs().decoder(customDecoder) - configurer.customCodecs().withDefaultCodecConfig({ config -> - customDecoder.maxInMemorySize(config.maxInMemorySize()) - }) - } - val webClient = WebClient.builder() - .exchangeStrategies({ strategies -> strategies.codecs(consumer) }) + .codecs({ configurer -> + val decoder = CustomDecoder() + configurer.customCodecs().registerWithDefaultConfig(decoder) + }) .build() ---- From b23617637d21f1f49f7f0c1c9c3ccc90c1de5b92 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 12 Dec 2019 21:55:13 +0000 Subject: [PATCH 0208/2315] Fix cloning issue in CodecConfigurer for multipart writers Closes gh-24194 --- .../codec/support/BaseCodecConfigurer.java | 17 +------ .../http/codec/support/BaseDefaultCodecs.java | 44 +++++++++++-------- .../support/ClientDefaultCodecsImpl.java | 10 ++--- .../support/DefaultClientCodecConfigurer.java | 17 ++++++- .../support/ClientCodecConfigurerTests.java | 28 +++++++++++- 5 files changed, 74 insertions(+), 42 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java index cac8a5e7d8b8..94bbf7328f72 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java @@ -105,25 +105,12 @@ public List> getReaders() { @Override public List> getWriters() { this.defaultCodecs.applyDefaultConfig(this.customCodecs); - return getWritersInternal(false); - } - - /** - * Internal method that returns the configured writers. - * @param forMultipart whether to returns writers for general use ("false"), - * or for multipart requests only ("true"). Generally the two sets are the - * same except for the multipart writer itself. - */ - protected List> getWritersInternal(boolean forMultipart) { List> result = new ArrayList<>(); - result.addAll(this.customCodecs.getTypedWriters().keySet()); - result.addAll(this.defaultCodecs.getTypedWriters(forMultipart)); - + result.addAll(this.defaultCodecs.getTypedWriters()); result.addAll(this.customCodecs.getObjectWriters().keySet()); - result.addAll(this.defaultCodecs.getObjectWriters(forMultipart)); - + result.addAll(this.defaultCodecs.getObjectWriters()); result.addAll(this.defaultCodecs.getCatchAllWriters()); return result; } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java index 4dce1d044e35..72ac98593957 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java @@ -355,13 +355,23 @@ final List> getCatchAllReaders() { } /** - * Return writers that support specific types. - * @param forMultipart whether to returns writers for general use ("false"), - * or for multipart requests only ("true"). Generally the two sets are the - * same except for the multipart writer itself. + * Return all writers that support specific types. */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - final List> getTypedWriters(boolean forMultipart) { + @SuppressWarnings({"rawtypes" }) + final List> getTypedWriters() { + if (!this.registerDefaults) { + return Collections.emptyList(); + } + List> writers = getBaseTypedWriters(); + extendTypedWriters(writers); + return writers; + } + + /** + * Return "base" typed writers only, i.e. common to client and server. + */ + @SuppressWarnings("unchecked") + final List> getBaseTypedWriters() { if (!this.registerDefaults) { return Collections.emptyList(); } @@ -371,10 +381,6 @@ final List> getTypedWriters(boolean forMultipart) { writers.add(new EncoderHttpMessageWriter<>(new DataBufferEncoder())); writers.add(new ResourceHttpMessageWriter()); writers.add(new EncoderHttpMessageWriter<>(CharSequenceEncoder.textPlainOnly())); - // No client or server specific multipart writers currently.. - if (!forMultipart) { - extendTypedWriters(writers); - } if (protobufPresent) { Encoder encoder = this.protobufEncoder != null ? this.protobufEncoder : new ProtobufEncoder(); writers.add(new ProtobufHttpMessageWriter((Encoder) encoder)); @@ -390,14 +396,20 @@ protected void extendTypedWriters(List> typedWriters) { /** * Return Object writers (JSON, XML, SSE). - * @param forMultipart whether to returns writers for general use ("false"), - * or for multipart requests only ("true"). Generally the two sets are the - * same except for the multipart writer itself. */ - final List> getObjectWriters(boolean forMultipart) { + final List> getObjectWriters() { if (!this.registerDefaults) { return Collections.emptyList(); } + List> writers = getBaseObjectWriters(); + extendObjectWriters(writers); + return writers; + } + + /** + * Return "base" object writers only, i.e. common to client and server. + */ + final List> getBaseObjectWriters() { List> writers = new ArrayList<>(); if (jackson2Present) { writers.add(new EncoderHttpMessageWriter<>(getJackson2JsonEncoder())); @@ -409,10 +421,6 @@ final List> getObjectWriters(boolean forMultipart) { Encoder encoder = this.jaxb2Encoder != null ? this.jaxb2Encoder : new Jaxb2XmlEncoder(); writers.add(new EncoderHttpMessageWriter<>(encoder)); } - // No client or server specific multipart writers currently.. - if (!forMultipart) { - extendObjectWriters(writers); - } return writers; } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java b/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java index dae7b25704d2..cc1c7f1a439c 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java @@ -54,9 +54,9 @@ class ClientDefaultCodecsImpl extends BaseDefaultCodecs implements ClientCodecCo ClientDefaultCodecsImpl(ClientDefaultCodecsImpl other) { super(other); - this.multipartCodecs = new DefaultMultipartCodecs(other.multipartCodecs); + this.multipartCodecs = (other.multipartCodecs != null ? + new DefaultMultipartCodecs(other.multipartCodecs) : null); this.sseDecoder = other.sseDecoder; - this.partWritersSupplier = other.partWritersSupplier; } @@ -132,10 +132,8 @@ private static class DefaultMultipartCodecs implements ClientCodecConfigurer.Mul DefaultMultipartCodecs() { } - DefaultMultipartCodecs(@Nullable DefaultMultipartCodecs other) { - if (other != null) { - this.writers.addAll(other.writers); - } + DefaultMultipartCodecs(DefaultMultipartCodecs other) { + this.writers.addAll(other.writers); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java index 737282eecd5e..382d11bec8c4 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java @@ -16,7 +16,11 @@ package org.springframework.http.codec.support; +import java.util.ArrayList; +import java.util.List; + import org.springframework.http.codec.ClientCodecConfigurer; +import org.springframework.http.codec.HttpMessageWriter; /** * Default implementation of {@link ClientCodecConfigurer}. @@ -29,11 +33,12 @@ public class DefaultClientCodecConfigurer extends BaseCodecConfigurer implements public DefaultClientCodecConfigurer() { super(new ClientDefaultCodecsImpl()); - ((ClientDefaultCodecsImpl) defaultCodecs()).setPartWritersSupplier(() -> getWritersInternal(true)); + ((ClientDefaultCodecsImpl) defaultCodecs()).setPartWritersSupplier(this::getPartWriters); } private DefaultClientCodecConfigurer(DefaultClientCodecConfigurer other) { super(other); + ((ClientDefaultCodecsImpl) defaultCodecs()).setPartWritersSupplier(this::getPartWriters); } @@ -52,4 +57,14 @@ protected BaseDefaultCodecs cloneDefaultCodecs() { return new ClientDefaultCodecsImpl((ClientDefaultCodecsImpl) defaultCodecs()); } + private List> getPartWriters() { + List> result = new ArrayList<>(); + result.addAll(this.customCodecs.getTypedWriters().keySet()); + result.addAll(this.defaultCodecs.getBaseTypedWriters()); + result.addAll(this.customCodecs.getObjectWriters().keySet()); + result.addAll(this.defaultCodecs.getBaseObjectWriters()); + result.addAll(this.defaultCodecs.getCatchAllWriters()); + return result; + } + } diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java index 1553916771cd..ca119d5de7e4 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java @@ -104,8 +104,8 @@ public void defaultWriters() { assertThat(getNextEncoder(writers).getClass()).isEqualTo(DataBufferEncoder.class); assertThat(writers.get(index.getAndIncrement()).getClass()).isEqualTo(ResourceHttpMessageWriter.class); assertStringEncoder(getNextEncoder(writers), true); - assertThat(writers.get(this.index.getAndIncrement()).getClass()).isEqualTo(MultipartHttpMessageWriter.class); assertThat(writers.get(index.getAndIncrement()).getClass()).isEqualTo(ProtobufHttpMessageWriter.class); + assertThat(writers.get(this.index.getAndIncrement()).getClass()).isEqualTo(MultipartHttpMessageWriter.class); assertThat(getNextEncoder(writers).getClass()).isEqualTo(Jackson2JsonEncoder.class); assertThat(getNextEncoder(writers).getClass()).isEqualTo(Jackson2SmileEncoder.class); assertThat(getNextEncoder(writers).getClass()).isEqualTo(Jaxb2XmlEncoder.class); @@ -159,7 +159,7 @@ public void enableLoggingRequestDetails() { } @Test - public void cloneConfigurer() { + public void clonedConfigurer() { ClientCodecConfigurer clone = this.configurer.clone(); Jackson2JsonDecoder jackson2Decoder = new Jackson2JsonDecoder(); @@ -184,6 +184,30 @@ public void cloneConfigurer() { assertThat(writers).hasSize(10); } + @Test // gh-24194 + public void cloneShouldNotDropMultipartCodecs() { + + ClientCodecConfigurer clone = this.configurer.clone(); + List> writers = + findCodec(clone.getWriters(), MultipartHttpMessageWriter.class).getPartWriters(); + + assertThat(writers).hasSize(10); + } + + @Test + public void cloneShouldNotBeImpactedByChangesToOriginal() { + + ClientCodecConfigurer clone = this.configurer.clone(); + + this.configurer.registerDefaults(false); + this.configurer.customCodecs().register(new Jackson2JsonEncoder()); + + List> writers = + findCodec(clone.getWriters(), MultipartHttpMessageWriter.class).getPartWriters(); + + assertThat(writers).hasSize(10); + } + private Decoder getNextDecoder(List> readers) { HttpMessageReader reader = readers.get(this.index.getAndIncrement()); assertThat(reader).isInstanceOf(DecoderHttpMessageReader.class); From 1dd0a0f0093c844523517f6e665fd51913aaa817 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 12 Dec 2019 22:03:38 +0000 Subject: [PATCH 0209/2315] Fix since tags from prior commit --- .../org/springframework/http/codec/CodecConfigurer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java index 972fc70ce234..62d8a0eb3c73 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java @@ -200,7 +200,7 @@ interface CustomCodecs { *

  • {@link Decoder} (wrapped internally with {@link DecoderHttpMessageReader}) * * @param codec the codec to register - * @since 5.2.3 + * @since 5.1.13 */ void register(Object codec); @@ -215,7 +215,7 @@ interface CustomCodecs { * {@link #getWriters()} are used to obtain the list of configured * readers or writers. * @param codec the codec to register and apply default config to - * @since 5.2.3 + * @since 5.1.13 */ void registerWithDefaultConfig(Object codec); @@ -229,7 +229,7 @@ interface CustomCodecs { * readers or writers. * @param codec the codec to register * @param configConsumer consumer of the default config - * @since 5.2.3 + * @since 5.1.13 */ void registerWithDefaultConfig(Object codec, Consumer configConsumer); From 63844c6d743544339fe001545409c3929a8e11ed Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Thu, 12 Dec 2019 13:55:33 -0500 Subject: [PATCH 0210/2315] MappingJackson2MessageConverter: fix javadoc typo `getJavaTypeForMessage()` - wrong parameter description. --- .../support/converter/MappingJackson2MessageConverter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java b/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java index e12c56d68033..37edf692c66d 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java @@ -340,7 +340,7 @@ protected Message mapToMessage(Object object, Session session, ObjectWriter obje * sets the resulting value (either a mapped id or the raw Java class name) * into the configured type id message property. * @param object the payload object to set a type id for - * @param message the JMS Message to set the type id on + * @param message the JMS Message on which to set the type id property * @throws JMSException if thrown by JMS methods * @see #getJavaTypeForMessage(javax.jms.Message) * @see #setTypeIdPropertyName(String) @@ -442,7 +442,7 @@ protected Object convertFromMessage(Message message, JavaType targetJavaType) *

    The default implementation parses the configured type id property name * and consults the configured type id mapping. This can be overridden with * a different strategy, e.g. doing some heuristics based on message origin. - * @param message the JMS Message to set the type id on + * @param message the JMS Message from which to get the type id property * @throws JMSException if thrown by JMS methods * @see #setTypeIdOnMessage(Object, javax.jms.Message) * @see #setTypeIdPropertyName(String) From 09b6730f3d89b55819ea9bea66314269b7cc4fd9 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Fri, 13 Dec 2019 10:59:33 +0100 Subject: [PATCH 0211/2315] Expose logPrefix in ClientResponse This commit exposes the logPrefix field in the ClientResponse interface. Closes gh-24146 --- .../reactive/function/client/ClientResponse.java | 13 +++++++++++++ .../function/client/DefaultClientResponse.java | 5 +++++ .../client/support/ClientResponseWrapper.java | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java index 5c6eaa0cf196..6c5bf5b79579 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java @@ -204,6 +204,19 @@ public interface ClientResponse { */ Mono createException(); + /** + * Return a log message prefix to use to correlate messages for this response. + * The prefix is based on the {@linkplain ClientRequest#logPrefix() client + * log prefix}, which itself is based on the value of the request attribute + * {@link ClientRequest#LOG_ID_ATTRIBUTE} along with some extra formatting + * so that the prefix can be conveniently prepended with no further + * formatting no separators required. + * @return the log message prefix or an empty String if the + * {@link ClientRequest#LOG_ID_ATTRIBUTE} was not set. + * @since 5.2.3 + */ + String logPrefix(); + // Static builder methods diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java index 11d64b9f7f6e..c148c80ee07b 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java @@ -225,6 +225,11 @@ public Mono createException() { }); } + @Override + public String logPrefix() { + return this.logPrefix; + } + // Used by DefaultClientResponseBuilder HttpRequest request() { return this.requestSupplier.get(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java index 8c98310ce520..3b558eeee308 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java @@ -153,6 +153,11 @@ public Mono createException() { return this.delegate.createException(); } + @Override + public String logPrefix() { + return this.delegate.logPrefix(); + } + /** * Implementation of the {@code Headers} interface that can be subclassed * to adapt the headers in a From 49ddf798e0c41e5b7dcd7492b18a196f74a968e1 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 13 Dec 2019 15:47:05 +0100 Subject: [PATCH 0212/2315] Polish ClassUtils.resolvePrimitiveClassName() See gh-24192 --- .../org/springframework/util/ClassUtils.java | 2 +- .../springframework/util/ClassUtilsTests.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index d0c83bd92d47..6b03c7c33669 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -455,7 +455,7 @@ public static Class resolvePrimitiveClassName(@Nullable String name) { Class result = null; // Most class names will be quite long, considering that they // SHOULD sit in a package, so a length check is worthwhile. - if (name != null && name.length() <= 8) { + if (name != null && name.length() <= 7) { // Could be a primitive - likely. result = primitiveTypeNameMap.get(name); } diff --git a/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java index 4c899124d925..358e80d976f1 100644 --- a/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java @@ -36,6 +36,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.ValueSource; import org.springframework.tests.sample.objects.DerivedTestObject; @@ -155,6 +156,29 @@ public Class loadClass(String name) throws ClassNotFoundException { assertThat(ClassUtils.isCacheSafe(composite, childLoader3)).isTrue(); } + @ParameterizedTest + @CsvSource({ + "boolean, boolean", + "byte, byte", + "char, char", + "short, short", + "int, int", + "long, long", + "float, float", + "double, double", + "[Z, boolean[]", + "[B, byte[]", + "[C, char[]", + "[S, short[]", + "[I, int[]", + "[J, long[]", + "[F, float[]", + "[D, double[]" + }) + void resolvePrimitiveClassName(String input, Class output) { + assertThat(ClassUtils.resolvePrimitiveClassName(input)).isEqualTo(output); + } + @Test void getShortName() { String className = ClassUtils.getShortName(getClass()); From bee2b7cd736a7f59e3c1e35b3fe471cbcfbe1349 Mon Sep 17 00:00:00 2001 From: lixiaolong11000 Date: Wed, 11 Dec 2019 23:44:42 +0800 Subject: [PATCH 0213/2315] Add missing test cases in XmlBeanFactoryTests Closes gh-24189 --- .../factory/xml/XmlBeanFactoryTests.java | 40 +++++++++++++++++++ .../xml/XmlBeanFactoryTests-reftypes.xml | 22 ++++++++++ 2 files changed, 62 insertions(+) diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java index 44807840f5e2..a406141b1a34 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java @@ -536,6 +536,46 @@ public void testCircularReferences() { assertThat(complexEgo.getSpouse().getSpouse() == complexEgo).as("Correct circular reference").isTrue(); } + @Test + public void testCircularReferencesWithConstructor() { + DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); + XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); + reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); + reader.loadBeanDefinitions(REFTYPES_CONTEXT); + assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> + xbf.getBean("jenny_constructor")) + .matches(ex -> ex.contains(BeanCurrentlyInCreationException.class)); + assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> + xbf.getBean("david_constructor")) + .matches(ex -> ex.contains(BeanCurrentlyInCreationException.class)); + } + + @Test + public void testCircularReferencesWithPrototype() { + DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); + XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); + reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); + reader.loadBeanDefinitions(REFTYPES_CONTEXT); + assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> + xbf.getBean("jenny_prototype")) + .matches(ex -> ex.contains(BeanCurrentlyInCreationException.class)); + assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> + xbf.getBean("david_prototype")) + .matches(ex -> ex.contains(BeanCurrentlyInCreationException.class)); + } + + @Test + public void testCircularReferencesWithDependOn() { + DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); + XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); + reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); + reader.loadBeanDefinitions(REFTYPES_CONTEXT); + assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> + xbf.getBean("jenny_depends_on")); + assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> + xbf.getBean("david_depends_on")); + } + @Test public void testCircularReferenceWithFactoryBeanFirst() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml index c9c7ca2400ce..245511e2df56 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml @@ -14,6 +14,28 @@ + + + + + + + + + + + + + + + + + + + + + + Andrew 36 From 47b18e5ea99c6c96a9ce25f575d1cf26dee978e5 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 13 Dec 2019 16:12:39 +0100 Subject: [PATCH 0214/2315] Polishing --- .../factory/xml/XmlBeanFactoryTests.java | 243 +++++++++--------- .../xml/XmlBeanFactoryTests-reftypes.xml | 11 +- 2 files changed, 126 insertions(+), 128 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java index a406141b1a34..f273716e5533 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java @@ -79,7 +79,7 @@ * @author Chris Beams * @author Sam Brannen */ -public class XmlBeanFactoryTests { +class XmlBeanFactoryTests { private static final Class CLASS = XmlBeanFactoryTests.class; private static final String CLASSNAME = CLASS.getSimpleName(); @@ -125,14 +125,14 @@ private static ClassPathResource classPathResource(String suffix) { @Test // SPR-2368 - public void testCollectionsReferredToAsRefLocals() { + void collectionsReferredToAsRefLocals() { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(factory).loadBeanDefinitions(COLLECTIONS_XSD_CONTEXT); factory.preInstantiateSingletons(); } @Test - public void testRefToSeparatePrototypeInstances() { + void refToSeparatePrototypeInstances() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); @@ -151,7 +151,7 @@ public void testRefToSeparatePrototypeInstances() { } @Test - public void testRefToSingleton() { + void refToSingleton() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); @@ -167,7 +167,7 @@ public void testRefToSingleton() { } @Test - public void testInnerBeans() throws IOException { + void innerBeans() throws IOException { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); @@ -245,7 +245,7 @@ public void testInnerBeans() throws IOException { } @Test - public void testInnerBeansWithoutDestroy() { + void innerBeansWithoutDestroy() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); @@ -279,7 +279,7 @@ public void testInnerBeansWithoutDestroy() { } @Test - public void testFailsOnInnerBean() { + void failsOnInnerBean() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); @@ -307,7 +307,7 @@ public void testFailsOnInnerBean() { } @Test - public void testInheritanceFromParentFactoryPrototype() { + void inheritanceFromParentFactoryPrototype() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent); @@ -323,7 +323,7 @@ public void testInheritanceFromParentFactoryPrototype() { } @Test - public void testInheritanceWithDifferentClass() { + void inheritanceWithDifferentClass() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent); @@ -338,7 +338,7 @@ public void testInheritanceWithDifferentClass() { } @Test - public void testInheritanceWithClass() { + void inheritanceWithClass() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent); @@ -353,7 +353,7 @@ public void testInheritanceWithClass() { } @Test - public void testPrototypeInheritanceFromParentFactoryPrototype() { + void prototypeInheritanceFromParentFactoryPrototype() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent); @@ -373,7 +373,7 @@ public void testPrototypeInheritanceFromParentFactoryPrototype() { } @Test - public void testPrototypeInheritanceFromParentFactorySingleton() { + void prototypeInheritanceFromParentFactorySingleton() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent); @@ -392,7 +392,7 @@ public void testPrototypeInheritanceFromParentFactorySingleton() { } @Test - public void testAutowireModeNotInherited() { + void autowireModeNotInherited() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.loadBeanDefinitions(OVERRIDES_CONTEXT); @@ -407,7 +407,7 @@ public void testAutowireModeNotInherited() { } @Test - public void testAbstractParentBeans() { + void abstractParentBeans() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); parent.preInstantiateSingletons(); @@ -428,7 +428,7 @@ public void testAbstractParentBeans() { } @Test - public void testDependenciesMaterializeThis() { + void dependenciesMaterializeThis() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEP_MATERIALIZE_CONTEXT); @@ -447,7 +447,7 @@ public void testDependenciesMaterializeThis() { } @Test - public void testChildOverridesParentBean() { + void childOverridesParentBean() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent); @@ -466,7 +466,7 @@ public void testChildOverridesParentBean() { * If a singleton does this the factory will fail to load. */ @Test - public void testBogusParentageFromParentFactory() { + void bogusParentageFromParentFactory() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent); @@ -483,7 +483,7 @@ public void testBogusParentageFromParentFactory() { * instances even if derived from a prototype */ @Test - public void testSingletonInheritsFromParentFactoryPrototype() { + void singletonInheritsFromParentFactoryPrototype() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent); @@ -498,7 +498,7 @@ public void testSingletonInheritsFromParentFactoryPrototype() { } @Test - public void testSingletonFromParent() { + void singletonFromParent() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); TestBean beanFromParent = (TestBean) parent.getBean("inheritedTestBeanSingleton"); @@ -509,7 +509,7 @@ public void testSingletonFromParent() { } @Test - public void testNestedPropertyValue() { + void nestedPropertyValue() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent); @@ -519,7 +519,7 @@ public void testNestedPropertyValue() { } @Test - public void testCircularReferences() { + void circularReferences() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); @@ -537,47 +537,47 @@ public void testCircularReferences() { } @Test - public void testCircularReferencesWithConstructor() { + void circularReferencesWithConstructor() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); reader.loadBeanDefinitions(REFTYPES_CONTEXT); - assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> - xbf.getBean("jenny_constructor")) + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(() -> xbf.getBean("jenny_constructor")) .matches(ex -> ex.contains(BeanCurrentlyInCreationException.class)); - assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> - xbf.getBean("david_constructor")) + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(() -> xbf.getBean("david_constructor")) .matches(ex -> ex.contains(BeanCurrentlyInCreationException.class)); } @Test - public void testCircularReferencesWithPrototype() { + void circularReferencesWithPrototype() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); reader.loadBeanDefinitions(REFTYPES_CONTEXT); - assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> - xbf.getBean("jenny_prototype")) + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(() -> xbf.getBean("jenny_prototype")) .matches(ex -> ex.contains(BeanCurrentlyInCreationException.class)); - assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> - xbf.getBean("david_prototype")) + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(() -> xbf.getBean("david_prototype")) .matches(ex -> ex.contains(BeanCurrentlyInCreationException.class)); } @Test - public void testCircularReferencesWithDependOn() { + void circularReferencesWithDependOn() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); reader.loadBeanDefinitions(REFTYPES_CONTEXT); - assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> - xbf.getBean("jenny_depends_on")); - assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> - xbf.getBean("david_depends_on")); + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(() -> xbf.getBean("jenny_depends_on")); + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(() -> xbf.getBean("david_depends_on")); } @Test - public void testCircularReferenceWithFactoryBeanFirst() { + void circularReferenceWithFactoryBeanFirst() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); @@ -588,7 +588,7 @@ public void testCircularReferenceWithFactoryBeanFirst() { } @Test - public void testCircularReferenceWithTwoFactoryBeans() { + void circularReferenceWithTwoFactoryBeans() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); @@ -600,7 +600,7 @@ public void testCircularReferenceWithTwoFactoryBeans() { } @Test - public void testCircularReferencesWithNotAllowed() { + void circularReferencesWithNotAllowed() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); xbf.setAllowCircularReferences(false); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); @@ -612,7 +612,7 @@ public void testCircularReferencesWithNotAllowed() { } @Test - public void testCircularReferencesWithWrapping() { + void circularReferencesWithWrapping() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); @@ -624,7 +624,7 @@ public void testCircularReferencesWithWrapping() { } @Test - public void testCircularReferencesWithWrappingAndRawInjectionAllowed() { + void circularReferencesWithWrappingAndRawInjectionAllowed() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); xbf.setAllowRawInjectionDespiteWrapping(true); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); @@ -645,7 +645,7 @@ public void testCircularReferencesWithWrappingAndRawInjectionAllowed() { } @Test - public void testFactoryReferenceCircle() { + void factoryReferenceCircle() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(FACTORY_CIRCLE_CONTEXT); TestBean tb = (TestBean) xbf.getBean("singletonFactory"); @@ -654,14 +654,14 @@ public void testFactoryReferenceCircle() { } @Test - public void testFactoryReferenceWithDoublePrefix() { + void factoryReferenceWithDoublePrefix() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(FACTORY_CIRCLE_CONTEXT); assertThat(xbf.getBean("&&singletonFactory")).isInstanceOf(DummyFactory.class); } @Test - public void testComplexFactoryReferenceCircle() { + void complexFactoryReferenceCircle() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(COMPLEX_FACTORY_CIRCLE_CONTEXT); xbf.getBean("proxy1"); @@ -673,7 +673,7 @@ public void testComplexFactoryReferenceCircle() { } @Test - public void noSuchFactoryBeanMethod() { + void noSuchFactoryBeanMethod() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(NO_SUCH_FACTORY_METHOD_CONTEXT); assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> @@ -681,7 +681,7 @@ public void noSuchFactoryBeanMethod() { } @Test - public void testInitMethodIsInvoked() { + void initMethodIsInvoked() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT); DoubleInitializer in = (DoubleInitializer) xbf.getBean("init-method1"); @@ -693,7 +693,7 @@ public void testInitMethodIsInvoked() { * Test that if a custom initializer throws an exception, it's handled correctly */ @Test - public void testInitMethodThrowsException() { + void initMethodThrowsException() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT); assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> @@ -706,7 +706,7 @@ public void testInitMethodThrowsException() { } @Test - public void testNoSuchInitMethod() { + void noSuchInitMethod() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT); assertThatExceptionOfType(FatalBeanException.class).isThrownBy(() -> @@ -720,7 +720,7 @@ public void testNoSuchInitMethod() { * Check that InitializingBean method is called first. */ @Test - public void testInitializingBeanAndInitMethod() { + void initializingBeanAndInitMethod() { InitAndIB.constructed = false; DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT); @@ -741,7 +741,7 @@ public void testInitializingBeanAndInitMethod() { * Check that InitializingBean method is not called twice. */ @Test - public void testInitializingBeanAndSameInitMethod() { + void initializingBeanAndSameInitMethod() { InitAndIB.constructed = false; DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT); @@ -759,7 +759,7 @@ public void testInitializingBeanAndSameInitMethod() { } @Test - public void testDefaultLazyInit() { + void defaultLazyInit() { InitAndIB.constructed = false; DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEFAULT_LAZY_CONTEXT); @@ -775,21 +775,21 @@ public void testDefaultLazyInit() { } @Test - public void noSuchXmlFile() { + void noSuchXmlFile() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() -> new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(MISSING_CONTEXT)); } @Test - public void invalidXmlFile() { + void invalidXmlFile() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() -> new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INVALID_CONTEXT)); } @Test - public void testAutowire() { + void autowire() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(AUTOWIRE_CONTEXT); TestBean spouse = new TestBean("kerry", 0); @@ -798,7 +798,7 @@ public void testAutowire() { } @Test - public void testAutowireWithParent() { + void autowireWithParent() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(AUTOWIRE_CONTEXT); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); @@ -855,7 +855,7 @@ private void doTestAutowire(DefaultListableBeanFactory xbf) { } @Test - public void testAutowireWithDefault() { + void autowireWithDefault() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEFAULT_AUTOWIRE_CONTEXT); @@ -871,7 +871,7 @@ public void testAutowireWithDefault() { } @Test - public void testAutowireByConstructor() { + void autowireByConstructor() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); ConstructorDependenciesBean rod1 = (ConstructorDependenciesBean) xbf.getBean("rod1"); @@ -909,7 +909,7 @@ public void testAutowireByConstructor() { } @Test - public void testAutowireByConstructorWithSimpleValues() { + void autowireByConstructorWithSimpleValues() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); @@ -939,7 +939,7 @@ public void testAutowireByConstructorWithSimpleValues() { } @Test - public void testRelatedCausesFromConstructorResolution() { + void relatedCausesFromConstructorResolution() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); @@ -954,7 +954,7 @@ public void testRelatedCausesFromConstructorResolution() { } @Test - public void testConstructorArgResolution() { + void constructorArgResolution() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); TestBean kerry1 = (TestBean) xbf.getBean("kerry1"); @@ -1003,7 +1003,7 @@ public void testConstructorArgResolution() { } @Test - public void testPrototypeWithExplicitArguments() { + void prototypeWithExplicitArguments() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); SimpleConstructorArgBean cd1 = (SimpleConstructorArgBean) xbf.getBean("rod18"); @@ -1019,7 +1019,7 @@ public void testPrototypeWithExplicitArguments() { } @Test - public void testConstructorArgWithSingleMatch() { + void constructorArgWithSingleMatch() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); File file = (File) xbf.getBean("file"); @@ -1027,7 +1027,7 @@ public void testConstructorArgWithSingleMatch() { } @Test - public void throwsExceptionOnTooManyArguments() { + void throwsExceptionOnTooManyArguments() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> @@ -1035,7 +1035,7 @@ public void throwsExceptionOnTooManyArguments() { } @Test - public void throwsExceptionOnAmbiguousResolution() { + void throwsExceptionOnAmbiguousResolution() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(() -> @@ -1043,52 +1043,52 @@ public void throwsExceptionOnAmbiguousResolution() { } @Test - public void testDependsOn() { + void dependsOn() { doTestDependencies(DEP_DEPENDSON_CONTEXT, 1); } @Test - public void testDependsOnInInnerBean() { + void dependsOnInInnerBean() { doTestDependencies(DEP_DEPENDSON_INNER_CONTEXT, 4); } @Test - public void testDependenciesThroughConstructorArguments() { + void dependenciesThroughConstructorArguments() { doTestDependencies(DEP_CARG_CONTEXT, 1); } @Test - public void testDependenciesThroughConstructorArgumentAutowiring() { + void dependenciesThroughConstructorArgumentAutowiring() { doTestDependencies(DEP_CARG_AUTOWIRE_CONTEXT, 1); } @Test - public void testDependenciesThroughConstructorArgumentsInInnerBean() { + void dependenciesThroughConstructorArgumentsInInnerBean() { doTestDependencies(DEP_CARG_INNER_CONTEXT, 1); } @Test - public void testDependenciesThroughProperties() { + void dependenciesThroughProperties() { doTestDependencies(DEP_PROP, 1); } @Test - public void testDependenciesThroughPropertiesWithInTheMiddle() { + void dependenciesThroughPropertiesWithInTheMiddle() { doTestDependencies(DEP_PROP_MIDDLE_CONTEXT, 1); } @Test - public void testDependenciesThroughPropertyAutowiringByName() { + void dependenciesThroughPropertyAutowiringByName() { doTestDependencies(DEP_PROP_ABN_CONTEXT, 1); } @Test - public void testDependenciesThroughPropertyAutowiringByType() { + void dependenciesThroughPropertyAutowiringByType() { doTestDependencies(DEP_PROP_ABT_CONTEXT, 1); } @Test - public void testDependenciesThroughPropertiesInInnerBean() { + void dependenciesThroughPropertiesInInnerBean() { doTestDependencies(DEP_PROP_INNER_CONTEXT, 1); } @@ -1120,7 +1120,7 @@ private void doTestDependencies(ClassPathResource resource, int nrOfHoldingBeans * must rather only be picked up when the bean is instantiated. */ @Test - public void testClassNotFoundWithDefaultBeanClassLoader() { + void classNotFoundWithDefaultBeanClassLoader() { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(factory).loadBeanDefinitions(CLASS_NOT_FOUND_CONTEXT); // cool, no errors, so the rubbish class name in the bean def was not resolved @@ -1132,7 +1132,7 @@ public void testClassNotFoundWithDefaultBeanClassLoader() { } @Test - public void testClassNotFoundWithNoBeanClassLoader() { + void classNotFoundWithNoBeanClassLoader() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf); reader.setBeanClassLoader(null); @@ -1141,7 +1141,7 @@ public void testClassNotFoundWithNoBeanClassLoader() { } @Test - public void testResourceAndInputStream() throws IOException { + void resourceAndInputStream() throws IOException { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(RESOURCE_CONTEXT); // comes from "resourceImport.xml" @@ -1165,7 +1165,7 @@ public void testResourceAndInputStream() throws IOException { } @Test - public void testClassPathResourceWithImport() { + void classPathResourceWithImport() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(RESOURCE_CONTEXT); // comes from "resourceImport.xml" @@ -1175,7 +1175,7 @@ public void testClassPathResourceWithImport() { } @Test - public void testUrlResourceWithImport() { + void urlResourceWithImport() { URL url = getClass().getResource(RESOURCE_CONTEXT.getPath()); DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(new UrlResource(url)); @@ -1186,7 +1186,7 @@ public void testUrlResourceWithImport() { } @Test - public void testFileSystemResourceWithImport() throws URISyntaxException { + void fileSystemResourceWithImport() throws URISyntaxException { String file = getClass().getResource(RESOURCE_CONTEXT.getPath()).toURI().getPath(); DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(new FileSystemResource(file)); @@ -1197,7 +1197,7 @@ public void testFileSystemResourceWithImport() throws URISyntaxException { } @Test - public void recursiveImport() { + void recursiveImport() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() -> new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(RECURSIVE_IMPORT_CONTEXT)); @@ -1209,7 +1209,8 @@ public void recursiveImport() { * @since 3.2.8 and 4.0.2 */ @Test - public void methodInjectedBeanMustBeOfSameEnhancedCglibSubclassTypeAcrossBeanFactories() { + @SuppressWarnings("deprecation") + void methodInjectedBeanMustBeOfSameEnhancedCglibSubclassTypeAcrossBeanFactories() { Class firstClass = null; for (int i = 0; i < 10; i++) { @@ -1229,7 +1230,7 @@ public void methodInjectedBeanMustBeOfSameEnhancedCglibSubclassTypeAcrossBeanFac } @Test - public void lookupOverrideMethodsWithSetterInjection() { + void lookupOverrideMethodsWithSetterInjection() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.loadBeanDefinitions(OVERRIDES_CONTEXT); @@ -1296,7 +1297,7 @@ private void lookupOverrideMethodsWithSetterInjection(BeanFactory xbf, } @Test - public void testReplaceMethodOverrideWithSetterInjection() { + void replaceMethodOverrideWithSetterInjection() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.loadBeanDefinitions(DELEGATION_OVERRIDES_CONTEXT); @@ -1343,7 +1344,7 @@ public void testReplaceMethodOverrideWithSetterInjection() { } @Test - public void lookupOverrideOneMethodWithConstructorInjection() { + void lookupOverrideOneMethodWithConstructorInjection() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.loadBeanDefinitions(CONSTRUCTOR_OVERRIDES_CONTEXT); @@ -1366,7 +1367,7 @@ public void lookupOverrideOneMethodWithConstructorInjection() { } @Test - public void testRejectsOverrideOfBogusMethodName() { + void rejectsOverrideOfBogusMethodName() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.loadBeanDefinitions(INVALID_NO_SUCH_METHOD_CONTEXT); @@ -1376,7 +1377,7 @@ public void testRejectsOverrideOfBogusMethodName() { } @Test - public void serializableMethodReplacerAndSuperclass() throws IOException { + void serializableMethodReplacerAndSuperclass() throws IOException { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.loadBeanDefinitions(DELEGATION_OVERRIDES_CONTEXT); @@ -1389,7 +1390,7 @@ public void serializableMethodReplacerAndSuperclass() throws IOException { } @Test - public void testInnerBeanInheritsScopeFromConcreteChildDefinition() { + void innerBeanInheritsScopeFromConcreteChildDefinition() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.loadBeanDefinitions(OVERRIDES_CONTEXT); @@ -1409,7 +1410,7 @@ public void testInnerBeanInheritsScopeFromConcreteChildDefinition() { } @Test - public void testConstructorArgWithSingleSimpleTypeMatch() { + void constructorArgWithSingleSimpleTypeMatch() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); @@ -1421,7 +1422,7 @@ public void testConstructorArgWithSingleSimpleTypeMatch() { } @Test - public void testConstructorArgWithDoubleSimpleTypeMatch() { + void constructorArgWithDoubleSimpleTypeMatch() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); @@ -1435,7 +1436,7 @@ public void testConstructorArgWithDoubleSimpleTypeMatch() { } @Test - public void testDoubleBooleanAutowire() { + void doubleBooleanAutowire() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); DoubleBooleanConstructorBean bean = (DoubleBooleanConstructorBean) xbf.getBean("beanWithDoubleBoolean"); @@ -1444,7 +1445,7 @@ public void testDoubleBooleanAutowire() { } @Test - public void testDoubleBooleanAutowireWithIndex() { + void doubleBooleanAutowireWithIndex() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); DoubleBooleanConstructorBean bean = (DoubleBooleanConstructorBean) xbf.getBean("beanWithDoubleBooleanAndIndex"); @@ -1453,7 +1454,7 @@ public void testDoubleBooleanAutowireWithIndex() { } @Test - public void testLenientDependencyMatching() { + void lenientDependencyMatching() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); LenientDependencyTestBean bean = (LenientDependencyTestBean) xbf.getBean("lenientDependencyTestBean"); @@ -1461,7 +1462,7 @@ public void testLenientDependencyMatching() { } @Test - public void testLenientDependencyMatchingFactoryMethod() { + void lenientDependencyMatchingFactoryMethod() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); LenientDependencyTestBean bean = (LenientDependencyTestBean) xbf.getBean("lenientDependencyTestBeanFactoryMethod"); @@ -1469,7 +1470,7 @@ public void testLenientDependencyMatchingFactoryMethod() { } @Test - public void testNonLenientDependencyMatching() { + void nonLenientDependencyMatching() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("lenientDependencyTestBean"); @@ -1480,7 +1481,7 @@ public void testNonLenientDependencyMatching() { } @Test - public void testNonLenientDependencyMatchingFactoryMethod() { + void nonLenientDependencyMatchingFactoryMethod() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("lenientDependencyTestBeanFactoryMethod"); @@ -1491,7 +1492,7 @@ public void testNonLenientDependencyMatchingFactoryMethod() { } @Test - public void testJavaLangStringConstructor() { + void javaLangStringConstructor() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("string"); @@ -1501,7 +1502,7 @@ public void testJavaLangStringConstructor() { } @Test - public void testCustomStringConstructor() { + void customStringConstructor() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("stringConstructor"); @@ -1511,7 +1512,7 @@ public void testCustomStringConstructor() { } @Test - public void testPrimitiveConstructorArray() { + void primitiveConstructorArray() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("constructorArray"); @@ -1521,7 +1522,7 @@ public void testPrimitiveConstructorArray() { } @Test - public void testIndexedPrimitiveConstructorArray() { + void indexedPrimitiveConstructorArray() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("indexedConstructorArray"); @@ -1531,7 +1532,7 @@ public void testIndexedPrimitiveConstructorArray() { } @Test - public void testStringConstructorArrayNoType() { + void stringConstructorArrayNoType() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("constructorArrayNoType"); @@ -1540,7 +1541,7 @@ public void testStringConstructorArrayNoType() { } @Test - public void testStringConstructorArrayNoTypeNonLenient() { + void stringConstructorArrayNoTypeNonLenient() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("constructorArrayNoType"); @@ -1551,7 +1552,7 @@ public void testStringConstructorArrayNoTypeNonLenient() { } @Test - public void testConstructorWithUnresolvableParameterName() { + void constructorWithUnresolvableParameterName() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); AtomicInteger bean = (AtomicInteger) xbf.getBean("constructorUnresolvableName"); @@ -1561,7 +1562,7 @@ public void testConstructorWithUnresolvableParameterName() { } @Test - public void testWithDuplicateName() { + void withDuplicateName() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); assertThatExceptionOfType(BeansException.class).isThrownBy(() -> new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(TEST_WITH_DUP_NAMES_CONTEXT)) @@ -1569,7 +1570,7 @@ public void testWithDuplicateName() { } @Test - public void testWithDuplicateNameInAlias() { + void withDuplicateNameInAlias() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); assertThatExceptionOfType(BeansException.class).isThrownBy(() -> new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(TEST_WITH_DUP_NAME_IN_ALIAS_CONTEXT)) @@ -1577,7 +1578,7 @@ public void testWithDuplicateNameInAlias() { } @Test - public void testOverrideMethodByArgTypeAttribute() { + void overrideMethodByArgTypeAttribute() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.loadBeanDefinitions(DELEGATION_OVERRIDES_CONTEXT); @@ -1587,7 +1588,7 @@ public void testOverrideMethodByArgTypeAttribute() { } @Test - public void testOverrideMethodByArgTypeElement() { + void overrideMethodByArgTypeElement() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.loadBeanDefinitions(DELEGATION_OVERRIDES_CONTEXT); @@ -1596,7 +1597,7 @@ public void testOverrideMethodByArgTypeElement() { assertThat(oom.replaceMe("abc")).as("should replace").isEqualTo("cba"); } - public static class DoSomethingReplacer implements MethodReplacer { + static class DoSomethingReplacer implements MethodReplacer { public Object lastArg; @@ -1610,7 +1611,7 @@ public Object reimplement(Object obj, Method method, Object[] args) throws Throw } - public static class BadInitializer { + static class BadInitializer { /** Init method */ public void init2() throws IOException { @@ -1619,7 +1620,7 @@ public void init2() throws IOException { } - public static class DoubleInitializer { + static class DoubleInitializer { private int num; @@ -1638,7 +1639,7 @@ public void init() { } - public static class InitAndIB implements InitializingBean, DisposableBean { + static class InitAndIB implements InitializingBean, DisposableBean { public static boolean constructed; @@ -1685,7 +1686,7 @@ public void customDestroy() { } - public static class PreparingBean1 implements DisposableBean { + static class PreparingBean1 implements DisposableBean { public static boolean prepared = false; @@ -1702,7 +1703,7 @@ public void destroy() { } - public static class PreparingBean2 implements DisposableBean { + static class PreparingBean2 implements DisposableBean { public static boolean prepared = false; @@ -1719,7 +1720,7 @@ public void destroy() { } - public static class DependingBean implements InitializingBean, DisposableBean { + static class DependingBean implements InitializingBean, DisposableBean { public static int destroyCount = 0; @@ -1758,7 +1759,7 @@ public void destroy() { } - public static class InTheMiddleBean { + static class InTheMiddleBean { public void setBean1(PreparingBean1 bean1) { } @@ -1768,7 +1769,7 @@ public void setBean2(PreparingBean2 bean2) { } - public static class HoldingBean implements DisposableBean { + static class HoldingBean implements DisposableBean { public static int destroyCount = 0; @@ -1791,7 +1792,7 @@ public void destroy() { } - public static class DoubleBooleanConstructorBean { + static class DoubleBooleanConstructorBean { private Boolean boolean1; private Boolean boolean2; @@ -1815,7 +1816,7 @@ public static DoubleBooleanConstructorBean create(String s1, String s2) { } - public static class LenientDependencyTestBean { + static class LenientDependencyTestBean { public final ITestBean tb; @@ -1850,7 +1851,7 @@ public static LenientDependencyTestBean create(DerivedTestBean tb) { } - public static class ConstructorArrayTestBean { + static class ConstructorArrayTestBean { public final Object array; @@ -1872,7 +1873,7 @@ public ConstructorArrayTestBean(String[] array) { } - public static class StringConstructorTestBean { + static class StringConstructorTestBean { public final String name; @@ -1882,7 +1883,7 @@ public StringConstructorTestBean(String name) { } - public static class WrappingPostProcessor implements BeanPostProcessor { + static class WrappingPostProcessor implements BeanPostProcessor { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml index 245511e2df56..075f8b48ed79 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml @@ -1,5 +1,4 @@ - @@ -23,18 +22,16 @@ - + - + - - + - - + Andrew From 17edbec0351f35aaea61f876fe617e6bbe40b58a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 13 Dec 2019 16:30:03 +0100 Subject: [PATCH 0215/2315] Polishing --- .../org/springframework/core/env/AbstractEnvironment.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java index cfb3fd813670..56c894fa0501 100644 --- a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java +++ b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java @@ -469,9 +469,7 @@ public void merge(ConfigurableEnvironment parent) { if (!ObjectUtils.isEmpty(parentDefaultProfiles)) { synchronized (this.defaultProfiles) { this.defaultProfiles.remove(RESERVED_DEFAULT_PROFILE_NAME); - for (String profile : parentDefaultProfiles) { - this.defaultProfiles.add(profile); - } + Collections.addAll(this.defaultProfiles, parentDefaultProfiles); } } } From d9cae339d60cc7f21b6f067fa4d66c5104cdc15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A6=D1=8B=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Fri, 13 Dec 2019 18:12:18 +0200 Subject: [PATCH 0216/2315] Simplify AdvisedSupport.removeAdvisor() Closes gh-24205 --- .../org/springframework/aop/framework/AdvisedSupport.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java index a82e77a0f1b9..c654811c44a2 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java @@ -283,16 +283,16 @@ public void removeAdvisor(int index) throws AopConfigException { "This configuration only has " + this.advisors.size() + " advisors."); } - Advisor advisor = this.advisors.get(index); + Advisor advisor = this.advisors.remove(index); if (advisor instanceof IntroductionAdvisor) { IntroductionAdvisor ia = (IntroductionAdvisor) advisor; // We need to remove introduction interfaces. - for (int j = 0; j < ia.getInterfaces().length; j++) { - removeInterface(ia.getInterfaces()[j]); + Class[] interfaces = ia.getInterfaces(); + for (Class iface : interfaces) { + removeInterface(iface); } } - this.advisors.remove(index); updateAdvisorArray(); adviceChanged(); } From 6fdf5ef6eeba50387686082f2dd4d1407a669f39 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 13 Dec 2019 17:14:26 +0100 Subject: [PATCH 0217/2315] Polish contribution See gh-24205 --- .../org/springframework/aop/framework/AdvisedSupport.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java index c654811c44a2..b4de26beedfe 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -287,9 +287,8 @@ public void removeAdvisor(int index) throws AopConfigException { if (advisor instanceof IntroductionAdvisor) { IntroductionAdvisor ia = (IntroductionAdvisor) advisor; // We need to remove introduction interfaces. - Class[] interfaces = ia.getInterfaces(); - for (Class iface : interfaces) { - removeInterface(iface); + for (Class ifc : ia.getInterfaces()) { + removeInterface(ifc); } } From f8d6896e40a5d2f6f36b51a0b29bcca8cc53e9ef Mon Sep 17 00:00:00 2001 From: wonwoo Date: Sun, 18 Aug 2019 22:27:13 +0900 Subject: [PATCH 0218/2315] Replace context object with "it" argument Closes gh-23482 --- .../web/servlet/MockHttpServletRequestDsl.kt | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt index 20bb0a0c9907..e997204d3fd0 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt @@ -185,25 +185,25 @@ open class MockHttpServletRequestDsl internal constructor (private val builder: } internal fun perform(mockMvc: MockMvc): ResultActionsDsl { - contextPath?.also { builder.contextPath(contextPath!!) } - servletPath?.also { builder.servletPath(servletPath!!) } - pathInfo?.also { builder.pathInfo(pathInfo) } - secure?.also { builder.secure(secure!!) } - characterEncoding?.also { builder.characterEncoding(characterEncoding!!) } + contextPath?.also { builder.contextPath(it) } + servletPath?.also { builder.servletPath(it) } + pathInfo?.also { builder.pathInfo(it) } + secure?.also { builder.secure(it) } + characterEncoding?.also { builder.characterEncoding(it) } content?.also { - when (content) { - is String -> builder.content(content as String) - is ByteArray -> builder.content(content as ByteArray) - else -> builder.content(content.toString()) + when (it) { + is String -> builder.content(it) + is ByteArray -> builder.content(it) + else -> builder.content(it.toString()) } } - accept?.also { builder.accept(accept!!) } - contentType?.also { builder.contentType(contentType!!) } - params?.also { builder.params(params!!) } - sessionAttrs?.also { builder.sessionAttrs(sessionAttrs!!) } - flashAttrs?.also { builder.flashAttrs(flashAttrs!!) } - session?.also { builder.session(session!!) } - principal?.also { builder.principal(principal!!) } + accept?.also { builder.accept(it) } + contentType?.also { builder.contentType(it) } + params?.also { builder.params(it) } + sessionAttrs?.also { builder.sessionAttrs(it) } + flashAttrs?.also { builder.flashAttrs(it) } + session?.also { builder.session(it) } + principal?.also { builder.principal(it) } return ResultActionsDsl(mockMvc.perform(builder), mockMvc) } } From f4509d6e3a1cf70a561b990ac699962d0d6d7594 Mon Sep 17 00:00:00 2001 From: Dzmitry Kabysh Date: Mon, 7 Jan 2019 19:19:36 -0800 Subject: [PATCH 0219/2315] Allow any Accept and Content-Type raw values See gh-2079 --- .../MockHttpServletRequestBuilder.java | 33 +++++++++++---- .../MockHttpServletRequestBuilderTests.java | 40 +++++++++++++++++++ 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java index c5b527b4adab..51be1286e5d7 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java @@ -294,7 +294,8 @@ public MockHttpServletRequestBuilder contentType(MediaType contentType) { * @since 4.1.2 */ public MockHttpServletRequestBuilder contentType(String contentType) { - this.contentType = MediaType.parseMediaType(contentType).toString(); + Assert.notNull(contentType, "'contentType' must not be null"); + this.contentType = contentType; return this; } @@ -314,11 +315,9 @@ public MockHttpServletRequestBuilder accept(MediaType... mediaTypes) { */ public MockHttpServletRequestBuilder accept(String... mediaTypes) { Assert.notEmpty(mediaTypes, "'mediaTypes' must not be empty"); - List result = new ArrayList<>(mediaTypes.length); - for (String mediaType : mediaTypes) { - result.add(MediaType.parseMediaType(mediaType)); - } - this.headers.set("Accept", MediaType.toString(result)); + List result = new ArrayList<>(mediaTypes.length); + result.addAll(Arrays.asList(mediaTypes)); + this.headers.set("Accept", String.join(", ", result)); return this; } @@ -712,7 +711,7 @@ public final MockHttpServletRequest buildRequest(ServletContext servletContext) if (this.content != null && this.content.length > 0) { String requestContentType = request.getContentType(); - if (requestContentType != null) { + if (requestContentType != null && isValidContentType(requestContentType)) { MediaType mediaType = MediaType.parseMediaType(requestContentType); if (MediaType.APPLICATION_FORM_URLENCODED.includes(mediaType)) { addRequestParams(request, parseFormData(mediaType)); @@ -742,6 +741,26 @@ public final MockHttpServletRequest buildRequest(ServletContext servletContext) return request; } + /** + * Some validation checks to find out if processing of a string value make sense. + */ + private boolean isValidContentType(String mimeType) { + if (!StringUtils.hasLength(mimeType)) { + return false; + } + + int index = mimeType.indexOf(';'); + String fullType = (index >= 0 ? mimeType.substring(0, index) : mimeType).trim(); + if (fullType.isEmpty()) { + return false; + } + int subIndex = fullType.indexOf('/'); + if (subIndex == -1) { + return false; + } + return subIndex != fullType.length() - 1; + } + /** * Create a new {@link MockHttpServletRequest} based on the supplied * {@code ServletContext}. diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java index ae111d7877b6..3479d385e622 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java @@ -29,6 +29,8 @@ import java.util.Locale; import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.servlet.ServletContext; import javax.servlet.http.Cookie; @@ -337,6 +339,21 @@ public void acceptHeader() { assertThat(result.get(1).toString()).isEqualTo("application/xml"); } + @Test + public void anyAcceptMultipleContentTypeViaStringArray() { + this.builder.accept("any", "any2"); + + MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); + List accept = Collections.list(request.getHeaders("Accept")); + List result = Stream.of(accept.get(0).split(",")) + .map(String::trim) + .collect(Collectors.toList()); + + assertThat(result.get(0)).isEqualTo("any"); + assertThat(result).hasSize(2); + assertThat(result.get(1)).isEqualTo("any2"); + } + @Test public void contentType() { this.builder.contentType(MediaType.TEXT_HTML); @@ -363,6 +380,19 @@ public void contentTypeViaString() { assertThat(contentTypes.get(0)).isEqualTo("text/html"); } + @Test + public void anyContentTypeViaString() { + this.builder.contentType("any"); + + MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); + String contentType = request.getContentType(); + List contentTypes = Collections.list(request.getHeaders("Content-Type")); + + assertThat(contentType).isEqualTo("any"); + assertThat(contentTypes).hasSize(1); + assertThat(contentTypes.get(0)).isEqualTo("any"); + } + @Test // SPR-11308 public void contentTypeViaHeader() { this.builder.header("Content-Type", MediaType.TEXT_HTML_VALUE); @@ -372,6 +402,16 @@ public void contentTypeViaHeader() { assertThat(contentType).isEqualTo("text/html"); } + @Test // SPR-17643 + public void invalidContentTypeViaHeader() { + this.builder.header("Content-Type", "yaml"); + this.builder.content("some content"); + MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); + String contentType = request.getContentType(); + + assertThat(contentType).isEqualTo("yaml"); + } + @Test // SPR-11308 public void contentTypeViaMultipleHeaderValues() { this.builder.header("Content-Type", MediaType.TEXT_HTML_VALUE, MediaType.ALL_VALUE); From 542297b30d1dbe36171f76d2a6d6d41f731683f6 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 13 Dec 2019 16:54:53 +0000 Subject: [PATCH 0220/2315] Polishing of contribution See gh-2079 --- .../MockHttpServletRequestBuilder.java | 46 +++++++------------ .../MockHttpServletRequestBuilderTests.java | 37 ++++----------- 2 files changed, 25 insertions(+), 58 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java index 51be1286e5d7..ef178c394bb6 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java @@ -289,7 +289,8 @@ public MockHttpServletRequestBuilder contentType(MediaType contentType) { } /** - * Set the 'Content-Type' header of the request. + * Set the 'Content-Type' header of the request as a raw String value, + * possibly not even well formed (for testing purposes). * @param contentType the content type * @since 4.1.2 */ @@ -310,14 +311,14 @@ public MockHttpServletRequestBuilder accept(MediaType... mediaTypes) { } /** - * Set the 'Accept' header to the given media type(s). - * @param mediaTypes one or more media types + * Set the 'Accept' header using raw String values, possibly not even well + * formed (for testing purposes). + * @param mediaTypes one or more media types; internally joined as + * comma-separated String */ public MockHttpServletRequestBuilder accept(String... mediaTypes) { Assert.notEmpty(mediaTypes, "'mediaTypes' must not be empty"); - List result = new ArrayList<>(mediaTypes.length); - result.addAll(Arrays.asList(mediaTypes)); - this.headers.set("Accept", String.join(", ", result)); + this.headers.set("Accept", String.join(", ", mediaTypes)); return this; } @@ -711,10 +712,15 @@ public final MockHttpServletRequest buildRequest(ServletContext servletContext) if (this.content != null && this.content.length > 0) { String requestContentType = request.getContentType(); - if (requestContentType != null && isValidContentType(requestContentType)) { - MediaType mediaType = MediaType.parseMediaType(requestContentType); - if (MediaType.APPLICATION_FORM_URLENCODED.includes(mediaType)) { - addRequestParams(request, parseFormData(mediaType)); + if (requestContentType != null) { + try { + MediaType mediaType = MediaType.parseMediaType(requestContentType); + if (MediaType.APPLICATION_FORM_URLENCODED.includes(mediaType)) { + addRequestParams(request, parseFormData(mediaType)); + } + } + catch (Exception ex) { + // Must be invalid, ignore.. } } } @@ -741,26 +747,6 @@ public final MockHttpServletRequest buildRequest(ServletContext servletContext) return request; } - /** - * Some validation checks to find out if processing of a string value make sense. - */ - private boolean isValidContentType(String mimeType) { - if (!StringUtils.hasLength(mimeType)) { - return false; - } - - int index = mimeType.indexOf(';'); - String fullType = (index >= 0 ? mimeType.substring(0, index) : mimeType).trim(); - if (fullType.isEmpty()) { - return false; - } - int subIndex = fullType.indexOf('/'); - if (subIndex == -1) { - return false; - } - return subIndex != fullType.length() - 1; - } - /** * Create a new {@link MockHttpServletRequest} based on the supplied * {@code ServletContext}. diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java index 3479d385e622..17fb123acec3 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java @@ -29,8 +29,6 @@ import java.util.Locale; import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.servlet.ServletContext; import javax.servlet.http.Cookie; @@ -339,19 +337,11 @@ public void acceptHeader() { assertThat(result.get(1).toString()).isEqualTo("application/xml"); } - @Test - public void anyAcceptMultipleContentTypeViaStringArray() { + @Test // gh-2079 + public void acceptHeaderWithInvalidValues() { this.builder.accept("any", "any2"); - MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); - List accept = Collections.list(request.getHeaders("Accept")); - List result = Stream.of(accept.get(0).split(",")) - .map(String::trim) - .collect(Collectors.toList()); - - assertThat(result.get(0)).isEqualTo("any"); - assertThat(result).hasSize(2); - assertThat(result.get(1)).isEqualTo("any2"); + assertThat(request.getHeader("Accept")).isEqualTo("any, any2"); } @Test @@ -380,17 +370,11 @@ public void contentTypeViaString() { assertThat(contentTypes.get(0)).isEqualTo("text/html"); } - @Test - public void anyContentTypeViaString() { + @Test // gh-2079 + public void contentTypeWithInvalidValue() { this.builder.contentType("any"); - MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); - String contentType = request.getContentType(); - List contentTypes = Collections.list(request.getHeaders("Content-Type")); - - assertThat(contentType).isEqualTo("any"); - assertThat(contentTypes).hasSize(1); - assertThat(contentTypes.get(0)).isEqualTo("any"); + assertThat(request.getContentType()).isEqualTo("any"); } @Test // SPR-11308 @@ -402,14 +386,11 @@ public void contentTypeViaHeader() { assertThat(contentType).isEqualTo("text/html"); } - @Test // SPR-17643 - public void invalidContentTypeViaHeader() { + @Test // gh-2079 + public void contentTypeViaHeaderWithInvalidValue() { this.builder.header("Content-Type", "yaml"); - this.builder.content("some content"); MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); - String contentType = request.getContentType(); - - assertThat(contentType).isEqualTo("yaml"); + assertThat(request.getContentType()).isEqualTo("yaml"); } @Test // SPR-11308 From 5836680490afca32ba6070bd524fafc89b6c2342 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 15 Dec 2019 23:28:04 +0100 Subject: [PATCH 0221/2315] Upgrade to Log4J 2.13 and RxJava 2.2.16 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 73bbb2c39246..ebf26209ac12 100644 --- a/build.gradle +++ b/build.gradle @@ -51,7 +51,7 @@ configure(allprojects) { project -> mavenBom "org.junit:junit-bom:5.5.2" } dependencies { - dependencySet(group: 'org.apache.logging.log4j', version: '2.12.1') { + dependencySet(group: 'org.apache.logging.log4j', version: '2.13.0') { entry 'log4j-api' entry 'log4j-core' entry 'log4j-slf4j-impl' @@ -76,7 +76,7 @@ configure(allprojects) { project -> dependency "io.reactivex:rxjava:1.3.8" dependency "io.reactivex:rxjava-reactive-streams:1.2.1" - dependency "io.reactivex.rxjava2:rxjava:2.2.15" + dependency "io.reactivex.rxjava2:rxjava:2.2.16" dependency "com.caucho:hessian:4.0.62" dependency "com.fasterxml:aalto-xml:1.2.2" From f353bc0c2500339dd6a58de82c985d271f66e130 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 16 Dec 2019 16:49:39 +0100 Subject: [PATCH 0222/2315] ConcurrentReferenceHashMap cache for getInterfaceMethodIfPossible results Closes gh-24206 --- .../org/springframework/util/ClassUtils.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index 6b03c7c33669..44390ec2dfd1 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -111,6 +111,11 @@ public abstract class ClassUtils { */ private static final Set> javaLanguageInterfaces; + /** + * Cache for equivalent methods on an interface implemented by the declaring class. + */ + private static final Map interfaceMethodCache = new ConcurrentReferenceHashMap<>(256); + static { primitiveWrapperTypeMap.put(Boolean.class, boolean.class); @@ -1277,13 +1282,16 @@ public static Method getMostSpecificMethod(Method method, @Nullable Class tar * @see #getMostSpecificMethod */ public static Method getInterfaceMethodIfPossible(Method method) { - if (Modifier.isPublic(method.getModifiers()) && !method.getDeclaringClass().isInterface()) { - Class current = method.getDeclaringClass(); + if (!Modifier.isPublic(method.getModifiers()) || method.getDeclaringClass().isInterface()) { + return method; + } + return interfaceMethodCache.computeIfAbsent(method, key -> { + Class current = key.getDeclaringClass(); while (current != null && current != Object.class) { Class[] ifcs = current.getInterfaces(); for (Class ifc : ifcs) { try { - return ifc.getMethod(method.getName(), method.getParameterTypes()); + return ifc.getMethod(key.getName(), key.getParameterTypes()); } catch (NoSuchMethodException ex) { // ignore @@ -1291,8 +1299,8 @@ public static Method getInterfaceMethodIfPossible(Method method) { } current = current.getSuperclass(); } - } - return method; + return key; + }); } /** From 0711e58a5fa200cb503ff11799cd06413bc7e7c4 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 16 Dec 2019 16:50:04 +0100 Subject: [PATCH 0223/2315] Un-deprecate PathResource (for NIO Path resolution in createRelative) Includes aligned createRelative signature and dedicated java.io.File test. Closes gh-24211 --- .../springframework/core/io/FileSystemResource.java | 12 +++++++++++- .../org/springframework/core/io/PathResource.java | 9 +++++---- .../org/springframework/core/io/ResourceTests.java | 9 +++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java b/spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java index d1b6ca0f0a38..d0f7d392e802 100644 --- a/spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -49,6 +49,7 @@ * * @author Juergen Hoeller * @since 28.12.2003 + * @see #FileSystemResource(String) * @see #FileSystemResource(File) * @see #FileSystemResource(Path) * @see java.io.File @@ -108,6 +109,15 @@ public FileSystemResource(File file) { *

    In contrast to {@link PathResource}, this variant strictly follows the * general {@link FileSystemResource} conventions, in particular in terms of * path cleaning and {@link #createRelative(String)} handling. + *

    Note: When building relative resources via {@link #createRelative}, + * the relative path will apply at the same directory level: + * e.g. Paths.get("C:/dir1"), relative path "dir2" -> "C:/dir2"! + * If you prefer to have relative paths built underneath the given root directory, + * use the {@link #FileSystemResource(String) constructor with a file path} + * to append a trailing slash to the root path: "C:/dir1/", which indicates + * this directory as root for all relative paths. Alternatively, consider + * using {@link PathResource#PathResource(Path)} for {@code java.nio.path.Path} + * resolution in {@code createRelative}, always nesting relative paths. * @param filePath a Path handle to a file * @since 5.1 * @see #FileSystemResource(File) diff --git a/spring-core/src/main/java/org/springframework/core/io/PathResource.java b/spring-core/src/main/java/org/springframework/core/io/PathResource.java index 83308b60c081..bd334cc51856 100644 --- a/spring-core/src/main/java/org/springframework/core/io/PathResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/PathResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -45,15 +45,16 @@ * in {@link FileSystemResource#FileSystemResource(Path) FileSystemResource}, * applying Spring's standard String-based path transformations but * performing all operations via the {@link java.nio.file.Files} API. + * This {@code PathResource} is effectively a pure {@code java.nio.path.Path} + * based alternative with different {@code createRelative} behavior. * * @author Philippe Marschall * @author Juergen Hoeller * @since 4.0 * @see java.nio.file.Path * @see java.nio.file.Files - * @deprecated as of 5.1.1, in favor of {@link FileSystemResource#FileSystemResource(Path)} + * @see FileSystemResource */ -@Deprecated public class PathResource extends AbstractResource implements WritableResource { private final Path path; @@ -253,7 +254,7 @@ public long lastModified() throws IOException { * @see java.nio.file.Path#resolve(String) */ @Override - public Resource createRelative(String relativePath) throws IOException { + public Resource createRelative(String relativePath) { return new PathResource(this.path.resolve(relativePath)); } diff --git a/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java index ba18f3f2bd48..838656757593 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java @@ -17,6 +17,7 @@ package org.springframework.core.io; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -130,6 +131,14 @@ void fileSystemResource() throws IOException { assertThat(resource).isEqualTo(new FileSystemResource(file)); } + @Test + void fileSystemResourceWithFile() throws IOException { + File file = new File(getClass().getResource("Resource.class").getFile()); + Resource resource = new FileSystemResource(file); + doTestResource(resource); + assertThat(resource).isEqualTo(new FileSystemResource(file)); + } + @Test void fileSystemResourceWithFilePath() throws Exception { Path filePath = Paths.get(getClass().getResource("Resource.class").toURI()); From 7474ee70419cb15b71841a5544e005d9e660cc47 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 16 Dec 2019 16:50:30 +0100 Subject: [PATCH 0224/2315] Polishing --- .../test/java/org/springframework/cache/CacheReproTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java b/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java index 6ad9f90b83b3..2d9ca8f647f2 100644 --- a/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java +++ b/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java @@ -56,7 +56,7 @@ public class CacheReproTests { @Test - public void spr11124MultipleAnnotations() throws Exception { + public void spr11124MultipleAnnotations() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Spr11124Config.class); Spr11124Service bean = context.getBean(Spr11124Service.class); bean.single(2); @@ -67,7 +67,7 @@ public void spr11124MultipleAnnotations() throws Exception { } @Test - public void spr11249PrimitiveVarargs() throws Exception { + public void spr11249PrimitiveVarargs() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Spr11249Config.class); Spr11249Service bean = context.getBean(Spr11249Service.class); Object result = bean.doSomething("op", 2, 3); From 0eacb443b01833eb1b34006d74c2ee6da04af403 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 18 Dec 2019 16:22:04 +0000 Subject: [PATCH 0225/2315] Reuse InputStream in ResourceRegionHttpMessageConverter The converter now tries to keep reading from the same InputStream which should be possible with ordered and non-overlapping regions. When necessary the InputStream is re-opened. Closes gh-24214 --- .../org/springframework/util/StreamUtils.java | 4 +- .../ResourceRegionHttpMessageConverter.java | 41 +++++++++++++------ ...sourceRegionHttpMessageConverterTests.java | 39 ++++++++++++++++++ 3 files changed, 70 insertions(+), 14 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/StreamUtils.java b/spring-core/src/main/java/org/springframework/util/StreamUtils.java index 037051ee768e..9ada13667cbc 100644 --- a/spring-core/src/main/java/org/springframework/util/StreamUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StreamUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -170,7 +170,7 @@ public static long copyRange(InputStream in, OutputStream out, long start, long } long bytesToCopy = end - start + 1; - byte[] buffer = new byte[StreamUtils.BUFFER_SIZE]; + byte[] buffer = new byte[(int) Math.min(StreamUtils.BUFFER_SIZE, bytesToCopy)]; while (bytesToCopy > 0) { int bytesRead = in.read(buffer); if (bytesRead == -1) { diff --git a/spring-web/src/main/java/org/springframework/http/converter/ResourceRegionHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/ResourceRegionHttpMessageConverter.java index be98db9122a1..a7167e530b5a 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/ResourceRegionHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/ResourceRegionHttpMessageConverter.java @@ -179,11 +179,23 @@ private void writeResourceRegionCollection(Collection resourceRe responseHeaders.set(HttpHeaders.CONTENT_TYPE, "multipart/byteranges; boundary=" + boundaryString); OutputStream out = outputMessage.getBody(); - for (ResourceRegion region : resourceRegions) { - long start = region.getPosition(); - long end = start + region.getCount() - 1; - InputStream in = region.getResource().getInputStream(); - try { + Resource resource = null; + InputStream in = null; + long inputStreamPosition = 0; + + try { + for (ResourceRegion region : resourceRegions) { + long start = region.getPosition() - inputStreamPosition; + if (start < 0 || resource != region.getResource()) { + if (in != null) { + in.close(); + } + resource = region.getResource(); + in = resource.getInputStream(); + inputStreamPosition = 0; + start = region.getPosition(); + } + long end = start + region.getCount() - 1; // Writing MIME header. println(out); print(out, "--" + boundaryString); @@ -193,20 +205,25 @@ private void writeResourceRegionCollection(Collection resourceRe println(out); } Long resourceLength = region.getResource().contentLength(); - end = Math.min(end, resourceLength - 1); - print(out, "Content-Range: bytes " + start + '-' + end + '/' + resourceLength); + end = Math.min(end, resourceLength - inputStreamPosition - 1); + print(out, "Content-Range: bytes " + + region.getPosition() + '-' + (region.getPosition() + region.getCount() - 1) + + '/' + resourceLength); println(out); println(out); // Printing content StreamUtils.copyRange(in, out, start, end); + inputStreamPosition += (end + 1); } - finally { - try { + } + finally { + try { + if (in != null) { in.close(); } - catch (IOException ex) { - // ignore - } + } + catch (IOException ex) { + // ignore } } diff --git a/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java index 67e21fd45e51..12ba56e15457 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java @@ -144,6 +144,45 @@ public void partialContentMultipleByteRanges() throws Exception { assertThat(ranges[15]).isEqualTo("resource content."); } + @Test + public void partialContentMultipleByteRangesInRandomOrderAndOverlapping() throws Exception { + MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); + Resource body = new ClassPathResource("byterangeresource.txt", getClass()); + List rangeList = HttpRange.parseRanges("bytes=7-15,0-5,17-20,20-29"); + List regions = new ArrayList<>(); + for(HttpRange range : rangeList) { + regions.add(range.toResourceRegion(body)); + } + + converter.write(regions, MediaType.TEXT_PLAIN, outputMessage); + + HttpHeaders headers = outputMessage.getHeaders(); + assertThat(headers.getContentType().toString()).startsWith("multipart/byteranges;boundary="); + String boundary = "--" + headers.getContentType().toString().substring(30); + String content = outputMessage.getBodyAsString(StandardCharsets.UTF_8); + String[] ranges = StringUtils.tokenizeToStringArray(content, "\r\n", false, true); + + assertThat(ranges[0]).isEqualTo(boundary); + assertThat(ranges[1]).isEqualTo("Content-Type: text/plain"); + assertThat(ranges[2]).isEqualTo("Content-Range: bytes 7-15/39"); + assertThat(ranges[3]).isEqualTo("Framework"); + + assertThat(ranges[4]).isEqualTo(boundary); + assertThat(ranges[5]).isEqualTo("Content-Type: text/plain"); + assertThat(ranges[6]).isEqualTo("Content-Range: bytes 0-5/39"); + assertThat(ranges[7]).isEqualTo("Spring"); + + assertThat(ranges[8]).isEqualTo(boundary); + assertThat(ranges[9]).isEqualTo("Content-Type: text/plain"); + assertThat(ranges[10]).isEqualTo("Content-Range: bytes 17-20/39"); + assertThat(ranges[11]).isEqualTo("test"); + + assertThat(ranges[12]).isEqualTo(boundary); + assertThat(ranges[13]).isEqualTo("Content-Type: text/plain"); + assertThat(ranges[14]).isEqualTo("Content-Range: bytes 20-29/39"); + assertThat(ranges[15]).isEqualTo("t resource"); + } + @Test // SPR-15041 public void applicationOctetStreamDefaultContentType() throws Exception { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); From 44da77513444f8388397f93d057ad1b6187516d3 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 18 Dec 2019 16:48:49 +0000 Subject: [PATCH 0226/2315] CorsInterceptor skips async dispatch Closes gh-24223 --- .../web/servlet/handler/AbstractHandlerMapping.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java index 28f059926f9c..df7096c5239b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java @@ -36,6 +36,8 @@ import org.springframework.util.PathMatcher; import org.springframework.web.HttpRequestHandler; import org.springframework.web.context.request.WebRequestInterceptor; +import org.springframework.web.context.request.async.WebAsyncManager; +import org.springframework.web.context.request.async.WebAsyncUtils; import org.springframework.web.context.support.WebApplicationObjectSupport; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfigurationSource; @@ -571,6 +573,12 @@ public CorsInterceptor(@Nullable CorsConfiguration config) { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + // Consistent with CorsFilter, ignore ASYNC dispatches + WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request); + if (asyncManager.hasConcurrentResult()) { + return true; + } + return corsProcessor.processRequest(this.config, request, response); } From 41f40c6c229d3b4f768718f1ec229d8f0ad76d76 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 19 Dec 2019 12:23:12 +0000 Subject: [PATCH 0227/2315] Escape quotes in filename Closes gh-24220 --- .../http/ContentDisposition.java | 22 +++++- .../http/ContentDispositionTests.java | 79 ++++++++++++++----- 2 files changed, 80 insertions(+), 21 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java index ac77d45c7e65..a9e574148c54 100644 --- a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java +++ b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java @@ -458,7 +458,11 @@ public interface Builder { Builder name(String name); /** - * Set the value of the {@literal filename} parameter. + * Set the value of the {@literal filename} parameter. The given + * filename will be formatted as quoted-string, as defined in RFC 2616, + * section 2.2, and any quote characters within the filename value will + * be escaped with a backslash, e.g. {@code "foo\"bar.txt"} becomes + * {@code "foo\\\"bar.txt"}. */ Builder filename(String filename); @@ -539,10 +543,24 @@ public Builder name(String name) { @Override public Builder filename(String filename) { - this.filename = filename; + Assert.hasText(filename, "No filename"); + this.filename = escapeQuotationMarks(filename); return this; } + private static String escapeQuotationMarks(String filename) { + if (filename.indexOf('"') == -1) { + return filename; + } + boolean escaped = false; + StringBuilder sb = new StringBuilder(); + for (char c : filename.toCharArray()) { + sb.append((c == '"' && !escaped) ? "\\\"" : c); + escaped = (!escaped && c == '\\'); + } + return sb.toString(); + } + @Override public Builder filename(String filename, Charset charset) { this.filename = filename; diff --git a/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java b/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java index 26b5ae57eab8..caf6e398e77a 100644 --- a/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java +++ b/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java @@ -19,11 +19,13 @@ import java.nio.charset.StandardCharsets; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.util.function.BiConsumer; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.springframework.http.ContentDisposition.builder; /** * Unit tests for {@link ContentDisposition} @@ -38,7 +40,7 @@ public class ContentDispositionTests { @Test public void parse() { assertThat(parse("form-data; name=\"foo\"; filename=\"foo.txt\"; size=123")) - .isEqualTo(ContentDisposition.builder("form-data") + .isEqualTo(builder("form-data") .name("foo") .filename("foo.txt") .size(123L) @@ -48,7 +50,7 @@ public void parse() { @Test public void parseFilenameUnquoted() { assertThat(parse("form-data; filename=unquoted")) - .isEqualTo(ContentDisposition.builder("form-data") + .isEqualTo(builder("form-data") .filename("unquoted") .build()); } @@ -56,7 +58,7 @@ public void parseFilenameUnquoted() { @Test // SPR-16091 public void parseFilenameWithSemicolon() { assertThat(parse("attachment; filename=\"filename with ; semicolon.txt\"")) - .isEqualTo(ContentDisposition.builder("attachment") + .isEqualTo(builder("attachment") .filename("filename with ; semicolon.txt") .build()); } @@ -64,7 +66,7 @@ public void parseFilenameWithSemicolon() { @Test public void parseEncodedFilename() { assertThat(parse("form-data; name=\"name\"; filename*=UTF-8''%E4%B8%AD%E6%96%87.txt")) - .isEqualTo(ContentDisposition.builder("form-data") + .isEqualTo(builder("form-data") .name("name") .filename("中文.txt", StandardCharsets.UTF_8) .build()); @@ -73,7 +75,7 @@ public void parseEncodedFilename() { @Test // gh-24112 public void parseEncodedFilenameWithPaddedCharset() { assertThat(parse("attachment; filename*= UTF-8''some-file.zip")) - .isEqualTo(ContentDisposition.builder("attachment") + .isEqualTo(builder("attachment") .filename("some-file.zip", StandardCharsets.UTF_8) .build()); } @@ -81,7 +83,7 @@ public void parseEncodedFilenameWithPaddedCharset() { @Test public void parseEncodedFilenameWithoutCharset() { assertThat(parse("form-data; name=\"name\"; filename*=test.txt")) - .isEqualTo(ContentDisposition.builder("form-data") + .isEqualTo(builder("form-data") .name("name") .filename("test.txt") .build()); @@ -104,18 +106,30 @@ public void parseEncodedFilenameWithInvalidName() { @Test // gh-23077 public void parseWithEscapedQuote() { - assertThat(parse("form-data; name=\"file\"; filename=\"\\\"The Twilight Zone\\\".txt\"; size=123")) - .isEqualTo(ContentDisposition.builder("form-data") - .name("file") - .filename("\\\"The Twilight Zone\\\".txt") - .size(123L) - .build()); + + BiConsumer tester = (description, filename) -> { + assertThat(parse("form-data; name=\"file\"; filename=\"" + filename + "\"; size=123")) + .as(description) + .isEqualTo(builder("form-data").name("file").filename(filename).size(123L).build()); + }; + + tester.accept("Escaped quotes should be ignored", + "\\\"The Twilight Zone\\\".txt"); + + tester.accept("Escaped quotes preceded by escaped backslashes should be ignored", + "\\\\\\\"The Twilight Zone\\\\\\\".txt"); + + tester.accept("Escaped backslashes should not suppress quote", + "The Twilight Zone \\\\"); + + tester.accept("Escaped backslashes should not suppress quote", + "The Twilight Zone \\\\\\\\"); } @Test public void parseWithExtraSemicolons() { assertThat(parse("form-data; name=\"foo\";; ; filename=\"foo.txt\"; size=123")) - .isEqualTo(ContentDisposition.builder("form-data") + .isEqualTo(builder("form-data") .name("foo") .filename("foo.txt") .size(123L) @@ -133,7 +147,7 @@ public void parseDates() { "creation-date=\"" + creationTime.format(formatter) + "\"; " + "modification-date=\"" + modificationTime.format(formatter) + "\"; " + "read-date=\"" + readTime.format(formatter) + "\"")).isEqualTo( - ContentDisposition.builder("attachment") + builder("attachment") .creationDate(creationTime) .modificationDate(modificationTime) .readDate(readTime) @@ -149,7 +163,7 @@ public void parseIgnoresInvalidDates() { "creation-date=\"-1\"; " + "modification-date=\"-1\"; " + "read-date=\"" + readTime.format(formatter) + "\"")).isEqualTo( - ContentDisposition.builder("attachment") + builder("attachment") .readDate(readTime) .build()); } @@ -177,7 +191,7 @@ private static ContentDisposition parse(String input) { @Test public void format() { assertThat( - ContentDisposition.builder("form-data") + builder("form-data") .name("foo") .filename("foo.txt") .size(123L) @@ -188,7 +202,7 @@ public void format() { @Test public void formatWithEncodedFilename() { assertThat( - ContentDisposition.builder("form-data") + builder("form-data") .name("name") .filename("中文.txt", StandardCharsets.UTF_8) .build().toString()) @@ -198,7 +212,7 @@ public void formatWithEncodedFilename() { @Test public void formatWithEncodedFilenameUsingUsAscii() { assertThat( - ContentDisposition.builder("form-data") + builder("form-data") .name("name") .filename("test.txt", StandardCharsets.US_ASCII) .build() @@ -206,10 +220,37 @@ public void formatWithEncodedFilenameUsingUsAscii() { .isEqualTo("form-data; name=\"name\"; filename=\"test.txt\""); } + @Test // gh-24220 + public void formatWithFilenameWithQuotes() { + + BiConsumer tester = (input, output) -> { + assertThat(builder("form-data").filename(input).build().toString()) + .isEqualTo("form-data; filename=\"" + output + "\""); + }; + + String filename = "\"foo.txt"; + tester.accept(filename, "\\" + filename); + + filename = "\\\"foo.txt"; + tester.accept(filename, filename); + + filename = "\\\\\"foo.txt"; + tester.accept(filename, "\\" + filename); + + filename = "\\\\\\\"foo.txt"; + tester.accept(filename, filename); + + filename = "\\\\\\\\\"foo.txt"; + tester.accept(filename, "\\" + filename); + + tester.accept("\"\"foo.txt", "\\\"\\\"foo.txt"); + tester.accept("\"\"\"foo.txt", "\\\"\\\"\\\"foo.txt"); + } + @Test public void formatWithEncodedFilenameUsingInvalidCharset() { assertThatIllegalArgumentException().isThrownBy(() -> - ContentDisposition.builder("form-data") + builder("form-data") .name("name") .filename("test.txt", StandardCharsets.UTF_16) .build() From 15321a31633c7a9d0f838783640e7148472e4d9a Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 19 Dec 2019 13:06:53 +0000 Subject: [PATCH 0228/2315] Fix checkstyle violations --- .../org/springframework/http/ContentDispositionTests.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java b/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java index caf6e398e77a..c14753ab844f 100644 --- a/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java +++ b/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java @@ -107,11 +107,10 @@ public void parseEncodedFilenameWithInvalidName() { @Test // gh-23077 public void parseWithEscapedQuote() { - BiConsumer tester = (description, filename) -> { + BiConsumer tester = (description, filename) -> assertThat(parse("form-data; name=\"file\"; filename=\"" + filename + "\"; size=123")) .as(description) .isEqualTo(builder("form-data").name("file").filename(filename).size(123L).build()); - }; tester.accept("Escaped quotes should be ignored", "\\\"The Twilight Zone\\\".txt"); @@ -223,10 +222,9 @@ public void formatWithEncodedFilenameUsingUsAscii() { @Test // gh-24220 public void formatWithFilenameWithQuotes() { - BiConsumer tester = (input, output) -> { + BiConsumer tester = (input, output) -> assertThat(builder("form-data").filename(input).build().toString()) .isEqualTo("form-data; filename=\"" + output + "\""); - }; String filename = "\"foo.txt"; tester.accept(filename, "\\" + filename); From ea4f1ca5d5c45db40da47684ceb522fec8fd294c Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 19 Dec 2019 16:27:40 +0000 Subject: [PATCH 0229/2315] Update ContentDisposition to RFC 6266 Close gh-24231 --- .../http/ContentDisposition.java | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java index a9e574148c54..4d480116c39c 100644 --- a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java +++ b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java @@ -33,18 +33,20 @@ import static java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME; /** - * Represent the Content-Disposition type and parameters as defined in RFC 2183. + * Represent the Content-Disposition type and parameters as defined in RFC 6266. * * @author Sebastien Deleuze * @author Juergen Hoeller + * @author Rossen Stoyanchev * @since 5.0 - * @see RFC 2183 + * @see RFC 6266 */ public final class ContentDisposition { private static final String INVALID_HEADER_FIELD_PARAMETER_FORMAT = "Invalid header field parameter format (as defined in RFC 5987)"; + @Nullable private final String type; @@ -124,7 +126,11 @@ public Charset getCharset() { /** * Return the value of the {@literal size} parameter, or {@code null} if not defined. + * @deprecated since 5.2.3 as per + * RFC 6266, Apendix B, + * to be removed in a future release. */ + @Deprecated @Nullable public Long getSize() { return this.size; @@ -132,7 +138,11 @@ public Long getSize() { /** * Return the value of the {@literal creation-date} parameter, or {@code null} if not defined. + * @deprecated since 5.2.3 as per + * RFC 6266, Apendix B, + * to be removed in a future release. */ + @Deprecated @Nullable public ZonedDateTime getCreationDate() { return this.creationDate; @@ -140,7 +150,11 @@ public ZonedDateTime getCreationDate() { /** * Return the value of the {@literal modification-date} parameter, or {@code null} if not defined. + * @deprecated since 5.2.3 as per + * RFC 6266, Apendix B, + * to be removed in a future release. */ + @Deprecated @Nullable public ZonedDateTime getModificationDate() { return this.modificationDate; @@ -148,7 +162,11 @@ public ZonedDateTime getModificationDate() { /** * Return the value of the {@literal read-date} parameter, or {@code null} if not defined. + * @deprecated since 5.2.3 as per + * RFC 6266, Apendix B, + * to be removed in a future release. */ + @Deprecated @Nullable public ZonedDateTime getReadDate() { return this.readDate; @@ -188,7 +206,7 @@ public int hashCode() { } /** - * Return the header value for this content disposition as defined in RFC 2183. + * Return the header value for this content disposition as defined in RFC 6266. * @see #parse(String) */ @Override @@ -480,22 +498,38 @@ public interface Builder { /** * Set the value of the {@literal size} parameter. + * @deprecated since 5.2.3 as per + * RFC 6266, Apendix B, + * to be removed in a future release. */ + @Deprecated Builder size(Long size); /** * Set the value of the {@literal creation-date} parameter. + * @deprecated since 5.2.3 as per + * RFC 6266, Apendix B, + * to be removed in a future release. */ + @Deprecated Builder creationDate(ZonedDateTime creationDate); /** * Set the value of the {@literal modification-date} parameter. + * @deprecated since 5.2.3 as per + * RFC 6266, Apendix B, + * to be removed in a future release. */ + @Deprecated Builder modificationDate(ZonedDateTime modificationDate); /** * Set the value of the {@literal read-date} parameter. + * @deprecated since 5.2.3 as per + * RFC 6266, Apendix B, + * to be removed in a future release. */ + @Deprecated Builder readDate(ZonedDateTime readDate); /** From 7456fb9c65f5b21c9aa825a01df1c02360d176f5 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 20 Dec 2019 09:15:44 +0000 Subject: [PATCH 0230/2315] Add failing test to be fixed See gh-23791 --- ...pingMessageConversionIntegrationTests.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java index 1deaaed19b59..3ad78feebf97 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java @@ -28,6 +28,7 @@ import io.reactivex.Flowable; import io.reactivex.Maybe; +import org.junit.jupiter.api.Disabled; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -522,6 +523,16 @@ public void personCreateWithFlowableXml(HttpServer httpServer) throws Exception assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2); } + @Disabled + @ParameterizedHttpServerTest // gh-23791 + public void personCreateViaDefaultMethodWithGenerics(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performPost("/23791", JSON, new Person("Robert"), null, String.class); + + assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); + assertThat(entity.getBody()).isEqualTo("Person"); + } + @Configuration @EnableWebFlux @@ -834,4 +845,17 @@ public List getPerson() { } + + private interface Controller23791 { + + @PostMapping("/23791") + default Mono test(@RequestBody Mono body) { + return body.map(value -> value.getClass().getSimpleName()); + } + } + + @RestController + private static class ConcreteController23791 implements Controller23791 { + } + } From a1b8b182828ffb24e7865520d28b86032d6ef643 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 20 Dec 2019 09:25:36 +0000 Subject: [PATCH 0231/2315] Polishing logPrefix Javadoc in ClientRequest|Response Closes gh-23791 --- .../web/reactive/function/client/ClientRequest.java | 9 ++++----- .../web/reactive/function/client/ClientResponse.java | 12 +++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java index a0c8d007a8bb..5d5fcdc578a0 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -96,11 +96,10 @@ default Optional attribute(String name) { /** * Return a log message prefix to use to correlate messages for this request. - * The prefix is based on the value of the attribute {@link #LOG_ID_ATTRIBUTE} - * along with some extra formatting so that the prefix can be conveniently - * prepended with no further formatting no separators required. + * The prefix is based on the value of the attribute {@link #LOG_ID_ATTRIBUTE + * LOG_ID_ATTRIBUTE} surrounded with "[" and "]". * @return the log message prefix or an empty String if the - * {@link #LOG_ID_ATTRIBUTE} is not set. + * {@link #LOG_ID_ATTRIBUTE LOG_ID_ATTRIBUTE} is not set. * @since 5.1 */ String logPrefix(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java index 6c5bf5b79579..992ce6db5a2b 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java @@ -205,14 +205,12 @@ public interface ClientResponse { Mono createException(); /** - * Return a log message prefix to use to correlate messages for this response. - * The prefix is based on the {@linkplain ClientRequest#logPrefix() client - * log prefix}, which itself is based on the value of the request attribute - * {@link ClientRequest#LOG_ID_ATTRIBUTE} along with some extra formatting - * so that the prefix can be conveniently prepended with no further - * formatting no separators required. + * Return a log message prefix to use to correlate messages for this exchange. + * The prefix is based on {@linkplain ClientRequest#logPrefix()}, which + * itself is based on the value of the {@link ClientRequest#LOG_ID_ATTRIBUTE + * LOG_ID_ATTRIBUTE} request attribute, further surrounded with "[" and "]". * @return the log message prefix or an empty String if the - * {@link ClientRequest#LOG_ID_ATTRIBUTE} was not set. + * {@link ClientRequest#LOG_ID_ATTRIBUTE LOG_ID_ATTRIBUTE} is not set. * @since 5.2.3 */ String logPrefix(); From 261956fd08fec9f35abbd2a1667e4acbbacdfc31 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 20 Dec 2019 11:03:08 +0000 Subject: [PATCH 0232/2315] Improve UriBuilder Javadoc on query params Add a note on encoding for query parameters specifically mentioning the "+" sign and a link to the reference docs. Also remove duplicate Javadoc in UriComponentsBuilder which is already inherited from UriBuilder. --- .../web/util/HierarchicalUriComponents.java | 2 +- .../springframework/web/util/UriBuilder.java | 70 ++++++---- .../web/util/UriComponentsBuilder.java | 121 +----------------- 3 files changed, 48 insertions(+), 145 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java index 1aaa56f5a12d..624bff55b10a 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java @@ -588,7 +588,7 @@ public int hashCode() { /** * Enumeration used to identify the allowed characters per URI component. *

    Contains methods to indicate whether a given character is valid in a specific URI component. - * @see RFC 3986 + * @see RFC 3986 */ enum Type { diff --git a/spring-web/src/main/java/org/springframework/web/util/UriBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriBuilder.java index bd654460822b..14618e75208b 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriBuilder.java @@ -98,31 +98,40 @@ public interface UriBuilder { UriBuilder pathSegment(String... pathSegments) throws IllegalArgumentException; /** - * Append the given query to the existing query of this builder. - * The given query may contain URI template variables. - *

    Note: The presence of reserved characters can prevent - * correct parsing of the URI string. For example if a query parameter - * contains {@code '='} or {@code '&'} characters, the query string cannot - * be parsed unambiguously. Such values should be substituted for URI - * variables to enable correct parsing: - *

    -	 * builder.query("filter={value}").uriString("hot&cold");
    -	 * 
    + * Parse the given query string into query parameters where parameters are + * separated with {@code '&'} and their values, if any, with {@code '='}. + * The query may contain URI template variables. + *

    Note: please, review the Javadoc of + * {@link #queryParam(String, Object...)} for further notes on the treatment + * and encoding of individual query parameters. * @param query the query string */ UriBuilder query(String query); /** - * Set the query of this builder overriding all existing query parameters. - * @param query the query string, or {@code null} to remove all query params + * Clear existing query parameters and then delegate to {@link #query(String)}. + *

    Note: please, review the Javadoc of + * {@link #queryParam(String, Object...)} for further notes on the treatment + * and encoding of individual query parameters. + * @param query the query string; a {@code null} value removes all query parameters. */ UriBuilder replaceQuery(@Nullable String query); /** - * Append the given query parameter to the existing query parameters. The - * given name or any of the values may contain URI template variables. If no + * Append the given query parameter. Both the parameter name and values may + * contain URI template variables to be expanded later from values. If no * values are given, the resulting URI will contain the query parameter name - * only (i.e. {@code ?foo} instead of {@code ?foo=bar}. + * only, e.g. {@code "?foo"} instead of {@code "?foo=bar"}. + *

    Note: encoding, if applied, will only encode characters + * that are illegal in a query parameter name or value such as {@code "="} + * or {@code "&"}. All others that are legal as per syntax rules in + * RFC 3986 are not + * encoded. This includes {@code "+"} which sometimes needs to be encoded + * to avoid its interpretation as an encoded space. Stricter encoding may + * be applied by using a URI template variable along with stricter encoding + * on variable values. For more details please read the + * "URI Encoding" + * section of the Spring Framework reference. * @param name the query parameter name * @param values the query parameter values * @see #queryParam(String, Collection) @@ -130,10 +139,10 @@ public interface UriBuilder { UriBuilder queryParam(String name, Object... values); /** - * Append the given query parameter to the existing query parameters. The - * given name or any of the values may contain URI template variables. If no - * values are given, the resulting URI will contain the query parameter name - * only (i.e. {@code ?foo} instead of {@code ?foo=bar}. + * Variant of {@link #queryParam(String, Object...)} with a Collection. + *

    Note: please, review the Javadoc of + * {@link #queryParam(String, Object...)} for further notes on the treatment + * and encoding of individual query parameters. * @param name the query parameter name * @param values the query parameter values * @since 5.2 @@ -142,14 +151,20 @@ public interface UriBuilder { UriBuilder queryParam(String name, @Nullable Collection values); /** - * Add the given query parameters. + * Add multiple query parameters and values. + *

    Note: please, review the Javadoc of + * {@link #queryParam(String, Object...)} for further notes on the treatment + * and encoding of individual query parameters. * @param params the params */ UriBuilder queryParams(MultiValueMap params); /** - * Set the query parameter values overriding all existing query values for - * the same parameter. If no values are given, the query parameter is removed. + * Set the query parameter values replacing existing values, or if no + * values are given, the query parameter is removed. + *

    Note: please, review the Javadoc of + * {@link #queryParam(String, Object...)} for further notes on the treatment + * and encoding of individual query parameters. * @param name the query parameter name * @param values the query parameter values * @see #replaceQueryParam(String, Collection) @@ -157,8 +172,10 @@ public interface UriBuilder { UriBuilder replaceQueryParam(String name, Object... values); /** - * Set the query parameter values overriding all existing query values for - * the same parameter. If no values are given, the query parameter is removed. + * Variant of {@link #replaceQueryParam(String, Object...)} with a Collection. + *

    Note: please, review the Javadoc of + * {@link #queryParam(String, Object...)} for further notes on the treatment + * and encoding of individual query parameters. * @param name the query parameter name * @param values the query parameter values * @since 5.2 @@ -167,7 +184,10 @@ public interface UriBuilder { UriBuilder replaceQueryParam(String name, @Nullable Collection values); /** - * Set the query parameter values overriding all existing query values. + * Set the query parameter values after removing all existing ones. + *

    Note: please, review the Javadoc of + * {@link #queryParam(String, Object...)} for further notes on the treatment + * and encoding of individual query parameters. * @param params the query parameter name */ UriBuilder replaceQueryParams(MultiValueMap params); diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java index 12ca9b7eaca3..506f92b1a9a0 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java @@ -521,12 +521,6 @@ public UriComponentsBuilder uriComponents(UriComponents uriComponents) { return this; } - /** - * Set the URI scheme. The given scheme may contain URI template variables, - * and may also be {@code null} to clear the scheme of this builder. - * @param scheme the URI scheme - * @return this UriComponentsBuilder - */ @Override public UriComponentsBuilder scheme(@Nullable String scheme) { this.scheme = scheme; @@ -547,12 +541,6 @@ public UriComponentsBuilder schemeSpecificPart(String ssp) { return this; } - /** - * Set the URI user info. The given user info may contain URI template variables, - * and may also be {@code null} to clear the user info of this builder. - * @param userInfo the URI user info - * @return this UriComponentsBuilder - */ @Override public UriComponentsBuilder userInfo(@Nullable String userInfo) { this.userInfo = userInfo; @@ -560,12 +548,6 @@ public UriComponentsBuilder userInfo(@Nullable String userInfo) { return this; } - /** - * Set the URI host. The given host may contain URI template variables, - * and may also be {@code null} to clear the host of this builder. - * @param host the URI host - * @return this UriComponentsBuilder - */ @Override public UriComponentsBuilder host(@Nullable String host) { this.host = host; @@ -573,11 +555,6 @@ public UriComponentsBuilder host(@Nullable String host) { return this; } - /** - * Set the URI port. Passing {@code -1} will clear the port of this builder. - * @param port the URI port - * @return this UriComponentsBuilder - */ @Override public UriComponentsBuilder port(int port) { Assert.isTrue(port >= -1, "Port must be >= -1"); @@ -586,13 +563,6 @@ public UriComponentsBuilder port(int port) { return this; } - /** - * Set the URI port. Use this method only when the port needs to be - * parameterized with a URI variable. Otherwise use {@link #port(int)}. - * Passing {@code null} will clear the port of this builder. - * @param port the URI port - * @return this UriComponentsBuilder - */ @Override public UriComponentsBuilder port(@Nullable String port) { this.port = port; @@ -600,12 +570,6 @@ public UriComponentsBuilder port(@Nullable String port) { return this; } - /** - * Append the given path to the existing path of this builder. - * The given path may contain URI template variables. - * @param path the URI path - * @return this UriComponentsBuilder - */ @Override public UriComponentsBuilder path(String path) { this.pathBuilder.addPath(path); @@ -613,13 +577,6 @@ public UriComponentsBuilder path(String path) { return this; } - /** - * Append path segments to the existing path. Each path segment may contain - * URI template variables and should not contain any slashes. - * Use {@code path("/")} subsequently to ensure a trailing slash. - * @param pathSegments the URI path segments - * @return this UriComponentsBuilder - */ @Override public UriComponentsBuilder pathSegment(String... pathSegments) throws IllegalArgumentException { this.pathBuilder.addPathSegments(pathSegments); @@ -627,11 +584,6 @@ public UriComponentsBuilder pathSegment(String... pathSegments) throws IllegalAr return this; } - /** - * Set the path of this builder overriding all existing path and path segment values. - * @param path the URI path (a {@code null} value results in an empty path) - * @return this UriComponentsBuilder - */ @Override public UriComponentsBuilder replacePath(@Nullable String path) { this.pathBuilder = new CompositePathComponentBuilder(); @@ -642,22 +594,6 @@ public UriComponentsBuilder replacePath(@Nullable String path) { return this; } - /** - * Append the given query to the existing query of this builder. - * The given query may contain URI template variables. - *

    Note: The presence of reserved characters can prevent - * correct parsing of the URI string. For example if a query parameter - * contains {@code '='} or {@code '&'} characters, the query string cannot - * be parsed unambiguously. Such values should be substituted for URI - * variables to enable correct parsing: - *

    -	 * UriComponentsBuilder.fromUriString("/hotels/42")
    -	 * 	.query("filter={value}")
    -	 * 	.buildAndExpand("hot&cold");
    -	 * 
    - * @param query the query string - * @return this UriComponentsBuilder - */ @Override public UriComponentsBuilder query(@Nullable String query) { if (query != null) { @@ -676,11 +612,6 @@ public UriComponentsBuilder query(@Nullable String query) { return this; } - /** - * Set the query of this builder overriding all existing query parameters. - * @param query the query string; a {@code null} value removes all query parameters. - * @return this UriComponentsBuilder - */ @Override public UriComponentsBuilder replaceQuery(@Nullable String query) { this.queryParams.clear(); @@ -691,16 +622,6 @@ public UriComponentsBuilder replaceQuery(@Nullable String query) { return this; } - /** - * Append the given query parameter to the existing query parameters. The - * given name or any of the values may contain URI template variables. If no - * values are given, the resulting URI will contain the query parameter name - * only (i.e. {@code ?foo} instead of {@code ?foo=bar}). - * @param name the query parameter name - * @param values the query parameter values - * @return this UriComponentsBuilder - * @see #queryParam(String, Collection) - */ @Override public UriComponentsBuilder queryParam(String name, Object... values) { Assert.notNull(name, "Name must not be null"); @@ -717,26 +638,13 @@ public UriComponentsBuilder queryParam(String name, Object... values) { return this; } - /** - * Append the given query parameter to the existing query parameters. The - * given name or any of the values may contain URI template variables. If no - * values are given, the resulting URI will contain the query parameter name - * only (i.e. {@code ?foo} instead of {@code ?foo=bar}). - * @param name the query parameter name - * @param values the query parameter values - * @return this UriComponentsBuilder - * @since 5.2 - * @see #queryParam(String, Object...) - */ @Override public UriComponentsBuilder queryParam(String name, @Nullable Collection values) { return queryParam(name, values != null ? values.toArray() : EMPTY_VALUES); } /** - * Add the given query parameters. - * @param params the params - * @return this UriComponentsBuilder + * {@inheritDoc} * @since 4.0 */ @Override @@ -747,14 +655,6 @@ public UriComponentsBuilder queryParams(@Nullable MultiValueMap return this; } - /** - * Set the query parameter values overriding all existing query values for - * the same parameter. If no values are given, the query parameter is removed. - * @param name the query parameter name - * @param values the query parameter values - * @return this UriComponentsBuilder - * @see #replaceQueryParam(String, Collection) - */ @Override public UriComponentsBuilder replaceQueryParam(String name, Object... values) { Assert.notNull(name, "Name must not be null"); @@ -766,24 +666,13 @@ public UriComponentsBuilder replaceQueryParam(String name, Object... values) { return this; } - /** - * Set the query parameter values overriding all existing query values for - * the same parameter. If no values are given, the query parameter is removed. - * @param name the query parameter name - * @param values the query parameter values - * @return this UriComponentsBuilder - * @see #replaceQueryParam(String, Object...) - * @since 5.2 - */ @Override public UriComponentsBuilder replaceQueryParam(String name, @Nullable Collection values) { return replaceQueryParam(name, values != null ? values.toArray() : EMPTY_VALUES); } /** - * Set the query parameter values overriding all existing query values. - * @param params the query parameter name - * @return this UriComponentsBuilder + * {@inheritDoc} * @since 4.2 */ @Override @@ -795,12 +684,6 @@ public UriComponentsBuilder replaceQueryParams(@Nullable MultiValueMap Date: Sun, 22 Dec 2019 16:00:45 +0100 Subject: [PATCH 0233/2315] Polishing --- ...stractEncoderMethodReturnValueHandler.java | 2 +- .../AbstractMethodMessageHandler.java | 8 ---- .../broker/DefaultSubscriptionRegistry.java | 3 +- .../simp/user/MultiServerUserRegistry.java | 8 ++++ .../HeaderMethodArgumentResolverTests.java | 1 + .../HeaderMethodArgumentResolverTests.java | 1 + .../reactive/StubArgumentResolver.java | 3 +- .../reactive/TestReturnValueHandler.java | 3 +- ...criptionMethodReturnValueHandlerTests.java | 3 ++ .../SimpleBrokerMessageHandlerTests.java | 3 +- .../StompBrokerRelayMessageHandlerTests.java | 35 ++++++---------- .../user/MultiServerUserRegistryTests.java | 27 +++++-------- .../UserDestinationMessageHandlerTests.java | 40 ++++++++----------- .../user/UserRegistryMessageHandlerTests.java | 3 +- 14 files changed, 61 insertions(+), 79 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractEncoderMethodReturnValueHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractEncoderMethodReturnValueHandler.java index ffe9a711504c..badd6afc70b5 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractEncoderMethodReturnValueHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractEncoderMethodReturnValueHandler.java @@ -154,7 +154,7 @@ private Flux encodeContent( } Encoder encoder = getEncoder(elementType, mimeType); - return Flux.from((Publisher) publisher).map(value -> + return Flux.from(publisher).map(value -> encodeValue(value, elementType, encoder, bufferFactory, mimeType, hints)); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java index b0de4fde096a..a92fc40d1297 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java @@ -566,14 +566,6 @@ private static class Match { this.handlerMethod = handlerMethod; } - public T getMapping() { - return this.mapping; - } - - public HandlerMethod getHandlerMethod() { - return this.handlerMethod; - } - @Override public String toString() { return this.mapping.toString(); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java index 153d940bcb9c..3ff2745f5f06 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -541,6 +541,7 @@ public boolean canRead(EvaluationContext context, @Nullable Object target, Strin } @Override + @SuppressWarnings("rawtypes") public TypedValue read(EvaluationContext context, @Nullable Object target, String name) { Object value; if (target instanceof Message) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java index d33e8548b0f4..cd91ab3b54dd 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java @@ -215,6 +215,7 @@ public UserRegistrySnapshot(String id, SimpUserRegistry registry) { } } + @SuppressWarnings("unused") public void setId(String id) { this.id = id; } @@ -223,6 +224,7 @@ public String getId() { return this.id; } + @SuppressWarnings("unused") public void setUserMap(Map users) { this.users = users; } @@ -297,6 +299,7 @@ public TransferSimpUser(SimpUser user) { } } + @SuppressWarnings("unused") public void setName(String name) { this.name = name; } @@ -328,6 +331,7 @@ public SimpSession getSession(String sessionId) { return null; } + @SuppressWarnings("unused") public void setSessions(Set sessions) { this.sessions.addAll(sessions); } @@ -407,6 +411,7 @@ public TransferSimpSession(SimpSession session) { } } + @SuppressWarnings("unused") public void setId(String id) { this.id = id; } @@ -425,6 +430,7 @@ public TransferSimpUser getUser() { return this.user; } + @SuppressWarnings("unused") public void setSubscriptions(Set subscriptions) { this.subscriptions.addAll(subscriptions); } @@ -487,6 +493,7 @@ public TransferSimpSubscription(SimpSubscription subscription) { this.destination = subscription.getDestination(); } + @SuppressWarnings("unused") public void setId(String id) { this.id = id; } @@ -505,6 +512,7 @@ public TransferSimpSession getSession() { return this.session; } + @SuppressWarnings("unused") public void setDestination(String destination) { this.destination = destination; } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeaderMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeaderMethodArgumentResolverTests.java index 45d89dc8a3a5..c5cff938c8fd 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeaderMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeaderMethodArgumentResolverTests.java @@ -51,6 +51,7 @@ public class HeaderMethodArgumentResolverTests { @BeforeEach + @SuppressWarnings("resource") public void setup() { GenericApplicationContext context = new GenericApplicationContext(); context.refresh(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolverTests.java index 503ef454ed82..8db7f97f17de 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolverTests.java @@ -53,6 +53,7 @@ public class HeaderMethodArgumentResolverTests { @BeforeEach + @SuppressWarnings("resource") public void setup() { GenericApplicationContext context = new GenericApplicationContext(); context.refresh(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/StubArgumentResolver.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/StubArgumentResolver.java index 8b2a879e8b2b..c5b5b9ecf0b5 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/StubArgumentResolver.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/StubArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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,7 +64,6 @@ public boolean supportsParameter(MethodParameter parameter) { return parameter.getParameterType().equals(this.valueType); } - @SuppressWarnings("unchecked") @Override public Mono resolveArgument(MethodParameter parameter, Message message) { this.resolvedParameters.add(parameter); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestReturnValueHandler.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestReturnValueHandler.java index 86b496da7f9f..22ea181370fd 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestReturnValueHandler.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestReturnValueHandler.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.messaging.handler.invocation.reactive; import org.reactivestreams.Publisher; @@ -44,7 +45,7 @@ public boolean supportsReturnType(MethodParameter returnType) { } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public Mono handleReturnValue(@Nullable Object value, MethodParameter returnType, Message message) { return value instanceof Publisher ? new ChannelSendOperator((Publisher) value, this::saveValue) : diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java index 26b24fbe8e89..92eefda1fbb4 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java @@ -237,6 +237,7 @@ private static class JacksonViewBean { private String withoutView; + @SuppressWarnings("unused") public String getWithView1() { return withView1; } @@ -245,6 +246,7 @@ public void setWithView1(String withView1) { this.withView1 = withView1; } + @SuppressWarnings("unused") public String getWithView2() { return withView2; } @@ -253,6 +255,7 @@ public void setWithView2(String withView2) { this.withView2 = withView2; } + @SuppressWarnings("unused") public String getWithoutView() { return withoutView; } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java index cae2ac4e3871..456bd9f1d21f 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java @@ -180,8 +180,8 @@ public void startWithHeartbeatValueWithoutTaskScheduler() { this.messageHandler::start); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("rawtypes") public void startAndStopWithHeartbeatValue() { ScheduledFuture future = mock(ScheduledFuture.class); given(this.taskScheduler.scheduleWithFixedDelay(any(Runnable.class), eq(15000L))).willReturn(future); @@ -199,7 +199,6 @@ public void startAndStopWithHeartbeatValue() { verifyNoMoreInteractions(future); } - @SuppressWarnings("unchecked") @Test public void startWithOneZeroHeartbeatValue() { this.messageHandler.setTaskScheduler(this.taskScheduler); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java index 3bf8372f841c..4b67d290fb52 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.messaging.simp.stomp; import java.util.ArrayList; @@ -46,11 +47,11 @@ import static org.mockito.Mockito.verify; /** - * Unit tests for StompBrokerRelayMessageHandler. + * Unit tests for {@link StompBrokerRelayMessageHandler}. * * @author Rossen Stoyanchev */ -public class StompBrokerRelayMessageHandlerTests { +class StompBrokerRelayMessageHandlerTests { private StompBrokerRelayMessageHandler brokerRelay; @@ -60,7 +61,7 @@ public class StompBrokerRelayMessageHandlerTests { @BeforeEach - public void setup() { + void setup() { this.outboundChannel = new StubMessageChannel(); @@ -80,7 +81,7 @@ protected void startInternal() { @Test - public void virtualHost() throws Exception { + void virtualHost() { this.brokerRelay.setVirtualHost("ABC"); @@ -101,7 +102,7 @@ public void virtualHost() throws Exception { } @Test - public void loginAndPasscode() throws Exception { + void loginAndPasscode() { this.brokerRelay.setSystemLogin("syslogin"); this.brokerRelay.setSystemPasscode("syspasscode"); @@ -125,7 +126,7 @@ public void loginAndPasscode() throws Exception { } @Test - public void destinationExcluded() throws Exception { + void destinationExcluded() { this.brokerRelay.start(); @@ -141,7 +142,7 @@ public void destinationExcluded() throws Exception { } @Test - public void messageFromBrokerIsEnriched() throws Exception { + void messageFromBrokerIsEnriched() { this.brokerRelay.start(); this.brokerRelay.handleMessage(connectMessage("sess1", "joe")); @@ -161,7 +162,7 @@ public void messageFromBrokerIsEnriched() throws Exception { // SPR-12820 @Test - public void connectWhenBrokerNotAvailable() throws Exception { + void connectWhenBrokerNotAvailable() { this.brokerRelay.start(); this.brokerRelay.stopInternal(); @@ -176,7 +177,7 @@ public void connectWhenBrokerNotAvailable() throws Exception { } @Test - public void sendAfterBrokerUnavailable() throws Exception { + void sendAfterBrokerUnavailable() { this.brokerRelay.start(); assertThat(this.brokerRelay.getConnectionCount()).isEqualTo(1); @@ -197,7 +198,8 @@ public void sendAfterBrokerUnavailable() throws Exception { } @Test - public void systemSubscription() throws Exception { + @SuppressWarnings("rawtypes") + void systemSubscription() { MessageHandler handler = mock(MessageHandler.class); this.brokerRelay.setSystemSubscriptions(Collections.singletonMap("/topic/foo", handler)); @@ -247,18 +249,7 @@ private Message message(StompCommand command, String sessionId, String u private static ListenableFutureTask getVoidFuture() { ListenableFutureTask futureTask = new ListenableFutureTask<>(new Callable() { @Override - public Void call() throws Exception { - return null; - } - }); - futureTask.run(); - return futureTask; - } - - private static ListenableFutureTask getBooleanFuture() { - ListenableFutureTask futureTask = new ListenableFutureTask<>(new Callable() { - @Override - public Boolean call() throws Exception { + public Void call() { return null; } }); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/MultiServerUserRegistryTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/MultiServerUserRegistryTests.java index 9bbc42b7a0f5..553c3af380c8 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/MultiServerUserRegistryTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/MultiServerUserRegistryTests.java @@ -22,7 +22,6 @@ import java.util.Iterator; import java.util.Set; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -39,25 +38,17 @@ * * @author Rossen Stoyanchev */ -public class MultiServerUserRegistryTests { +class MultiServerUserRegistryTests { - private SimpUserRegistry localRegistry; + private final SimpUserRegistry localRegistry = Mockito.mock(SimpUserRegistry.class); - private MultiServerUserRegistry registry; + private final MultiServerUserRegistry registry = new MultiServerUserRegistry(this.localRegistry); - private MessageConverter converter; - - - @BeforeEach - public void setup() throws Exception { - this.localRegistry = Mockito.mock(SimpUserRegistry.class); - this.registry = new MultiServerUserRegistry(this.localRegistry); - this.converter = new MappingJackson2MessageConverter(); - } + private final MessageConverter converter = new MappingJackson2MessageConverter(); @Test - public void getUserFromLocalRegistry() throws Exception { + void getUserFromLocalRegistry() { SimpUser user = Mockito.mock(SimpUser.class); Set users = Collections.singleton(user); given(this.localRegistry.getUsers()).willReturn(users); @@ -69,7 +60,7 @@ public void getUserFromLocalRegistry() throws Exception { } @Test - public void getUserFromRemoteRegistry() throws Exception { + void getUserFromRemoteRegistry() { // Prepare broadcast message from remote server TestSimpUser testUser = new TestSimpUser("joe"); TestSimpSession testSession = new TestSimpSession("remote-sess"); @@ -100,7 +91,7 @@ public void getUserFromRemoteRegistry() throws Exception { } @Test - public void findSubscriptionsFromRemoteRegistry() throws Exception { + void findSubscriptionsFromRemoteRegistry() { // Prepare broadcast message from remote server TestSimpUser user1 = new TestSimpUser("joe"); TestSimpUser user2 = new TestSimpUser("jane"); @@ -133,7 +124,7 @@ public void findSubscriptionsFromRemoteRegistry() throws Exception { } @Test // SPR-13800 - public void getSessionsWhenUserIsConnectedToMultipleServers() throws Exception { + void getSessionsWhenUserIsConnectedToMultipleServers() { // Add user to local registry TestSimpUser localUser = new TestSimpUser("joe"); TestSimpSession localSession = new TestSimpSession("sess123"); @@ -169,7 +160,7 @@ public void getSessionsWhenUserIsConnectedToMultipleServers() throws Exception { } @Test - public void purgeExpiredRegistries() throws Exception { + void purgeExpiredRegistries() { // Prepare broadcast message from remote server TestSimpUser testUser = new TestSimpUser("joe"); testUser.addSessions(new TestSimpSession("remote-sub")); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java index 7cae1cc285e8..78c8dd3a5f34 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java @@ -18,7 +18,6 @@ import java.nio.charset.StandardCharsets; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; @@ -41,31 +40,22 @@ import static org.springframework.messaging.simp.SimpMessageHeaderAccessor.ORIGINAL_DESTINATION; /** - * Unit tests for - * {@link org.springframework.messaging.simp.user.UserDestinationMessageHandler}. + * Unit tests for {@link UserDestinationMessageHandler}. */ -public class UserDestinationMessageHandlerTests { +class UserDestinationMessageHandlerTests { private static final String SESSION_ID = "123"; - private UserDestinationMessageHandler handler; + private final SimpUserRegistry registry = mock(SimpUserRegistry.class); - private SimpUserRegistry registry; + private final SubscribableChannel brokerChannel = mock(SubscribableChannel.class); - private SubscribableChannel brokerChannel; - - - @BeforeEach - public void setup() { - this.registry = mock(SimpUserRegistry.class); - this.brokerChannel = mock(SubscribableChannel.class); - UserDestinationResolver resolver = new DefaultUserDestinationResolver(this.registry); - this.handler = new UserDestinationMessageHandler(new StubMessageChannel(), this.brokerChannel, resolver); - } + private final UserDestinationMessageHandler handler = new UserDestinationMessageHandler(new StubMessageChannel(), this.brokerChannel, new DefaultUserDestinationResolver(this.registry)); @Test - public void handleSubscribe() { + @SuppressWarnings("rawtypes") + void handleSubscribe() { given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true); this.handler.handleMessage(createWith(SimpMessageType.SUBSCRIBE, "joe", SESSION_ID, "/user/queue/foo")); @@ -77,7 +67,8 @@ public void handleSubscribe() { } @Test - public void handleUnsubscribe() { + @SuppressWarnings("rawtypes") + void handleUnsubscribe() { given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true); this.handler.handleMessage(createWith(SimpMessageType.UNSUBSCRIBE, "joe", "123", "/user/queue/foo")); @@ -89,7 +80,8 @@ public void handleUnsubscribe() { } @Test - public void handleMessage() { + @SuppressWarnings("rawtypes") + void handleMessage() { TestSimpUser simpUser = new TestSimpUser("joe"); simpUser.addSessions(new TestSimpSession("123")); given(this.registry.getUser("joe")).willReturn(simpUser); @@ -105,7 +97,8 @@ public void handleMessage() { } @Test - public void handleMessageWithoutActiveSession() { + @SuppressWarnings("rawtypes") + void handleMessageWithoutActiveSession() { this.handler.setBroadcastDestination("/topic/unresolved"); given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true); this.handler.handleMessage(createWith(SimpMessageType.MESSAGE, "joe", "123", "/user/joe/queue/foo")); @@ -125,7 +118,8 @@ public void handleMessageWithoutActiveSession() { } @Test - public void handleMessageFromBrokerWithActiveSession() { + @SuppressWarnings("rawtypes") + void handleMessageFromBrokerWithActiveSession() { TestSimpUser simpUser = new TestSimpUser("joe"); simpUser.addSessions(new TestSimpSession("123")); given(this.registry.getUser("joe")).willReturn(simpUser); @@ -153,7 +147,7 @@ public void handleMessageFromBrokerWithActiveSession() { } @Test - public void handleMessageFromBrokerWithoutActiveSession() { + void handleMessageFromBrokerWithoutActiveSession() { this.handler.setBroadcastDestination("/topic/unresolved"); given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true); @@ -170,7 +164,7 @@ public void handleMessageFromBrokerWithoutActiveSession() { } @Test - public void ignoreMessage() { + void ignoreMessage() { // no destination this.handler.handleMessage(createWith(SimpMessageType.MESSAGE, "joe", "123", null)); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserRegistryMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserRegistryMessageHandlerTests.java index 98f2caea15bc..e01348ff64d4 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserRegistryMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserRegistryMessageHandlerTests.java @@ -89,8 +89,8 @@ public void brokerAvailableEvent() throws Exception { assertThat(runnable).isNotNull(); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings({ "unchecked", "rawtypes" }) public void brokerUnavailableEvent() throws Exception { ScheduledFuture future = mock(ScheduledFuture.class); @@ -106,6 +106,7 @@ public void brokerUnavailableEvent() throws Exception { } @Test + @SuppressWarnings("rawtypes") public void broadcastRegistry() throws Exception { given(this.brokerChannel.send(any())).willReturn(true); From 0b5ad093948fe5f2eb5727ad63248e164fdd3437 Mon Sep 17 00:00:00 2001 From: Ferdinand Jacobs Date: Sun, 22 Dec 2019 16:48:58 +0100 Subject: [PATCH 0234/2315] Fix example in RSocket docs Closes gh-24245 --- src/docs/asciidoc/rsocket.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docs/asciidoc/rsocket.adoc b/src/docs/asciidoc/rsocket.adoc index 29c24ed38b48..8c373c14764d 100644 --- a/src/docs/asciidoc/rsocket.adoc +++ b/src/docs/asciidoc/rsocket.adoc @@ -690,8 +690,8 @@ you need to share configuration between a client and a server in the same proces @Bean public RSocketStrategies rsocketStrategies() { return RSocketStrategies.builder() - .encoders(encoders -> encoders.add(new Jackson2CborEncoder)) - .decoders(decoders -> decoders.add(new Jackson2CborDecoder)) + .encoders(encoders -> encoders.add(new Jackson2CborEncoder())) + .decoders(decoders -> decoders.add(new Jackson2CborDecoder())) .routeMatcher(new PathPatternRouteMatcher()) .build(); } From b6b7162d616481df79ae9455c42af20f5805d7e9 Mon Sep 17 00:00:00 2001 From: Gary Hale Date: Mon, 23 Dec 2019 09:14:33 -0500 Subject: [PATCH 0235/2315] Upgrade to nohttp plugin 0.0.4.RELEASE See gh-24251 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ebf26209ac12..f1fb6222067a 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ plugins { id 'org.jetbrains.kotlin.jvm' version '1.3.61' apply false id 'org.jetbrains.dokka' version '0.9.18' apply false id 'org.asciidoctor.convert' version '1.5.8' - id 'io.spring.nohttp' version '0.0.3.RELEASE' + id 'io.spring.nohttp' version '0.0.4.RELEASE' id 'de.undercouch.download' version '4.0.0' id 'com.gradle.build-scan' version '2.4.2' id "com.jfrog.artifactory" version '4.11.0' apply false From 2d779857aa3459e557dbac1876f2f2487ea8c733 Mon Sep 17 00:00:00 2001 From: Gary Hale Date: Mon, 23 Dec 2019 09:24:43 -0500 Subject: [PATCH 0236/2315] Upgrade to Gradle build scan plugin 3.1.1 See gh-24252 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f1fb6222067a..4341457d3c14 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ plugins { id 'org.asciidoctor.convert' version '1.5.8' id 'io.spring.nohttp' version '0.0.4.RELEASE' id 'de.undercouch.download' version '4.0.0' - id 'com.gradle.build-scan' version '2.4.2' + id 'com.gradle.build-scan' version '3.1.1' id "com.jfrog.artifactory" version '4.11.0' apply false id "io.freefair.aspectj" version "4.1.1" apply false id "com.github.ben-manes.versions" version "0.24.0" From e7d489667c06b76a8fdb248259eba6f1b7f31062 Mon Sep 17 00:00:00 2001 From: Pascal Schumacher Date: Wed, 25 Dec 2019 16:20:37 +0100 Subject: [PATCH 0237/2315] Add missing space in AopConfigException message See gh-24266 --- .../org/springframework/aop/framework/ProxyFactoryBean.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java index c9c081c47497..364e5225af01 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java @@ -600,7 +600,7 @@ private Advisor namedBeanToAdvisor(Object next) { // We expected this to be an Advisor or Advice, // but it wasn't. This is a configuration error. throw new AopConfigException("Unknown advisor type " + next.getClass() + - "; Can only include Advisor or Advice type beans in interceptorNames chain except for last entry," + + "; Can only include Advisor or Advice type beans in interceptorNames chain except for last entry, " + "which may also be target or TargetSource", ex); } } From 956ffe68587c8d5f21135b5ce4650af0c2dea933 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 26 Dec 2019 17:30:15 +0000 Subject: [PATCH 0238/2315] ContentDisposition refactoring See gh-24220 --- .../http/ContentDisposition.java | 46 ++++++++++--------- .../http/ContentDispositionTests.java | 11 ++++- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java index 4d480116c39c..c50ffc715a3c 100644 --- a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java +++ b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java @@ -222,7 +222,7 @@ public String toString() { if (this.filename != null) { if (this.charset == null || StandardCharsets.US_ASCII.equals(this.charset)) { sb.append("; filename=\""); - sb.append(this.filename).append('\"'); + sb.append(escapeQuotationsInFilename(this.filename)).append('\"'); } else { sb.append("; filename*="); @@ -428,6 +428,23 @@ private static boolean isRFC5987AttrChar(byte c) { c == '.' || c == '^' || c == '_' || c == '`' || c == '|' || c == '~'; } + private static String escapeQuotationsInFilename(String filename) { + if (filename.indexOf('"') == -1 && filename.indexOf('\\') == -1) { + return filename; + } + boolean escaped = false; + StringBuilder sb = new StringBuilder(); + for (char c : filename.toCharArray()) { + sb.append((c == '"' && !escaped) ? "\\\"" : c); + escaped = (!escaped && c == '\\'); + } + // Remove backslash at the end.. + if (escaped) { + sb.deleteCharAt(sb.length() - 1); + } + return sb.toString(); + } + /** * Encode the given header field param as describe in RFC 5987. * @param input the header field param @@ -437,13 +454,10 @@ private static boolean isRFC5987AttrChar(byte c) { * @see RFC 5987 */ private static String encodeFilename(String input, Charset charset) { - Assert.notNull(input, "Input String should not be null"); - Assert.notNull(charset, "Charset should not be null"); - if (StandardCharsets.US_ASCII.equals(charset)) { - return input; - } - Assert.isTrue(UTF_8.equals(charset) || ISO_8859_1.equals(charset), - "Charset should be UTF-8 or ISO-8859-1"); + Assert.notNull(input, "`input` is required"); + Assert.notNull(charset, "`charset` is required"); + Assert.isTrue(!StandardCharsets.US_ASCII.equals(charset), "ASCII does not require encoding"); + Assert.isTrue(UTF_8.equals(charset) || ISO_8859_1.equals(charset), "Only UTF-8 and ISO-8859-1 supported."); byte[] source = input.getBytes(charset); int len = source.length; StringBuilder sb = new StringBuilder(len << 1); @@ -578,25 +592,13 @@ public Builder name(String name) { @Override public Builder filename(String filename) { Assert.hasText(filename, "No filename"); - this.filename = escapeQuotationMarks(filename); + this.filename = filename; return this; } - private static String escapeQuotationMarks(String filename) { - if (filename.indexOf('"') == -1) { - return filename; - } - boolean escaped = false; - StringBuilder sb = new StringBuilder(); - for (char c : filename.toCharArray()) { - sb.append((c == '"' && !escaped) ? "\\\"" : c); - escaped = (!escaped && c == '\\'); - } - return sb.toString(); - } - @Override public Builder filename(String filename, Charset charset) { + Assert.hasText(filename, "No filename"); this.filename = filename; this.charset = charset; return this; diff --git a/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java b/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java index c14753ab844f..c63492780787 100644 --- a/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java +++ b/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java @@ -222,10 +222,15 @@ public void formatWithEncodedFilenameUsingUsAscii() { @Test // gh-24220 public void formatWithFilenameWithQuotes() { - BiConsumer tester = (input, output) -> + BiConsumer tester = (input, output) -> { + assertThat(builder("form-data").filename(input).build().toString()) .isEqualTo("form-data; filename=\"" + output + "\""); + assertThat(builder("form-data").filename(input, StandardCharsets.US_ASCII).build().toString()) + .isEqualTo("form-data; filename=\"" + output + "\""); + }; + String filename = "\"foo.txt"; tester.accept(filename, "\\" + filename); @@ -243,6 +248,10 @@ public void formatWithFilenameWithQuotes() { tester.accept("\"\"foo.txt", "\\\"\\\"foo.txt"); tester.accept("\"\"\"foo.txt", "\\\"\\\"\\\"foo.txt"); + + tester.accept("foo.txt\\", "foo.txt"); + tester.accept("foo.txt\\\\", "foo.txt\\\\"); + tester.accept("foo.txt\\\\\\", "foo.txt\\\\"); } @Test From 8082b338e2e2f2e931d289882f710c60a028ccc8 Mon Sep 17 00:00:00 2001 From: Honnix Date: Tue, 31 Dec 2019 18:58:48 +0100 Subject: [PATCH 0239/2315] Document that SpEL supports symbolic logical operators Make it clear that symbolic logical operators are supported. Closes gh-24276 --- src/docs/asciidoc/core/core-expressions.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/docs/asciidoc/core/core-expressions.adoc b/src/docs/asciidoc/core/core-expressions.adoc index 54f44b4e4bb2..0c2e823fc8b2 100644 --- a/src/docs/asciidoc/core/core-expressions.adoc +++ b/src/docs/asciidoc/core/core-expressions.adoc @@ -1133,9 +1133,9 @@ All of the textual operators are case-insensitive. SpEL supports the following logical operators: -* `and` -* `or` -* `not` +* `and` (`&&`) +* `or` (`||`) +* `not` (`!`) The following example shows how to use the logical operators From 75fd391fc716456bbd2448f60e691b8f588c70de Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 2 Jan 2020 11:29:04 +0100 Subject: [PATCH 0240/2315] Remove quality parameter from selected media type Prior to this commit, WebFlux application would keep the quality parameter from the "Accept" request header when selecting a media type for the response. It would then echo it back to the client. While strictly not wrong, this is unnecessary and can confuse HTTP clients. This commit aligns WebFlux's behavior with Spring MVC. Fixes gh-24239 --- .../result/HandlerResultHandlerSupport.java | 1 + .../result/HandlerResultHandlerTests.java | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/HandlerResultHandlerSupport.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/HandlerResultHandlerSupport.java index e974f42703e5..bf2fbe214bc5 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/HandlerResultHandlerSupport.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/HandlerResultHandlerSupport.java @@ -156,6 +156,7 @@ else if (mediaType.isPresentIn(ALL_APPLICATION_MEDIA_TYPES)) { } if (selected != null) { + selected = selected.removeQualityValue(); if (logger.isDebugEnabled()) { logger.debug("Using '" + selected + "' given " + acceptableTypes + " and supported " + producibleTypes); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java index 98121a607194..28c3522088fb 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -51,7 +51,7 @@ public class HandlerResultHandlerTests { @Test - public void usesContentTypeResolver() throws Exception { + void usesContentTypeResolver() { TestResultHandler resultHandler = new TestResultHandler(new FixedContentTypeResolver(IMAGE_GIF)); List mediaTypes = Arrays.asList(IMAGE_JPEG, IMAGE_GIF, IMAGE_PNG); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path")); @@ -61,7 +61,7 @@ public void usesContentTypeResolver() throws Exception { } @Test - public void producibleMediaTypesRequestAttribute() throws Exception { + void producibleMediaTypesRequestAttribute() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path")); exchange.getAttributes().put(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, Collections.singleton(IMAGE_GIF)); @@ -72,7 +72,7 @@ public void producibleMediaTypesRequestAttribute() throws Exception { } @Test // SPR-9160 - public void sortsByQuality() throws Exception { + void sortsByQuality() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path") .header("Accept", "text/plain; q=0.5, application/json")); @@ -83,7 +83,7 @@ public void sortsByQuality() throws Exception { } @Test - public void charsetFromAcceptHeader() throws Exception { + void charsetFromAcceptHeader() { MediaType text8859 = MediaType.parseMediaType("text/plain;charset=ISO-8859-1"); MediaType textUtf8 = MediaType.parseMediaType("text/plain;charset=UTF-8"); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path").accept(text8859)); @@ -93,7 +93,7 @@ public void charsetFromAcceptHeader() throws Exception { } @Test // SPR-12894 - public void noConcreteMediaType() throws Exception { + void noConcreteMediaType() { List producible = Collections.singletonList(ALL); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path")); MediaType actual = this.resultHandler.selectMediaType(exchange, () -> producible); @@ -101,6 +101,17 @@ public void noConcreteMediaType() throws Exception { assertThat(actual).isEqualTo(APPLICATION_OCTET_STREAM); } + @Test + void removeQualityParameter() { + MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path") + .header("Accept", "text/plain; q=0.5")); + + List mediaTypes = Arrays.asList(APPLICATION_JSON, TEXT_PLAIN); + MediaType actual = this.resultHandler.selectMediaType(exchange, () -> mediaTypes); + + assertThat(actual).isEqualTo(TEXT_PLAIN); + } + @SuppressWarnings("WeakerAccess") private static class TestResultHandler extends HandlerResultHandlerSupport { From 5718bf424b353d3bcdf841b528c34a7f1ae829f7 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 28 Dec 2019 11:44:40 +0100 Subject: [PATCH 0241/2315] Use Gradle test fixture support for spring-core See gh-23550 --- build.gradle | 1 + .../build/testsources/TestSourcesPlugin.java | 27 ++++-- integration-tests/integration-tests.gradle | 1 + ...NamespaceHandlerScopeIntegrationTests.java | 2 +- ...ansactionalAnnotationIntegrationTests.java | 4 +- spring-aop/spring-aop.gradle | 1 + .../annotation/AspectProxyFactoryTests.java | 2 +- .../config/AopNamespaceHandlerEventTests.java | 2 +- ...AopNamespaceHandlerPointcutErrorTests.java | 2 +- .../aop/config/TopLevelAopTagTests.java | 2 +- .../aop/framework/PrototypeTargetTests.java | 2 +- .../aop/framework/ProxyFactoryTests.java | 2 +- .../ConcurrencyThrottleInterceptorTests.java | 2 +- .../ExposeInvocationInterceptorTests.java | 2 +- .../aop/scope/ScopedProxyAutowireTests.java | 2 +- .../AbstractRegexpMethodPointcutTests.java | 2 +- .../aop/support/AopUtilsTests.java | 2 +- ...elegatingIntroductionInterceptorTests.java | 4 +- .../aop/support/MethodMatchersTests.java | 2 +- .../support/NameMatchMethodPointcutTests.java | 2 +- ...MethodPointcutAdvisorIntegrationTests.java | 4 +- .../CommonsPool2TargetSourceProxyTests.java | 2 +- .../target/HotSwappableTargetSourceTests.java | 4 +- .../aop/target/LazyInitTargetSourceTests.java | 2 +- .../PrototypeBasedTargetSourceTests.java | 2 +- .../target/PrototypeTargetSourceTests.java | 2 +- .../target/ThreadLocalTargetSourceTests.java | 2 +- .../dynamic/RefreshableTargetSourceTests.java | 4 +- .../TimestampIntroductionInterceptor.java | 2 +- spring-aspects/spring-aspects.gradle | 1 + .../AnnotationAsyncExecutionAspectTests.java | 4 +- spring-beans/spring-beans.gradle | 1 + .../beans/AbstractPropertyAccessorTests.java | 6 +- .../beans/factory/BeanFactoryUtilsTests.java | 2 +- .../factory/ConcurrentBeanFactoryTests.java | 6 +- .../DefaultListableBeanFactoryTests.java | 8 +- .../beans/factory/FactoryBeanTests.java | 4 +- ...wiredAnnotationBeanPostProcessorTests.java | 2 +- .../CustomAutowireConfigurerTests.java | 2 +- ...njectAnnotationBeanPostProcessorTests.java | 2 +- .../FieldRetrievingFactoryBeanTests.java | 2 +- ...ObjectFactoryCreatingFactoryBeanTests.java | 4 +- .../config/PropertiesFactoryBeanTests.java | 2 +- .../config/PropertyPathFactoryBeanTests.java | 2 +- .../PropertyResourceConfigurerTests.java | 2 +- .../factory/config/SimpleScopeTests.java | 2 +- .../parsing/CustomProblemReporterTests.java | 2 +- .../support/BeanFactoryGenericsTests.java | 4 +- .../context/index/sample/SampleNone.java | 3 +- .../context/index/sample/Scope.java | 33 +++++++ .../spring-context-support.gradle | 1 + .../cache/ehcache/EhCacheCacheTests.java | 4 +- .../scheduling/quartz/QuartzSupportTests.java | 4 +- .../SpringValidatorAdapterTests.java | 2 +- spring-context/spring-context.gradle | 1 + .../AspectJAutoProxyCreatorTests.java | 6 +- .../aop/framework/AbstractAopProxyTests.java | 10 +- .../aop/framework/ProxyFactoryBeanTests.java | 4 +- .../BeanNameAutoProxyCreatorTests.java | 2 +- .../aop/scope/ScopedProxyTests.java | 2 +- .../target/CommonsPool2TargetSourceTests.java | 2 +- .../factory/xml/XmlBeanFactoryTests.java | 2 +- .../AnnotationProcessorPerformanceTests.java | 6 +- ...ommonAnnotationBeanPostProcessorTests.java | 2 +- ...mponentScanAnnotationIntegrationTests.java | 2 +- .../ComponentScanParserScopedProxyTests.java | 2 +- .../ApplicationContextExpressionTests.java | 8 +- .../EnvironmentAccessorIntegrationTests.java | 2 +- .../DefaultLifecycleProcessorTests.java | 4 +- ...onmentSecurityManagerIntegrationTests.java | 5 +- ...ertySourcesPlaceholderConfigurerTests.java | 2 +- .../mock/env/MockEnvironment.java | 1 + .../annotation/EnableSchedulingTests.java | 4 +- .../ScheduledExecutorFactoryBeanTests.java | 4 +- .../ScriptFactoryPostProcessorTests.java | 4 +- .../SpringValidatorAdapterTests.java | 2 +- .../context/support/BeanDefinitionDslTests.kt | 2 +- spring-core/spring-core.gradle | 6 ++ .../type/AspectJTypeFilterTestsTypes.java | 2 +- .../AnnotatedElementUtilsTests.java | 4 +- .../core/annotation/AnnotationUtilsTests.java | 4 +- .../annotation/MergedAnnotationsTests.java | 6 +- .../core/codec/ByteArrayDecoderTests.java | 1 + .../core/codec/ByteArrayEncoderTests.java | 1 + .../core/codec/ByteBufferDecoderTests.java | 1 + .../core/codec/ByteBufferEncoderTests.java | 1 + .../core/codec/CharSequenceEncoderTests.java | 1 + .../core/codec/DataBufferDecoderTests.java | 1 + .../core/codec/DataBufferEncoderTests.java | 1 + .../core/codec/ResourceDecoderTests.java | 1 + .../core/codec/ResourceEncoderTests.java | 1 + .../codec/ResourceRegionEncoderTests.java | 4 +- .../core/codec/StringDecoderTests.java | 1 + .../DefaultConversionServiceTests.java | 4 +- .../GenericConversionServiceTests.java | 4 +- .../core/env/MutablePropertySourcesTests.java | 2 +- .../PropertySourcesPropertyResolverTests.java | 2 +- .../core/env/StandardEnvironmentTests.java | 73 ++------------- .../core/io/buffer/DataBufferTests.java | 2 + .../core/io/buffer/DataBufferUtilsTests.java | 3 +- .../LeakAwareDataBufferFactoryTests.java | 2 + .../support/DataBufferTestUtilsTests.java | 3 +- .../test/fixtures/TestGroupParsingTests.java} | 6 +- .../test/fixtures/TestGroupTests.java} | 39 +++++--- .../core/type/AnnotationMetadataTests.java | 2 +- .../core/type/AnnotationTypeFilterTests.java | 2 +- .../core/type/AspectJTypeFilterTests.java | 6 +- .../type/CachingMetadataReaderLeakTests.java | 4 +- .../org/springframework/core/type/Scope.java | 11 +-- .../org/springframework/tests/Assume.java | 77 ---------------- .../util/AutoPopulatingListTests.java | 1 + .../util/ReflectionUtilsTests.java | 4 +- .../util/SerializationUtilsTests.java | 14 +-- .../util/xml/AbstractStaxHandlerTests.java | 2 +- .../util/xml/DomContentHandlerTests.java | 2 +- .../xml/ListBasedXMLEventReaderTests.java | 2 +- .../util/xml/StaxResultTests.java | 2 +- .../util/xml/StaxSourceTests.java | 2 +- .../util/xml/XMLEventStreamReaderTests.java | 2 +- .../util/xml/XMLEventStreamWriterTests.java | 2 +- .../core/test/fixtures/Assume.java | 46 ++++++++++ .../test/fixtures}/EnabledForTestGroups.java | 2 +- .../core/test/fixtures}/TestGroup.java | 3 +- .../test/fixtures}/TestGroupsCondition.java | 2 +- .../core/test/fixtures}/TimeStamped.java | 2 +- .../fixtures}/codec/AbstractDecoderTests.java | 6 +- .../fixtures}/codec/AbstractEncoderTests.java | 6 +- .../fixtures/env/EnvironmentTestUtils.java | 92 +++++++++++++++++++ .../fixtures}/env/MockPropertySource.java | 2 +- .../test/fixtures/io/ResourceTestUtils.java} | 6 +- .../fixtures/io}/SerializationTestUtils.java | 2 +- .../AbstractDataBufferAllocatingTests.java | 10 +- .../io/buffer/AbstractLeakCheckingTests.java | 5 +- .../io/buffer}/DataBufferTestUtils.java | 2 +- .../io/buffer/LeakAwareDataBuffer.java | 5 +- .../io/buffer/LeakAwareDataBufferFactory.java | 6 +- .../test/fixtures}/stereotype/Component.java | 6 +- .../test/fixtures}/stereotype/Indexed.java | 2 +- .../core/test/fixtures/xml}/XmlContent.java | 4 +- .../test/fixtures/xml}/XmlContentAssert.java | 12 +-- spring-expression/spring-expression.gradle | 1 + .../expression/spel/MapAccessTests.java | 4 +- .../expression/spel/PerformanceTests.java | 4 +- spring-jdbc/spring-jdbc.gradle | 1 + .../config/JdbcNamespaceIntegrationTests.java | 4 +- .../DataSourceTransactionManagerTests.java | 4 +- spring-messaging/spring-messaging.gradle | 3 +- .../messaging/MessageHeadersTests.java | 2 +- .../MarshallingMessageConverterTests.java | 2 +- .../TestEncoderMethodReturnValueHandler.java | 2 +- .../LeakAwareNettyDataBufferFactory.java | 2 +- .../rsocket/MetadataEncoderTests.java | 2 +- .../messaging/rsocket/PayloadUtilsTests.java | 2 +- .../support/MessageHeaderAccessorTests.java | 2 +- spring-orm/spring-orm.gradle | 1 + ...rEntityManagerFactoryIntegrationTests.java | 2 +- ...ontainerEntityManagerFactoryBeanTests.java | 2 +- .../support/PersistenceInjectionTests.java | 2 +- spring-oxm/spring-oxm.gradle | 1 + .../oxm/AbstractMarshallerTests.java | 2 +- .../oxm/jaxb/Jaxb2MarshallerTests.java | 2 +- .../oxm/jibx/JibxMarshallerTests.java | 2 +- .../oxm/xstream/XStreamMarshallerTests.java | 2 +- spring-test/spring-test.gradle | 1 + .../SpringJUnit4ConcurrencyTests.java | 2 +- .../server/HttpHandlerConnectorTests.java | 2 +- .../DelegatingWebConnectionTests.java | 4 +- .../MockMvcWebClientBuilderTests.java | 2 +- .../MockMvcHtmlUnitDriverBuilderTests.java | 2 +- spring-tx/spring-tx.gradle | 1 + ...tationTransactionAttributeSourceTests.java | 2 +- .../config/AnnotationDrivenTests.java | 2 +- ...ransactionAttributeSourceAdvisorTests.java | 2 +- .../TransactionInterceptorTests.java | 2 +- ...aTransactionManagerSerializationTests.java | 2 +- spring-web/spring-web.gradle | 1 + .../codec/CancelWithoutDemandCodecTests.java | 2 +- .../codec/FormHttpMessageReaderTests.java | 2 +- .../codec/FormHttpMessageWriterTests.java | 4 +- ...ServerSentEventHttpMessageReaderTests.java | 2 +- ...ServerSentEventHttpMessageWriterTests.java | 4 +- .../codec/cbor/Jackson2CborDecoderTests.java | 2 +- .../codec/cbor/Jackson2CborEncoderTests.java | 4 +- .../codec/json/Jackson2JsonDecoderTests.java | 2 +- .../codec/json/Jackson2JsonEncoderTests.java | 2 +- .../codec/json/Jackson2SmileDecoderTests.java | 2 +- .../codec/json/Jackson2SmileEncoderTests.java | 4 +- .../codec/json/Jackson2TokenizerTests.java | 2 +- .../MultipartHttpMessageWriterTests.java | 2 +- ...SynchronossPartHttpMessageReaderTests.java | 4 +- .../codec/protobuf/ProtobufDecoderTests.java | 2 +- .../codec/protobuf/ProtobufEncoderTests.java | 2 +- .../http/codec/xml/Jaxb2XmlDecoderTests.java | 2 +- .../http/codec/xml/Jaxb2XmlEncoderTests.java | 4 +- .../http/codec/xml/XmlEventDecoderTests.java | 2 +- .../AtomFeedHttpMessageConverterTests.java | 2 +- .../RssChannelHttpMessageConverterTests.java | 2 +- ...2RootElementHttpMessageConverterTests.java | 2 +- .../xml/SourceHttpMessageConverterTests.java | 2 +- .../reactive/ChannelSendOperatorTests.java | 2 +- .../HttpHeadResponseDecoratorTests.java | 2 +- .../web/bind/ServletRequestUtilsTests.java | 4 +- .../context/request/SessionScopeTests.java | 2 +- spring-webflux/spring-webflux.gradle | 3 +- .../config/ResourceHandlerRegistryTests.java | 2 +- .../reactive/function/BodyInsertersTests.java | 2 +- .../client/ExchangeFilterFunctionsTests.java | 2 +- .../WebClientDataBufferAllocatingTests.java | 2 +- .../resource/ResourceWebHandlerTests.java | 2 +- .../MessageWriterResultHandlerTests.java | 2 +- ...equestPartMethodArgumentResolverTests.java | 2 +- .../ResponseEntityResultHandlerTests.java | 2 +- .../view/HttpMessageWriterViewTests.java | 2 +- .../ViewResolutionResultHandlerTests.java | 2 +- .../result/view/ZeroDemandResponse.java | 2 +- spring-webmvc/spring-webmvc.gradle | 1 + .../web/servlet/DispatcherServletTests.java | 1 - .../web/servlet}/DummyEnvironment.java | 9 +- ...nnotationControllerHandlerMethodTests.java | 2 +- .../servlet/view/feed/AtomFeedViewTests.java | 2 +- .../servlet/view/feed/RssFeedViewTests.java | 2 +- spring-websocket/spring-websocket.gradle | 1 + .../AbstractSockJsIntegrationTests.java | 4 +- src/checkstyle/checkstyle-suppressions.xml | 8 +- 224 files changed, 552 insertions(+), 453 deletions(-) create mode 100644 spring-context-indexer/src/test/java/org/springframework/context/index/sample/Scope.java rename spring-core/src/test/java/org/springframework/{tests/TestGroupTests.java => core/test/fixtures/TestGroupParsingTests.java} (95%) rename spring-core/src/test/java/org/springframework/{tests/AssumeTests.java => core/test/fixtures/TestGroupTests.java} (76%) delete mode 100644 spring-core/src/test/java/org/springframework/tests/Assume.java create mode 100644 spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/Assume.java rename spring-core/src/{test/java/org/springframework/tests => testFixtures/java/org/springframework/core/test/fixtures}/EnabledForTestGroups.java (96%) rename spring-core/src/{test/java/org/springframework/tests => testFixtures/java/org/springframework/core/test/fixtures}/TestGroup.java (98%) rename spring-core/src/{test/java/org/springframework/tests => testFixtures/java/org/springframework/core/test/fixtures}/TestGroupsCondition.java (97%) rename spring-core/src/{test/java/org/springframework/tests => testFixtures/java/org/springframework/core/test/fixtures}/TimeStamped.java (95%) rename spring-core/src/{test/java/org/springframework/core => testFixtures/java/org/springframework/core/test/fixtures}/codec/AbstractDecoderTests.java (98%) rename spring-core/src/{test/java/org/springframework/core => testFixtures/java/org/springframework/core/test/fixtures}/codec/AbstractEncoderTests.java (98%) create mode 100644 spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/EnvironmentTestUtils.java rename spring-core/src/{test/java/org/springframework/mock => testFixtures/java/org/springframework/core/test/fixtures}/env/MockPropertySource.java (98%) rename spring-core/src/{test/java/org/springframework/tests/TestResourceUtils.java => testFixtures/java/org/springframework/core/test/fixtures/io/ResourceTestUtils.java} (89%) rename spring-core/src/{test/java/org/springframework/util => testFixtures/java/org/springframework/core/test/fixtures/io}/SerializationTestUtils.java (97%) rename spring-core/src/{test/java/org/springframework/core => testFixtures/java/org/springframework/core/test/fixtures}/io/buffer/AbstractDataBufferAllocatingTests.java (92%) rename spring-core/src/{test/java/org/springframework/core => testFixtures/java/org/springframework/core/test/fixtures}/io/buffer/AbstractLeakCheckingTests.java (92%) rename spring-core/src/{test/java/org/springframework/core/io/buffer/support => testFixtures/java/org/springframework/core/test/fixtures/io/buffer}/DataBufferTestUtils.java (97%) rename spring-core/src/{test/java/org/springframework/core => testFixtures/java/org/springframework/core/test/fixtures}/io/buffer/LeakAwareDataBuffer.java (92%) rename spring-core/src/{test/java/org/springframework/core => testFixtures/java/org/springframework/core/test/fixtures}/io/buffer/LeakAwareDataBufferFactory.java (93%) rename spring-core/src/{test/java/org/springframework => testFixtures/java/org/springframework/core/test/fixtures}/stereotype/Component.java (84%) rename spring-core/src/{test/java/org/springframework => testFixtures/java/org/springframework/core/test/fixtures}/stereotype/Indexed.java (94%) rename spring-core/src/{test/java/org/springframework/tests => testFixtures/java/org/springframework/core/test/fixtures/xml}/XmlContent.java (94%) rename spring-core/src/{test/java/org/springframework/tests => testFixtures/java/org/springframework/core/test/fixtures/xml}/XmlContentAssert.java (77%) rename {spring-core/src/test/java/org/springframework/core/env => spring-webmvc/src/test/java/org/springframework/web/servlet}/DummyEnvironment.java (88%) diff --git a/build.gradle b/build.gradle index 4341457d3c14..c3f625e7962e 100644 --- a/build.gradle +++ b/build.gradle @@ -308,6 +308,7 @@ configure([rootProject] + javaProjects) { project -> group = "org.springframework" apply plugin: "java" + apply plugin: "java-test-fixtures" apply plugin: "checkstyle" apply plugin: 'org.springframework.build.compile' apply from: "${rootDir}/gradle/ide.gradle" diff --git a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java index 68b97661902c..b93ca0f77df1 100644 --- a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java +++ b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java @@ -55,9 +55,16 @@ public class TestSourcesPlugin implements Plugin { OptionalDependenciesPlugin.OPTIONAL_CONFIGURATION_NAME, JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME); + /** + * Projects which will not be automatically added as a test dependency. + *

    This is used to assist with the migration to Gradle test fixtures. + */ + private static final List excludedProjects = Arrays.asList("spring-core"); + + @Override public void apply(Project project) { - project.getPlugins().withType(JavaPlugin.class, (plugin) -> addTestSourcesToProject(project)); + project.getPlugins().withType(JavaPlugin.class, plugin -> addTestSourcesToProject(project)); } private void addTestSourcesToProject(Project project) { @@ -83,13 +90,17 @@ private void collectProjectDependencies(Set projectDependenci } } - private void addTestSourcesFromDependency(final Project currentProject, ProjectDependency dependency) { + @SuppressWarnings("deprecation") + private void addTestSourcesFromDependency(Project currentProject, ProjectDependency dependency) { Project dependencyProject = dependency.getDependencyProject(); - dependencyProject.getPlugins().withType(JavaPlugin.class, plugin -> { - final JavaPluginConvention javaPlugin = dependencyProject.getConvention() - .getPlugin(JavaPluginConvention.class); - SourceSetOutput test = javaPlugin.getSourceSets().findByName(SourceSet.TEST_SOURCE_SET_NAME).getOutput(); - currentProject.getDependencies().add(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME, test); - }); + if (!excludedProjects.contains(dependencyProject.getName())) { + dependencyProject.getPlugins().withType(JavaPlugin.class, plugin -> { + JavaPluginConvention javaPlugin = dependencyProject.getConvention().getPlugin(JavaPluginConvention.class); + SourceSetOutput test = javaPlugin.getSourceSets().findByName(SourceSet.TEST_SOURCE_SET_NAME).getOutput(); + // System.err.println(String.format("Adding test source dependencies from %s to %s", currentProject.getName(), dependencyProject.getName())); + currentProject.getDependencies().add(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME, test); + }); + } } + } diff --git a/integration-tests/integration-tests.gradle b/integration-tests/integration-tests.gradle index ab3bba7354b6..afaa939a61b5 100644 --- a/integration-tests/integration-tests.gradle +++ b/integration-tests/integration-tests.gradle @@ -7,6 +7,7 @@ dependencies { testCompile(project(":spring-beans")) testCompile(project(":spring-context")) testCompile(project(":spring-core")) + testCompile(testFixtures(project(":spring-core"))) testCompile(project(":spring-expression")) testCompile(project(":spring-jdbc")) testCompile(project(":spring-orm")) diff --git a/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java b/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java index 29f6e050812e..173da6e54d7a 100644 --- a/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java @@ -21,12 +21,12 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpSession; import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; diff --git a/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java b/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java index 95d897138f45..77f1145de82f 100644 --- a/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java @@ -28,10 +28,10 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.dao.support.PersistenceExceptionTranslator; import org.springframework.stereotype.Repository; -import org.springframework.tests.EnabledForTestGroups; import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.Mockito.mock; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * Integration tests cornering bug SPR-8651, which revealed that @Scheduled methods may diff --git a/spring-aop/spring-aop.gradle b/spring-aop/spring-aop.gradle index e4c20542e2cd..3d000edc2d4d 100644 --- a/spring-aop/spring-aop.gradle +++ b/spring-aop/spring-aop.gradle @@ -6,4 +6,5 @@ dependencies { optional("org.aspectj:aspectjweaver") optional("org.apache.commons:commons-pool2") optional("com.jamonapi:jamon") + testCompile(testFixtures(project(":spring-core"))) } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java index 0c4d6ff1d8d1..e445598dd282 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; import test.aop.PerThisAspect; -import org.springframework.util.SerializationTestUtils; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java index c31d5a396d04..d713be7450f9 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java @@ -33,7 +33,7 @@ import org.springframework.tests.beans.CollectingReaderEventListener; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Rob Harrop diff --git a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java index 7b07a2f793ee..67cc99823d7c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Mark Fisher diff --git a/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java b/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java index 95732b92a1d7..c8e21cb8c40d 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * Tests that the <aop:config/> element can be used as a top level element. diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java index 6174c02a0c19..dd99d98d6470 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java @@ -25,7 +25,7 @@ import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Juergen Hoeller diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java index 7372468f9c3b..06545b23b00e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java @@ -36,7 +36,7 @@ import org.springframework.aop.support.DelegatingIntroductionInterceptor; import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.Order; -import org.springframework.tests.TimeStamped; +import org.springframework.core.test.fixtures.TimeStamped; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.sample.beans.IOther; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java index 9477df4ca017..316d212c12d9 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java @@ -22,10 +22,10 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.sample.beans.DerivedTestBean; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java index 76b682bf093e..aaba0ed62314 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java @@ -25,7 +25,7 @@ import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * Non-XML tests are in AbstractAopProxyTests diff --git a/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java b/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java index 42f32fa1eb02..7c09bbb7c5ab 100644 --- a/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Mark Fisher diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java index f13ebf47fea3..1b32923d4da5 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java index 63778647debc..09d88705f80e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java @@ -25,10 +25,10 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.target.EmptyTargetSource; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java index a165be41a406..55da6fee78b1 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java @@ -24,7 +24,8 @@ import org.springframework.aop.IntroductionAdvisor; import org.springframework.aop.IntroductionInterceptor; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.tests.TimeStamped; +import org.springframework.core.test.fixtures.TimeStamped; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import org.springframework.tests.sample.beans.INestedTestBean; import org.springframework.tests.sample.beans.ITestBean; @@ -32,7 +33,6 @@ import org.springframework.tests.sample.beans.Person; import org.springframework.tests.sample.beans.SerializablePerson; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java index f860ef72d4eb..b69e8450b491 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java @@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.MethodMatcher; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.tests.sample.beans.IOther; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java index 91517e6831c1..87241091caf7 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java @@ -21,11 +21,11 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import org.springframework.tests.sample.beans.Person; import org.springframework.tests.sample.beans.SerializablePerson; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java index da9699a305b3..34fd0e47775e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java @@ -22,15 +22,15 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.Resource; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.Person; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Rod Johnson diff --git a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java index 31afac2e099c..5536a17c8f0d 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java @@ -25,7 +25,7 @@ import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Stephane Nicoll diff --git a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java index ef7bea56dae9..a5298674de79 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java @@ -25,15 +25,15 @@ import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import org.springframework.tests.sample.beans.Person; import org.springframework.tests.sample.beans.SerializablePerson; import org.springframework.tests.sample.beans.SideEffectBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Rod Johnson diff --git a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java index 0efaa5165e6f..54ea0552c769 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java @@ -26,7 +26,7 @@ import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Juergen Hoeller diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java index a8b7d812ab22..a4006bd888ed 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java @@ -23,9 +23,9 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.sample.beans.SerializablePerson; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java index edcf3379a7cf..37bf57a27417 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java @@ -24,7 +24,7 @@ import org.springframework.tests.sample.beans.SideEffectBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Rod Johnson diff --git a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java index bb5e6579d83c..1ff3816db8bc 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java @@ -25,7 +25,7 @@ import org.springframework.tests.sample.beans.SideEffectBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Rod Johnson diff --git a/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java index dbfe7024c450..23c1c56f048e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java @@ -18,10 +18,10 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.EnabledForTestGroups; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * @author Rob Harrop diff --git a/spring-aop/src/test/java/org/springframework/tests/aop/interceptor/TimestampIntroductionInterceptor.java b/spring-aop/src/test/java/org/springframework/tests/aop/interceptor/TimestampIntroductionInterceptor.java index 8e665dba6567..41e79f3e5c94 100644 --- a/spring-aop/src/test/java/org/springframework/tests/aop/interceptor/TimestampIntroductionInterceptor.java +++ b/spring-aop/src/test/java/org/springframework/tests/aop/interceptor/TimestampIntroductionInterceptor.java @@ -17,7 +17,7 @@ package org.springframework.tests.aop.interceptor; import org.springframework.aop.support.DelegatingIntroductionInterceptor; -import org.springframework.tests.TimeStamped; +import org.springframework.core.test.fixtures.TimeStamped; @SuppressWarnings("serial") public class TimestampIntroductionInterceptor extends DelegatingIntroductionInterceptor diff --git a/spring-aspects/spring-aspects.gradle b/spring-aspects/spring-aspects.gradle index b30a8107f987..fbb219643771 100644 --- a/spring-aspects/spring-aspects.gradle +++ b/spring-aspects/spring-aspects.gradle @@ -24,6 +24,7 @@ dependencies { optional("javax.transaction:javax.transaction-api") // for @javax.transaction.Transactional support testCompile(project(":spring-core")) // for CodeStyleAspect testCompile(project(":spring-test")) + testCompile(testFixtures(project(":spring-core"))) testCompile("javax.mail:javax.mail-api") testCompileOnly("org.aspectj:aspectjrt") } diff --git a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java index 62dceafaede3..940c3e044b21 100644 --- a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java +++ b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java @@ -30,15 +30,15 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.core.task.SimpleAsyncTaskExecutor; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.tests.EnabledForTestGroups; import org.springframework.util.ReflectionUtils; import org.springframework.util.concurrent.ListenableFuture; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * Unit tests for {@link AnnotationAsyncExecutionAspect}. diff --git a/spring-beans/spring-beans.gradle b/spring-beans/spring-beans.gradle index 0409b9e910d8..9ab23dedff8d 100644 --- a/spring-beans/spring-beans.gradle +++ b/spring-beans/spring-beans.gradle @@ -10,6 +10,7 @@ dependencies { optional("org.codehaus.groovy:groovy-xml") optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") + testCompile(testFixtures(project(":spring-core"))) testCompile("javax.annotation:javax.annotation-api") } diff --git a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java index 0b7576bad4ca..723ee31c2388 100644 --- a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java @@ -47,9 +47,9 @@ import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.core.convert.support.GenericConversionService; +import org.springframework.core.test.fixtures.Assume; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.lang.Nullable; -import org.springframework.tests.Assume; -import org.springframework.tests.EnabledForTestGroups; import org.springframework.tests.sample.beans.BooleanTestBean; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.IndexedTestBean; @@ -62,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.within; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * Shared tests for property accessors. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java index 47aa95f8a929..4f7a9659bc0c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java @@ -37,7 +37,7 @@ import org.springframework.util.ObjectUtils; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Rod Johnson diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java index 87f7e0089a35..2587d05e4e60 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java @@ -33,11 +33,11 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.propertyeditors.CustomDateEditor; -import org.springframework.tests.EnabledForTestGroups; -import org.springframework.tests.TestGroup; +import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.test.fixtures.TestGroup; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Guillaume Poirier diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java index 2c38c122e687..20fde13c848e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java @@ -86,10 +86,11 @@ import org.springframework.core.convert.support.GenericConversionService; import org.springframework.core.io.Resource; import org.springframework.core.io.UrlResource; +import org.springframework.core.test.fixtures.Assume; +import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.test.fixtures.TestGroup; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.lang.Nullable; -import org.springframework.tests.Assume; -import org.springframework.tests.EnabledForTestGroups; -import org.springframework.tests.TestGroup; import org.springframework.tests.sample.beans.DependenciesBean; import org.springframework.tests.sample.beans.DerivedTestBean; import org.springframework.tests.sample.beans.ITestBean; @@ -98,7 +99,6 @@ import org.springframework.tests.sample.beans.SideEffectBean; import org.springframework.tests.sample.beans.TestBean; import org.springframework.tests.sample.beans.factory.DummyFactory; -import org.springframework.util.SerializationTestUtils; import org.springframework.util.StopWatch; import org.springframework.util.StringValueResolver; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java index 3bffa8ca1fae..427161efb3b3 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java @@ -27,11 +27,11 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.Resource; -import org.springframework.stereotype.Component; +import org.springframework.core.test.fixtures.stereotype.Component; import org.springframework.util.Assert; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Rob Harrop diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java index 8f650ffc3601..2a552309f637 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java @@ -68,12 +68,12 @@ import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.Order; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.IndexedTestBean; import org.springframework.tests.sample.beans.NestedTestBean; import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ReflectionUtils; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java index 3454c28d9c22..259132d5ff90 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * Unit tests for {@link CustomAutowireConfigurer}. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java index 8f498f3889e9..2a39ac4fbafb 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java @@ -40,11 +40,11 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.IndexedTestBean; import org.springframework.tests.sample.beans.NestedTestBean; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java index cc20dc84e4d3..770a6bddd0bf 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java @@ -25,7 +25,7 @@ import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * Unit tests for {@link FieldRetrievingFactoryBean}. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java index 02066e98a455..d045f1d9619d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java @@ -28,13 +28,13 @@ import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.util.SerializationTestUtils; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Colin Sampaleanu diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java index e7b68287893d..cdd9778c1348 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java @@ -23,7 +23,7 @@ import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * Unit tests for {@link PropertiesFactoryBean}. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java index 0c7fcc4a4c1f..c9ba85ae21be 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java @@ -25,7 +25,7 @@ import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * Unit tests for {@link PropertyPathFactoryBean}. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java index 9d5b3909ce60..cf8cf8ac18ae 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java @@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * Unit tests for various {@link PropertyResourceConfigurer} implementations including: diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java index 297c4a655ca6..5844bb080690 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java @@ -28,7 +28,7 @@ import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * Simple test to illustrate and verify scope usage. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java index 33caa90d5734..c8287913ef8b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java @@ -27,7 +27,7 @@ import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestResourceUtils.qualifiedResource; +import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; /** * @author Rob Harrop diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java index d848f90a7e5e..e89a49b4b3be 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java @@ -49,7 +49,7 @@ import org.springframework.core.annotation.Order; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.UrlResource; -import org.springframework.tests.EnabledForTestGroups; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.tests.sample.beans.GenericBean; import org.springframework.tests.sample.beans.GenericIntegerBean; import org.springframework.tests.sample.beans.GenericSetOfIntegerBean; @@ -57,7 +57,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.tests.TestGroup.LONG_RUNNING; +import static org.springframework.core.test.fixtures.TestGroup.LONG_RUNNING; /** * @author Juergen Hoeller diff --git a/spring-context-indexer/src/test/java/org/springframework/context/index/sample/SampleNone.java b/spring-context-indexer/src/test/java/org/springframework/context/index/sample/SampleNone.java index bd1cd72401f2..f81de9365b85 100644 --- a/spring-context-indexer/src/test/java/org/springframework/context/index/sample/SampleNone.java +++ b/spring-context-indexer/src/test/java/org/springframework/context/index/sample/SampleNone.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 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.context.index.sample; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.core.type.Scope; /** * Candidate with no matching annotation. diff --git a/spring-context-indexer/src/test/java/org/springframework/context/index/sample/Scope.java b/spring-context-indexer/src/test/java/org/springframework/context/index/sample/Scope.java new file mode 100644 index 000000000000..b96de6139374 --- /dev/null +++ b/spring-context-indexer/src/test/java/org/springframework/context/index/sample/Scope.java @@ -0,0 +1,33 @@ +/* + * Copyright 2002-2009 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.context.index.sample; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Copy of the {@code @Scope} annotation for testing purposes. + */ +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +public @interface Scope { + + String value() default "singleton"; + +} diff --git a/spring-context-support/spring-context-support.gradle b/spring-context-support/spring-context-support.gradle index 54bf50e43335..f2fb5feedeb1 100644 --- a/spring-context-support/spring-context-support.gradle +++ b/spring-context-support/spring-context-support.gradle @@ -15,6 +15,7 @@ dependencies { optional("org.codehaus.fabric3.api:commonj") optional("org.freemarker:freemarker") testCompile(project(":spring-context")) + testCompile(testFixtures(project(":spring-core"))) testCompile("org.hsqldb:hsqldb") testCompile("org.hibernate:hibernate-validator") testCompile("javax.annotation:javax.annotation-api") diff --git a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java index df0e02b72ae7..b35768a7bf9a 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java @@ -26,10 +26,10 @@ import org.junit.jupiter.api.Test; import org.springframework.cache.AbstractCacheTests; -import org.springframework.tests.EnabledForTestGroups; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestGroup.LONG_RUNNING; +import static org.springframework.core.test.fixtures.TestGroup.LONG_RUNNING; /** * @author Costin Leau diff --git a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java index b2503fb7db35..3e22f8483523 100644 --- a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java +++ b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java @@ -37,8 +37,8 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.StaticApplicationContext; import org.springframework.core.task.TaskExecutor; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.tests.EnabledForTestGroups; import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; @@ -46,7 +46,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * @author Juergen Hoeller diff --git a/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java b/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java index 7639b6704b48..deb14733357b 100644 --- a/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java +++ b/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java @@ -52,8 +52,8 @@ import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; import org.springframework.context.support.StaticMessageSource; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.util.ObjectUtils; -import org.springframework.util.SerializationTestUtils; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.FieldError; import org.springframework.validation.beanvalidation.SpringValidatorAdapter; diff --git a/spring-context/spring-context.gradle b/spring-context/spring-context.gradle index 54ee48da69ac..0894c8d55f02 100644 --- a/spring-context/spring-context.gradle +++ b/spring-context/spring-context.gradle @@ -26,6 +26,7 @@ dependencies { optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") optional("org.reactivestreams:reactive-streams") + testCompile(testFixtures(project(":spring-core"))) testCompile("io.projectreactor:reactor-core") testCompile("org.codehaus.groovy:groovy-jsr223") testCompile("org.codehaus.groovy:groovy-test") diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java index 341b25f3eb9c..8c88ad34b78a 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java @@ -50,10 +50,10 @@ import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.core.io.ClassPathResource; +import org.springframework.core.test.fixtures.Assume; +import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.test.fixtures.TestGroup; import org.springframework.lang.Nullable; -import org.springframework.tests.Assume; -import org.springframework.tests.EnabledForTestGroups; -import org.springframework.tests.TestGroup; import org.springframework.tests.sample.beans.INestedTestBean; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.NestedTestBean; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java index b5b151c08335..8fb952e12f0c 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java @@ -57,10 +57,11 @@ import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; import org.springframework.aop.target.HotSwappableTargetSource; import org.springframework.aop.target.SingletonTargetSource; +import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.test.fixtures.TestGroup; +import org.springframework.core.test.fixtures.TimeStamped; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.lang.Nullable; -import org.springframework.tests.EnabledForTestGroups; -import org.springframework.tests.TestGroup; -import org.springframework.tests.TimeStamped; import org.springframework.tests.aop.advice.CountingAfterReturningAdvice; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.advice.MethodCounter; @@ -73,7 +74,6 @@ import org.springframework.tests.sample.beans.Person; import org.springframework.tests.sample.beans.SerializablePerson; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; @@ -765,7 +765,7 @@ public void testIntroductionThrowsUncheckedException() throws Throwable { @SuppressWarnings("serial") class MyDi extends DelegatingIntroductionInterceptor implements TimeStamped { /** - * @see test.util.TimeStamped#getTimeStamp() + * @see org.springframework.core.test.fixtures.util.TimeStamped#getTimeStamp() */ @Override public long getTimeStamp() { diff --git a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java index a026401340cb..24c744ccba74 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java @@ -48,8 +48,9 @@ import org.springframework.context.ApplicationListener; import org.springframework.context.TestListener; import org.springframework.core.io.ClassPathResource; +import org.springframework.core.test.fixtures.TimeStamped; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.lang.Nullable; -import org.springframework.tests.TimeStamped; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.advice.MyThrowsHandler; import org.springframework.tests.aop.interceptor.NopInterceptor; @@ -58,7 +59,6 @@ import org.springframework.tests.sample.beans.Person; import org.springframework.tests.sample.beans.SideEffectBean; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java index 1e1ba357f80c..1af446bf16fe 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java @@ -26,7 +26,7 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.FactoryBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.TimeStamped; +import org.springframework.core.test.fixtures.TimeStamped; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.sample.beans.ITestBean; diff --git a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java index ff966c8f9e3e..82e9f0100439 100644 --- a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java @@ -27,10 +27,10 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.ClassPathResource; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.context.SimpleMapScope; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java index df0cec9921ff..beb840ae6ca3 100644 --- a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java @@ -27,10 +27,10 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.support.StaticApplicationContext; import org.springframework.core.io.ClassPathResource; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.sample.beans.Person; import org.springframework.tests.sample.beans.SerializablePerson; import org.springframework.tests.sample.beans.SideEffectBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java index f273716e5533..d820baa13561 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java @@ -55,6 +55,7 @@ import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.UrlResource; import org.springframework.core.io.support.EncodedResource; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.sample.beans.DependenciesBean; import org.springframework.tests.sample.beans.DerivedTestBean; import org.springframework.tests.sample.beans.ITestBean; @@ -64,7 +65,6 @@ import org.springframework.tests.sample.beans.factory.DummyFactory; import org.springframework.util.ClassUtils; import org.springframework.util.FileCopyUtils; -import org.springframework.util.SerializationTestUtils; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java index db76843b48a7..bf789c112054 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java @@ -34,13 +34,13 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.tests.Assume; -import org.springframework.tests.EnabledForTestGroups; +import org.springframework.core.test.fixtures.Assume; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * @author Juergen Hoeller diff --git a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java index 646393f0d1fd..96b9d1f78740 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java @@ -37,13 +37,13 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.support.GenericApplicationContext; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.jndi.support.SimpleJndiBeanFactory; import org.springframework.tests.mock.jndi.ExpectedLookupTemplate; import org.springframework.tests.sample.beans.INestedTestBean; import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.NestedTestBean; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java index 86b607729280..4f13113e52f6 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java @@ -55,11 +55,11 @@ import org.springframework.core.env.Environment; import org.springframework.core.env.Profiles; import org.springframework.core.io.ResourceLoader; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.filter.TypeFilter; import org.springframework.tests.context.SimpleMapScope; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java index 67480997a359..4c3f6baef119 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java @@ -23,8 +23,8 @@ import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.context.SimpleMapScope; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java index adf27cd2db63..0c1e65b76f81 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java @@ -51,15 +51,15 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.core.io.support.EncodedResource; -import org.springframework.tests.Assume; -import org.springframework.tests.EnabledForTestGroups; +import org.springframework.core.test.fixtures.Assume; +import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.FileCopyUtils; -import org.springframework.util.SerializationTestUtils; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * @author Juergen Hoeller diff --git a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java index 5f4600e82a4d..a68066125ebd 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java @@ -21,7 +21,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.mock.env.MockPropertySource; +import org.springframework.core.test.fixtures.env.MockPropertySource; import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java index 6538d05bc5f5..f24be678c738 100644 --- a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java @@ -27,10 +27,10 @@ import org.springframework.context.Lifecycle; import org.springframework.context.LifecycleProcessor; import org.springframework.context.SmartLifecycle; -import org.springframework.tests.EnabledForTestGroups; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * @author Mark Fisher diff --git a/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java index 584f242e7d9f..190ba795821f 100644 --- a/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java @@ -28,13 +28,12 @@ import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; import org.springframework.context.annotation.Profile; import org.springframework.core.env.AbstractEnvironment; -import org.springframework.core.env.StandardEnvironmentTests; +import org.springframework.core.test.fixtures.env.EnvironmentTestUtils; import org.springframework.stereotype.Component; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; - /** * Tests integration between Environment and SecurityManagers. See SPR-9970. * @@ -50,7 +49,7 @@ public class EnvironmentSecurityManagerIntegrationTests { @BeforeEach public void setUp() { originalSecurityManager = System.getSecurityManager(); - env = StandardEnvironmentTests.getModifiableSystemEnvironment(); + env = EnvironmentTestUtils.getModifiableSystemEnvironment(); env.put(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "p1"); } diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java index c08b49210eb5..fb1f12ac1955 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java @@ -29,8 +29,8 @@ import org.springframework.core.env.StandardEnvironment; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import org.springframework.core.test.fixtures.env.MockPropertySource; import org.springframework.mock.env.MockEnvironment; -import org.springframework.mock.env.MockPropertySource; import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java b/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java index f518bd40c860..bb23db28d4a0 100644 --- a/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java +++ b/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java @@ -18,6 +18,7 @@ import org.springframework.core.env.AbstractEnvironment; import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.test.fixtures.env.MockPropertySource; /** * Simple {@link ConfigurableEnvironment} implementation exposing diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java index 6911a0b37e08..6a155d4cc899 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java @@ -26,16 +26,16 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.config.IntervalTask; import org.springframework.scheduling.config.ScheduledTaskHolder; import org.springframework.scheduling.config.ScheduledTaskRegistrar; import org.springframework.scheduling.config.TaskManagementConfigUtils; -import org.springframework.tests.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * Tests use of @EnableScheduling on @Configuration classes. diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java index cb3099cccecc..c35995d0f6bd 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import org.springframework.core.task.NoOpRunnable; -import org.springframework.tests.EnabledForTestGroups; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * @author Rick Evans diff --git a/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java b/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java index 88adb4e7bdf2..65c9bfdb5e61 100644 --- a/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java @@ -24,16 +24,16 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.GenericApplicationContext; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.scripting.Messenger; import org.springframework.scripting.ScriptCompilationException; import org.springframework.scripting.groovy.GroovyScriptFactory; -import org.springframework.tests.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.mockito.Mockito.mock; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * @author Rick Evans diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java index 4e7eaf4d09fc..0145e155b780 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java @@ -50,8 +50,8 @@ import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; import org.springframework.context.support.StaticMessageSource; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.util.ObjectUtils; -import org.springframework.util.SerializationTestUtils; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.FieldError; diff --git a/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt b/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt index f54c7c946253..d9fc98990aef 100644 --- a/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt @@ -25,7 +25,7 @@ import org.springframework.beans.factory.getBean import org.springframework.context.support.BeanDefinitionDsl.* import org.springframework.core.env.SimpleCommandLinePropertySource import org.springframework.core.env.get -import org.springframework.mock.env.MockPropertySource +import org.springframework.core.test.fixtures.env.MockPropertySource import java.util.stream.Collectors @Suppress("UNUSED_EXPRESSION") diff --git a/spring-core/spring-core.gradle b/spring-core/spring-core.gradle index 48fd9976b504..a84b8e753706 100644 --- a/spring-core/spring-core.gradle +++ b/spring-core/spring-core.gradle @@ -60,6 +60,12 @@ dependencies { testCompile("javax.xml.bind:jaxb-api") testCompile("com.fasterxml.woodstox:woodstox-core") testCompile(project(":kotlin-coroutines")) + testFixturesApi("org.junit.jupiter:junit-jupiter-api") + testFixturesApi("org.junit.jupiter:junit-jupiter-params") + testFixturesImplementation("com.google.code.findbugs:jsr305") + testFixturesImplementation("io.projectreactor:reactor-test") + testFixturesImplementation("org.assertj:assertj-core") + testFixturesImplementation("org.xmlunit:xmlunit-assertj") } jar { diff --git a/spring-core/src/test/java/example/type/AspectJTypeFilterTestsTypes.java b/spring-core/src/test/java/example/type/AspectJTypeFilterTestsTypes.java index d4151647525a..bf17886f9b7a 100644 --- a/spring-core/src/test/java/example/type/AspectJTypeFilterTestsTypes.java +++ b/spring-core/src/test/java/example/type/AspectJTypeFilterTestsTypes.java @@ -16,7 +16,7 @@ package example.type; -import org.springframework.stereotype.Component; +import org.springframework.core.test.fixtures.stereotype.Component; /** * We must use a standalone set of types to ensure that no one else is loading diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java index 1b1bc2b0f98e..0aca2ed60776 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java @@ -42,10 +42,10 @@ import org.springframework.core.annotation.AnnotationUtilsTests.ImplementsInterfaceWithGenericAnnotatedMethod; import org.springframework.core.annotation.AnnotationUtilsTests.WebController; import org.springframework.core.annotation.AnnotationUtilsTests.WebMapping; +import org.springframework.core.test.fixtures.stereotype.Component; +import org.springframework.core.test.fixtures.stereotype.Indexed; import org.springframework.lang.NonNullApi; import org.springframework.lang.Nullable; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Indexed; import org.springframework.util.MultiValueMap; import static java.util.Arrays.asList; diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 6270f108841e..78ec17e6b8ca 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -39,8 +39,8 @@ import org.springframework.core.Ordered; import org.springframework.core.annotation.subpackage.NonPublicAnnotatedClass; +import org.springframework.core.test.fixtures.stereotype.Component; import org.springframework.lang.NonNullApi; -import org.springframework.stereotype.Component; import static java.util.Arrays.asList; import static java.util.Arrays.stream; @@ -928,7 +928,7 @@ void synthesizeAnnotationFromMapWithAttributeOfIncorrectType() throws Exception Map map = Collections.singletonMap(VALUE, 42L); assertThatIllegalStateException().isThrownBy(() -> synthesizeAnnotation(map, Component.class, null).value()) - .withMessageContaining("Attribute 'value' in annotation org.springframework.stereotype.Component " + .withMessageContaining("Attribute 'value' in annotation org.springframework.core.test.fixtures.stereotype.Component " + "should be compatible with java.lang.String but a java.lang.Long value was returned"); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java index 6241039c40f1..956f93f549a8 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java @@ -43,9 +43,9 @@ import org.springframework.core.annotation.MergedAnnotation.Adapt; import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; import org.springframework.core.annotation.subpackage.NonPublicAnnotatedClass; +import org.springframework.core.test.fixtures.stereotype.Component; +import org.springframework.core.test.fixtures.stereotype.Indexed; import org.springframework.lang.Nullable; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Indexed; import org.springframework.util.ClassUtils; import org.springframework.util.MultiValueMap; import org.springframework.util.ReflectionUtils; @@ -1770,7 +1770,7 @@ void synthesizeFromMapWithAttributeOfIncorrectType() throws Exception { MergedAnnotation annotation = MergedAnnotation.of(Component.class, map); assertThatIllegalStateException().isThrownBy(() -> annotation.synthesize().value()) .withMessage("Attribute 'value' in annotation " + - "org.springframework.stereotype.Component should be " + + "org.springframework.core.test.fixtures.stereotype.Component should be " + "compatible with java.lang.String but a java.lang.Long value was returned"); } diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java index 1eb50b011b98..c41874ef0836 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java @@ -24,6 +24,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java index 2c44c1a83811..12d40d64aad0 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java @@ -22,6 +22,7 @@ import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; +import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java index 2563ff8c9fab..1d0215ee58e6 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java @@ -25,6 +25,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java index aa18e0e1ecf9..066aa9051d9b 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java @@ -23,6 +23,7 @@ import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; +import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java index c0a85d0816c8..6356dfc810e2 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java @@ -23,6 +23,7 @@ import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; +import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; import org.springframework.util.MimeTypeUtils; import static java.nio.charset.StandardCharsets.ISO_8859_1; diff --git a/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java index efde8b15eb74..ec0ccdda0869 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java @@ -25,6 +25,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; +import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java index c9322af3c7ea..cb6242c7182c 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java @@ -24,6 +24,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java index f05b34fbbbb5..409d9c693e96 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java @@ -28,6 +28,7 @@ import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.Resource; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; import org.springframework.util.MimeTypeUtils; import org.springframework.util.StreamUtils; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java index 193c705a7adf..b99bcb3812cf 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java @@ -28,6 +28,7 @@ import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.Resource; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; import org.springframework.lang.Nullable; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java index ce83d5bebdff..8148ecf64e05 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java @@ -29,11 +29,11 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; import org.springframework.core.io.support.ResourceRegion; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; diff --git a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java index a17ae084c2fd..bcfc43b498f0 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java @@ -30,6 +30,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferLimitException; +import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; diff --git a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java index 8deb6d3f3cf8..f5a932bacbd5 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java @@ -51,13 +51,13 @@ import org.springframework.core.convert.ConverterNotFoundException; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.support.DefaultConversionService; -import org.springframework.tests.EnabledForTestGroups; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.util.ClassUtils; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * Unit tests for {@link DefaultConversionService}. diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java index a91c64bb320e..fd2271d26f6b 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java @@ -43,8 +43,8 @@ import org.springframework.core.convert.converter.GenericConverter; import org.springframework.core.io.DescriptiveResource; import org.springframework.core.io.Resource; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.lang.Nullable; -import org.springframework.tests.EnabledForTestGroups; import org.springframework.util.StopWatch; import org.springframework.util.StringUtils; @@ -54,7 +54,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * Unit tests for {@link GenericConversionService}. diff --git a/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java b/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java index fa79f1804407..9d04dcbd2466 100644 --- a/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.env.MockPropertySource; +import org.springframework.core.test.fixtures.env.MockPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java index d3eaa2804fb7..bed53fce1f4d 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.springframework.core.convert.ConverterNotFoundException; -import org.springframework.mock.env.MockPropertySource; +import org.springframework.core.test.fixtures.env.MockPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java index f7218b9c48b0..24bb7143ebe6 100644 --- a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java @@ -16,17 +16,16 @@ package org.springframework.core.env; -import java.lang.reflect.Field; import java.security.AccessControlException; import java.security.Permission; import java.util.Arrays; -import java.util.Collections; import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.core.SpringProperties; -import org.springframework.mock.env.MockPropertySource; +import org.springframework.core.test.fixtures.env.EnvironmentTestUtils; +import org.springframework.core.test.fixtures.env.MockPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -465,8 +464,8 @@ public void checkPermission(Permission perm) { @Test void getSystemEnvironment_withAndWithoutSecurityManager() { - getModifiableSystemEnvironment().put(ALLOWED_PROPERTY_NAME, ALLOWED_PROPERTY_VALUE); - getModifiableSystemEnvironment().put(DISALLOWED_PROPERTY_NAME, DISALLOWED_PROPERTY_VALUE); + EnvironmentTestUtils.getModifiableSystemEnvironment().put(ALLOWED_PROPERTY_NAME, ALLOWED_PROPERTY_VALUE); + EnvironmentTestUtils.getModifiableSystemEnvironment().put(DISALLOWED_PROPERTY_NAME, DISALLOWED_PROPERTY_VALUE); { Map systemEnvironment = environment.getSystemEnvironment(); @@ -500,68 +499,8 @@ public void checkPermission(Permission perm) { } System.setSecurityManager(oldSecurityManager); - getModifiableSystemEnvironment().remove(ALLOWED_PROPERTY_NAME); - getModifiableSystemEnvironment().remove(DISALLOWED_PROPERTY_NAME); - } - - - @SuppressWarnings("unchecked") - public static Map getModifiableSystemEnvironment() { - // for os x / linux - Class[] classes = Collections.class.getDeclaredClasses(); - Map env = System.getenv(); - for (Class cl : classes) { - if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) { - try { - Field field = cl.getDeclaredField("m"); - field.setAccessible(true); - Object obj = field.get(env); - if (obj != null && obj.getClass().getName().equals("java.lang.ProcessEnvironment$StringEnvironment")) { - return (Map) obj; - } - } - catch (Exception ex) { - throw new RuntimeException(ex); - } - } - } - - // for windows - Class processEnvironmentClass; - try { - processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment"); - } - catch (Exception ex) { - throw new IllegalStateException(ex); - } - - try { - Field theCaseInsensitiveEnvironmentField = processEnvironmentClass.getDeclaredField("theCaseInsensitiveEnvironment"); - theCaseInsensitiveEnvironmentField.setAccessible(true); - Object obj = theCaseInsensitiveEnvironmentField.get(null); - return (Map) obj; - } - catch (NoSuchFieldException ex) { - // do nothing - } - catch (Exception ex) { - throw new IllegalStateException(ex); - } - - try { - Field theEnvironmentField = processEnvironmentClass.getDeclaredField("theEnvironment"); - theEnvironmentField.setAccessible(true); - Object obj = theEnvironmentField.get(null); - return (Map) obj; - } - catch (NoSuchFieldException ex) { - // do nothing - } - catch (Exception ex) { - throw new IllegalStateException(ex); - } - - throw new IllegalStateException(); + EnvironmentTestUtils.getModifiableSystemEnvironment().remove(ALLOWED_PROPERTY_NAME); + EnvironmentTestUtils.getModifiableSystemEnvironment().remove(DISALLOWED_PROPERTY_NAME); } } diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java index f39c87d445e1..2d006cd45a7e 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java @@ -22,6 +22,8 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; +import org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests; + import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java index 27067179cdc7..168a6df23e84 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java @@ -45,7 +45,8 @@ import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java index ef329ea62bb0..37d941dde6f1 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java @@ -18,6 +18,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory; + import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.springframework.core.io.buffer.DataBufferUtils.release; diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java index 5100feb3ffc1..576df2655887 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java @@ -18,9 +18,10 @@ import java.nio.charset.StandardCharsets; -import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTests; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; +import org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java b/spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupParsingTests.java similarity index 95% rename from spring-core/src/test/java/org/springframework/tests/TestGroupTests.java rename to spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupParsingTests.java index 5377c4b5f74f..097fd19c8c79 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java +++ b/spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupParsingTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests; +package org.springframework.core.test.fixtures; import java.util.Collections; import java.util.EnumSet; @@ -26,12 +26,12 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; /** - * Tests for {@link TestGroup}. + * Tests for {@link TestGroup} parsing. * * @author Phillip Webb * @author Sam Brannen */ -class TestGroupTests { +class TestGroupParsingTests { @Test void parseNull() { diff --git a/spring-core/src/test/java/org/springframework/tests/AssumeTests.java b/spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupTests.java similarity index 76% rename from spring-core/src/test/java/org/springframework/tests/AssumeTests.java rename to spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupTests.java index f077ffe6170b..84eda4984c59 100644 --- a/spring-core/src/test/java/org/springframework/tests/AssumeTests.java +++ b/spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupTests.java @@ -14,9 +14,10 @@ * limitations under the License. */ -package org.springframework.tests; +package org.springframework.core.test.fixtures; import java.util.Arrays; +import java.util.Set; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -28,17 +29,20 @@ import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.springframework.tests.Assume.TEST_GROUPS_SYSTEM_PROPERTY; -import static org.springframework.tests.TestGroup.LONG_RUNNING; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.junit.jupiter.api.Assumptions.assumeTrue; +import static org.springframework.core.test.fixtures.TestGroup.LONG_RUNNING; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** - * Tests for {@link Assume}. + * Tests for {@link TestGroup}. * * @author Sam Brannen * @since 5.0 */ -class AssumeTests { +class TestGroupTests { + + private static final String TEST_GROUPS_SYSTEM_PROPERTY = "testGroups"; + private String originalTestGroups; @@ -59,25 +63,22 @@ void restoreOriginalTestGroups() { } @Test - @SuppressWarnings("deprecation") void assumeGroupWithNoActiveTestGroups() { setTestGroups(""); - assertThatExceptionOfType(TestAbortedException.class).isThrownBy(() -> Assume.group(LONG_RUNNING)); + assertThatExceptionOfType(TestAbortedException.class).isThrownBy(() -> assumeGroup(LONG_RUNNING)); } @Test - @SuppressWarnings("deprecation") void assumeGroupWithNoMatchingActiveTestGroup() { setTestGroups(PERFORMANCE); - assertThatExceptionOfType(TestAbortedException.class).isThrownBy(() -> Assume.group(LONG_RUNNING)); + assertThatExceptionOfType(TestAbortedException.class).isThrownBy(() -> assumeGroup(LONG_RUNNING)); } @Test - @SuppressWarnings("deprecation") void assumeGroupWithMatchingActiveTestGroup() { setTestGroups(LONG_RUNNING); - assertThatCode(() -> Assume.group(LONG_RUNNING)) + assertThatCode(() -> assumeGroup(LONG_RUNNING)) .as("assumption should NOT have failed") .doesNotThrowAnyException(); } @@ -92,7 +93,6 @@ void assumeGroupWithAllMinusBogusActiveTestGroup() { assertBogusActiveTestGroupBehavior("all-bogus"); } - @SuppressWarnings("deprecation") private void assertBogusActiveTestGroupBehavior(String testGroups) { // Should result in something similar to the following: // @@ -102,7 +102,7 @@ private void assertBogusActiveTestGroupBehavior(String testGroups) { setTestGroups(testGroups); assertThatIllegalStateException() - .isThrownBy(() -> Assume.group(LONG_RUNNING)) + .isThrownBy(() -> assumeGroup(LONG_RUNNING)) .withMessageStartingWith("Failed to parse '" + TEST_GROUPS_SYSTEM_PROPERTY + "' system property: ") .withCauseInstanceOf(IllegalArgumentException.class) .satisfies(ex -> @@ -119,4 +119,15 @@ private void setTestGroups(String testGroups) { System.setProperty(TEST_GROUPS_SYSTEM_PROPERTY, testGroups); } + /** + * Assume that a particular {@link TestGroup} is active. + * @param group the group that must be active + * @throws org.opentest4j.TestAbortedException if the assumption fails + */ + private static void assumeGroup(TestGroup group) { + Set testGroups = TestGroup.loadTestGroups(); + assumeTrue(testGroups.contains(group), + () -> "Requires inactive test group " + group + "; active test groups: " + testGroups); + } + } diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index 571440dfaa71..0881e55de54f 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -33,10 +33,10 @@ import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AnnotationAttributes; +import org.springframework.core.test.fixtures.stereotype.Component; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; -import org.springframework.stereotype.Component; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java index 0fc09ecdf4fb..d1c7d1652f6c 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java @@ -21,11 +21,11 @@ import example.type.NonInheritedAnnotation; import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.stereotype.Component; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; import org.springframework.core.type.filter.AnnotationTypeFilter; -import org.springframework.stereotype.Component; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java b/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java index f1fc05a2082b..a3dfed9fcc9d 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java @@ -88,7 +88,7 @@ void subclassPatternNoMatches() throws Exception { @Test void annotationPatternMatches() throws Exception { assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", - "@org.springframework.stereotype.Component *..*"); + "@org.springframework.core.test.fixtures.stereotype.Component *..*"); assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", "@* *..*"); assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", @@ -96,9 +96,9 @@ void annotationPatternMatches() throws Exception { assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", "@*..*Component *..*"); assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", - "@org.springframework.stereotype.Component *..*Component"); + "@org.springframework.core.test.fixtures.stereotype.Component *..*Component"); assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", - "@org.springframework.stereotype.Component *"); + "@org.springframework.core.test.fixtures.stereotype.Component *"); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java b/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java index 9f61f1328289..405a742034bb 100644 --- a/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java @@ -22,13 +22,13 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.UrlResource; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.core.type.classreading.CachingMetadataReaderFactory; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; -import org.springframework.tests.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestGroup.LONG_RUNNING; +import static org.springframework.core.test.fixtures.TestGroup.LONG_RUNNING; /** * Unit tests for checking the behaviour of {@link CachingMetadataReaderFactory} under diff --git a/spring-core/src/test/java/org/springframework/core/type/Scope.java b/spring-core/src/test/java/org/springframework/core/type/Scope.java index 0a169a2e5f58..eb581928a96b 100644 --- a/spring-core/src/test/java/org/springframework/core/type/Scope.java +++ b/spring-core/src/test/java/org/springframework/core/type/Scope.java @@ -16,21 +16,18 @@ package org.springframework.core.type; -import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -@Target({ElementType.TYPE, ElementType.METHOD}) +/** + * Copy of the {@code @Scope} annotation for testing purposes. + */ +@Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) -@Documented public @interface Scope { - /** - * Specifies the scope to use for instances of the annotated class. - * @return the desired scope - */ String value() default "singleton"; } diff --git a/spring-core/src/test/java/org/springframework/tests/Assume.java b/spring-core/src/test/java/org/springframework/tests/Assume.java deleted file mode 100644 index 76503c01b2cb..000000000000 --- a/spring-core/src/test/java/org/springframework/tests/Assume.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2002-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.tests; - -import java.util.Set; - -import org.apache.commons.logging.Log; - -import static org.junit.jupiter.api.Assumptions.assumeFalse; -import static org.junit.jupiter.api.Assumptions.assumeTrue; - -/** - * Provides utility methods that allow JUnit tests to assume certain conditions - * hold {@code true}. If the assumption fails, it means the test should be - * aborted. - * - *

    Tests can be categorized into {@link TestGroup}s. Active groups are enabled using - * the 'testGroups' system property, usually activated from the gradle command line: - * - *

    - * gradle test -PtestGroups="performance"
    - * 
    - * - *

    Groups can be activated as a comma separated list of values, or using the - * pseudo group 'all'. See {@link TestGroup} for a list of valid groups. - * - * @author Rob Winch - * @author Phillip Webb - * @author Sam Brannen - * @since 3.2 - * @see EnabledForTestGroups @EnabledForTestGroups - * @see #notLogging(Log) - * @see TestGroup - */ -public abstract class Assume { - - static final String TEST_GROUPS_SYSTEM_PROPERTY = "testGroups"; - - - /** - * Assume that a particular {@link TestGroup} is active. - * @param group the group that must be active - * @throws org.opentest4j.TestAbortedException if the assumption fails - * @deprecated as of Spring Framework 5.2 in favor of {@link EnabledForTestGroups} - */ - @Deprecated - public static void group(TestGroup group) { - Set testGroups = TestGroup.loadTestGroups(); - assumeTrue(testGroups.contains(group), - () -> "Requires inactive test group " + group + "; active test groups: " + testGroups); - } - - /** - * Assume that the specified log is not set to Trace or Debug. - * @param log the log to test - * @throws org.opentest4j.TestAbortedException if the assumption fails - */ - public static void notLogging(Log log) { - assumeFalse(log.isTraceEnabled()); - assumeFalse(log.isDebugEnabled()); - } - -} diff --git a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java index 4401096721c6..416ad92d2dbf 100644 --- a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java +++ b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.sample.objects.TestObject; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java index cf8629948d51..4bef1397a210 100644 --- a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java @@ -27,12 +27,12 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.springframework.tests.EnabledForTestGroups; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.tests.sample.objects.TestObject; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * @author Rob Harrop diff --git a/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java b/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java index 98abc6b718be..d48b00b32f43 100644 --- a/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java @@ -25,14 +25,14 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; /** - * Test for static utility to help with serialization. + * Unit tests for {@link SerializationUtils}. * * @author Dave Syer * @since 3.0.5 */ class SerializationUtilsTests { - private static BigInteger FOO = new BigInteger( + private static final BigInteger FOO = new BigInteger( "-9702942423549012526722364838327831379660941553432801565505143675386108883970811292563757558516603356009681061" + "5697574744209306031461371833798723505120163874786203211176873686513374052845353833564048"); @@ -44,21 +44,17 @@ void serializeCycleSunnyDay() throws Exception { @Test void deserializeUndefined() throws Exception { - byte[] bytes = FOO.toByteArray(); - assertThatIllegalStateException().isThrownBy(() -> - SerializationUtils.deserialize(bytes)); + assertThatIllegalStateException().isThrownBy(() -> SerializationUtils.deserialize(FOO.toByteArray())); } @Test void serializeNonSerializable() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - SerializationUtils.serialize(new Object())); + assertThatIllegalArgumentException().isThrownBy(() -> SerializationUtils.serialize(new Object())); } @Test void deserializeNonSerializable() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - SerializationUtils.deserialize("foo".getBytes())); + assertThatIllegalArgumentException().isThrownBy(() -> SerializationUtils.deserialize("foo".getBytes())); } @Test diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTests.java index b127bce00672..2592d12a4a83 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTests.java @@ -34,7 +34,7 @@ import org.xml.sax.XMLReader; import org.xmlunit.util.Predicate; -import org.springframework.tests.XmlContent; +import org.springframework.core.test.fixtures.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java index a32eb4a3474a..a7fe73634c8d 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java @@ -28,7 +28,7 @@ import org.xml.sax.InputSource; import org.xml.sax.XMLReader; -import org.springframework.tests.XmlContent; +import org.springframework.core.test.fixtures.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java index 8a019329eb0e..0049180a3c5d 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.XmlContent; +import org.springframework.core.test.fixtures.xml.XmlContent; import static javax.xml.stream.XMLStreamConstants.END_DOCUMENT; import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java index 78188adcbdeb..000307e318cd 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java @@ -31,7 +31,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.tests.XmlContent; +import org.springframework.core.test.fixtures.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java index fb5ad8dcadb8..908dfd3d1b93 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java @@ -34,7 +34,7 @@ import org.w3c.dom.Document; import org.xml.sax.InputSource; -import org.springframework.tests.XmlContent; +import org.springframework.core.test.fixtures.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java index 832784168d23..7d9719a34733 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java @@ -31,7 +31,7 @@ import org.w3c.dom.Node; import org.xmlunit.util.Predicate; -import org.springframework.tests.XmlContent; +import org.springframework.core.test.fixtures.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java index e35807870a68..7ed978406b42 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java @@ -27,7 +27,7 @@ import org.w3c.dom.Node; import org.xmlunit.util.Predicate; -import org.springframework.tests.XmlContent; +import org.springframework.core.test.fixtures.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/Assume.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/Assume.java new file mode 100644 index 000000000000..1537f459a2a1 --- /dev/null +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/Assume.java @@ -0,0 +1,46 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.core.test.fixtures; + +import org.apache.commons.logging.Log; + +import static org.junit.jupiter.api.Assumptions.assumeFalse; + +/** + * Utility methods that allow JUnit tests to assume certain conditions hold + * {@code true}. If an assumption fails, it means the test should be aborted. + * + * @author Rob Winch + * @author Phillip Webb + * @author Sam Brannen + * @since 3.2 + * @see #notLogging(Log) + * @see EnabledForTestGroups @EnabledForTestGroups + */ +public abstract class Assume { + + /** + * Assume that the specified log is not set to Trace or Debug. + * @param log the log to test + * @throws org.opentest4j.TestAbortedException if the assumption fails + */ + public static void notLogging(Log log) { + assumeFalse(log.isTraceEnabled()); + assumeFalse(log.isDebugEnabled()); + } + +} diff --git a/spring-core/src/test/java/org/springframework/tests/EnabledForTestGroups.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/EnabledForTestGroups.java similarity index 96% rename from spring-core/src/test/java/org/springframework/tests/EnabledForTestGroups.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/EnabledForTestGroups.java index 4ae6637caa47..5fd5eeab9201 100644 --- a/spring-core/src/test/java/org/springframework/tests/EnabledForTestGroups.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/EnabledForTestGroups.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests; +package org.springframework.core.test.fixtures; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroup.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroup.java similarity index 98% rename from spring-core/src/test/java/org/springframework/tests/TestGroup.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroup.java index f04c47bc1823..0203908775b6 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestGroup.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroup.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests; +package org.springframework.core.test.fixtures; import java.util.Collections; import java.util.EnumSet; @@ -29,7 +29,6 @@ * A test group used to limit when certain tests are run. * * @see EnabledForTestGroups @EnabledForTestGroups - * @see Assume#group(TestGroup) * @author Phillip Webb * @author Chris Beams * @author Sam Brannen diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroupsCondition.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroupsCondition.java similarity index 97% rename from spring-core/src/test/java/org/springframework/tests/TestGroupsCondition.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroupsCondition.java index 90850b0acdf1..e17d446033c4 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestGroupsCondition.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroupsCondition.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests; +package org.springframework.core.test.fixtures; import java.util.Arrays; import java.util.Optional; diff --git a/spring-core/src/test/java/org/springframework/tests/TimeStamped.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TimeStamped.java similarity index 95% rename from spring-core/src/test/java/org/springframework/tests/TimeStamped.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TimeStamped.java index 20904c8b9abe..27fe1634002c 100644 --- a/spring-core/src/test/java/org/springframework/tests/TimeStamped.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TimeStamped.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests; +package org.springframework.core.test.fixtures; /** * This interface can be implemented by cacheable objects or cache entries, diff --git a/spring-core/src/test/java/org/springframework/core/codec/AbstractDecoderTests.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractDecoderTests.java similarity index 98% rename from spring-core/src/test/java/org/springframework/core/codec/AbstractDecoderTests.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractDecoderTests.java index de9598edafd8..72fece41b7e3 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/AbstractDecoderTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractDecoderTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.codec; +package org.springframework.core.test.fixtures.codec; import java.time.Duration; import java.util.Map; @@ -27,8 +27,9 @@ import reactor.test.StepVerifier; import org.springframework.core.ResolvableType; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.codec.Decoder; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.MimeType; @@ -43,7 +44,6 @@ * @author Arjen Poutsma * @since 5.1.3 */ -@SuppressWarnings("ProtectedField") public abstract class AbstractDecoderTests> extends AbstractLeakCheckingTests { /** diff --git a/spring-core/src/test/java/org/springframework/core/codec/AbstractEncoderTests.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractEncoderTests.java similarity index 98% rename from spring-core/src/test/java/org/springframework/core/codec/AbstractEncoderTests.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractEncoderTests.java index 4eb7c811a590..33af4bb64b0e 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/AbstractEncoderTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractEncoderTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.codec; +package org.springframework.core.test.fixtures.codec; import java.util.Map; import java.util.function.Consumer; @@ -25,9 +25,10 @@ import reactor.test.StepVerifier; import org.springframework.core.ResolvableType; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.codec.Encoder; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.MimeType; @@ -44,7 +45,6 @@ * @author Arjen Poutsma * @since 5.1.3 */ -@SuppressWarnings("ProtectedField") public abstract class AbstractEncoderTests> extends AbstractLeakCheckingTests { /** diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/EnvironmentTestUtils.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/EnvironmentTestUtils.java new file mode 100644 index 000000000000..227c70a84b73 --- /dev/null +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/EnvironmentTestUtils.java @@ -0,0 +1,92 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.core.test.fixtures.env; + +import java.lang.reflect.Field; +import java.util.Collections; +import java.util.Map; + +import org.springframework.core.env.StandardEnvironment; + +/** + * Test utilities for {@link StandardEnvironment}. + * + * @author Chris Beams + * @author Juergen Hoeller + */ +public class EnvironmentTestUtils { + + @SuppressWarnings("unchecked") + public static Map getModifiableSystemEnvironment() { + // for os x / linux + Class[] classes = Collections.class.getDeclaredClasses(); + Map env = System.getenv(); + for (Class cl : classes) { + if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) { + try { + Field field = cl.getDeclaredField("m"); + field.setAccessible(true); + Object obj = field.get(env); + if (obj != null && obj.getClass().getName().equals("java.lang.ProcessEnvironment$StringEnvironment")) { + return (Map) obj; + } + } + catch (Exception ex) { + throw new RuntimeException(ex); + } + } + } + + // for windows + Class processEnvironmentClass; + try { + processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment"); + } + catch (Exception ex) { + throw new IllegalStateException(ex); + } + + try { + Field theCaseInsensitiveEnvironmentField = processEnvironmentClass.getDeclaredField("theCaseInsensitiveEnvironment"); + theCaseInsensitiveEnvironmentField.setAccessible(true); + Object obj = theCaseInsensitiveEnvironmentField.get(null); + return (Map) obj; + } + catch (NoSuchFieldException ex) { + // do nothing + } + catch (Exception ex) { + throw new IllegalStateException(ex); + } + + try { + Field theEnvironmentField = processEnvironmentClass.getDeclaredField("theEnvironment"); + theEnvironmentField.setAccessible(true); + Object obj = theEnvironmentField.get(null); + return (Map) obj; + } + catch (NoSuchFieldException ex) { + // do nothing + } + catch (Exception ex) { + throw new IllegalStateException(ex); + } + + throw new IllegalStateException(); + } + +} diff --git a/spring-core/src/test/java/org/springframework/mock/env/MockPropertySource.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/MockPropertySource.java similarity index 98% rename from spring-core/src/test/java/org/springframework/mock/env/MockPropertySource.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/MockPropertySource.java index b2dc34a41e68..9037af3d5b84 100644 --- a/spring-core/src/test/java/org/springframework/mock/env/MockPropertySource.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/MockPropertySource.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.env; +package org.springframework.core.test.fixtures.env; import java.util.Properties; diff --git a/spring-core/src/test/java/org/springframework/tests/TestResourceUtils.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/ResourceTestUtils.java similarity index 89% rename from spring-core/src/test/java/org/springframework/tests/TestResourceUtils.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/ResourceTestUtils.java index 6f2a67f58ad4..3925c486876c 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestResourceUtils.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/ResourceTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests; +package org.springframework.core.test.fixtures.io; import org.springframework.core.io.ClassPathResource; @@ -23,7 +23,7 @@ * * @author Chris Beams */ -public abstract class TestResourceUtils { +public abstract class ResourceTestUtils { /** * Load a {@link ClassPathResource} qualified by the simple name of clazz, diff --git a/spring-core/src/test/java/org/springframework/util/SerializationTestUtils.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/SerializationTestUtils.java similarity index 97% rename from spring-core/src/test/java/org/springframework/util/SerializationTestUtils.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/SerializationTestUtils.java index 38c48dea3473..798dc834776e 100644 --- a/spring-core/src/test/java/org/springframework/util/SerializationTestUtils.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/SerializationTestUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.util; +package org.springframework.core.test.fixtures.io; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/AbstractDataBufferAllocatingTests.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractDataBufferAllocatingTests.java similarity index 92% rename from spring-core/src/test/java/org/springframework/core/io/buffer/AbstractDataBufferAllocatingTests.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractDataBufferAllocatingTests.java index dc8717e0df42..e8f40a82e1f7 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/AbstractDataBufferAllocatingTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractDataBufferAllocatingTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.io.buffer; +package org.springframework.core.test.fixtures.io.buffer; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -40,7 +40,11 @@ import org.junit.jupiter.params.provider.MethodSource; import reactor.core.publisher.Mono; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.io.buffer.DataBufferFactory; +import org.springframework.core.io.buffer.DataBufferUtils; +import org.springframework.core.io.buffer.DefaultDataBufferFactory; +import org.springframework.core.io.buffer.NettyDataBufferFactory; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.params.provider.Arguments.arguments; @@ -144,7 +148,7 @@ private static long getAllocations(List metrics) { @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @ParameterizedTest(name = "[{index}] {0}") - @MethodSource("org.springframework.core.io.buffer.AbstractDataBufferAllocatingTests#dataBufferFactories()") + @MethodSource("org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests#dataBufferFactories()") public @interface ParameterizedDataBufferAllocatingTest { } diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/AbstractLeakCheckingTests.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractLeakCheckingTests.java similarity index 92% rename from spring-core/src/test/java/org/springframework/core/io/buffer/AbstractLeakCheckingTests.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractLeakCheckingTests.java index 13c8207f1ec2..e6b5f3b425a9 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/AbstractLeakCheckingTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractLeakCheckingTests.java @@ -14,10 +14,12 @@ * limitations under the License. */ -package org.springframework.core.io.buffer; +package org.springframework.core.test.fixtures.io.buffer; import org.junit.jupiter.api.AfterEach; +import org.springframework.core.io.buffer.DataBufferFactory; + /** * Abstract base class for unit tests that allocate data buffers via a {@link DataBufferFactory}. * After each unit test, this base class checks whether all created buffers have been released, @@ -32,7 +34,6 @@ public abstract class AbstractLeakCheckingTests { /** * The data buffer factory. */ - @SuppressWarnings("ProtectedField") protected final LeakAwareDataBufferFactory bufferFactory = new LeakAwareDataBufferFactory(); /** diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtils.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/DataBufferTestUtils.java similarity index 97% rename from spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtils.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/DataBufferTestUtils.java index dc331d73144c..d66fca194798 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtils.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/DataBufferTestUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.io.buffer.support; +package org.springframework.core.test.fixtures.io.buffer; import java.nio.charset.Charset; diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBuffer.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBuffer.java similarity index 92% rename from spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBuffer.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBuffer.java index 80879f82eb46..cb42a0468e44 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBuffer.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBuffer.java @@ -14,8 +14,11 @@ * limitations under the License. */ -package org.springframework.core.io.buffer; +package org.springframework.core.test.fixtures.io.buffer; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.io.buffer.DataBufferWrapper; +import org.springframework.core.io.buffer.PooledDataBuffer; import org.springframework.util.Assert; /** diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactory.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBufferFactory.java similarity index 93% rename from spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactory.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBufferFactory.java index 4769e3a23aa6..e3c8dced702a 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactory.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBufferFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.io.buffer; +package org.springframework.core.test.fixtures.io.buffer; import java.nio.ByteBuffer; import java.time.Duration; @@ -28,6 +28,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.io.buffer.DataBufferFactory; +import org.springframework.core.io.buffer.DefaultDataBufferFactory; +import org.springframework.core.io.buffer.NettyDataBufferFactory; import org.springframework.util.Assert; /** diff --git a/spring-core/src/test/java/org/springframework/stereotype/Component.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Component.java similarity index 84% rename from spring-core/src/test/java/org/springframework/stereotype/Component.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Component.java index 16dc18dcd678..04bf3e0fc7eb 100644 --- a/spring-core/src/test/java/org/springframework/stereotype/Component.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Component.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.stereotype; +package org.springframework.core.test.fixtures.stereotype; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -23,9 +23,7 @@ import java.lang.annotation.Target; /** - * Indicates that an annotated class is a "component". - * Such classes are considered as candidates for auto-detection - * when using annotation-based configuration and classpath scanning. + * Copy of the standard {@code Component} annotation for testing purposes. * * @author Mark Fisher * @since 2.5 diff --git a/spring-core/src/test/java/org/springframework/stereotype/Indexed.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Indexed.java similarity index 94% rename from spring-core/src/test/java/org/springframework/stereotype/Indexed.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Indexed.java index 63502acaf807..2da265f6cb77 100644 --- a/spring-core/src/test/java/org/springframework/stereotype/Indexed.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Indexed.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.stereotype; +package org.springframework.core.test.fixtures.stereotype; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-core/src/test/java/org/springframework/tests/XmlContent.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContent.java similarity index 94% rename from spring-core/src/test/java/org/springframework/tests/XmlContent.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContent.java index df4342a68ed0..becbae6d2c78 100644 --- a/spring-core/src/test/java/org/springframework/tests/XmlContent.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests; +package org.springframework.core.test.fixtures.xml; import java.io.StringWriter; @@ -29,7 +29,7 @@ */ public class XmlContent implements AssertProvider { - private Object source; + private final Object source; private XmlContent(Object source) { this.source = source; diff --git a/spring-core/src/test/java/org/springframework/tests/XmlContentAssert.java b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContentAssert.java similarity index 77% rename from spring-core/src/test/java/org/springframework/tests/XmlContentAssert.java rename to spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContentAssert.java index b598f5f36349..c76d1cb3a5ce 100644 --- a/spring-core/src/test/java/org/springframework/tests/XmlContentAssert.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContentAssert.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests; +package org.springframework.core.test.fixtures.xml; import org.assertj.core.api.AbstractAssert; import org.w3c.dom.Node; @@ -35,30 +35,30 @@ public class XmlContentAssert extends AbstractAssert { } public XmlContentAssert isSimilarTo(Object control) { - XmlAssert.assertThat(actual).and(control).areSimilar(); + XmlAssert.assertThat(super.actual).and(control).areSimilar(); return this; } public XmlContentAssert isSimilarTo(Object control, Predicate nodeFilter) { - XmlAssert.assertThat(actual).and(control).withNodeFilter(nodeFilter).areSimilar(); + XmlAssert.assertThat(super.actual).and(control).withNodeFilter(nodeFilter).areSimilar(); return this; } public XmlContentAssert isSimilarTo(String control, DifferenceEvaluator differenceEvaluator) { - XmlAssert.assertThat(actual).and(control).withDifferenceEvaluator( + XmlAssert.assertThat(super.actual).and(control).withDifferenceEvaluator( differenceEvaluator).areSimilar(); return this; } public XmlContentAssert isSimilarToIgnoringWhitespace(Object control) { - XmlAssert.assertThat(actual).and(control).ignoreWhitespace().areSimilar(); + XmlAssert.assertThat(super.actual).and(control).ignoreWhitespace().areSimilar(); return this; } public XmlContentAssert isSimilarToIgnoringWhitespace(String control, NodeMatcher nodeMatcher) { - XmlAssert.assertThat(actual).and(control).ignoreWhitespace().withNodeMatcher(nodeMatcher).areSimilar(); + XmlAssert.assertThat(super.actual).and(control).ignoreWhitespace().withNodeMatcher(nodeMatcher).areSimilar(); return this; } diff --git a/spring-expression/spring-expression.gradle b/spring-expression/spring-expression.gradle index 432179877a9d..9f8299d4db90 100644 --- a/spring-expression/spring-expression.gradle +++ b/spring-expression/spring-expression.gradle @@ -4,6 +4,7 @@ apply plugin: "kotlin" dependencies { compile(project(":spring-core")) + testCompile(testFixtures(project(":spring-core"))) testCompile("org.jetbrains.kotlin:kotlin-reflect") testCompile("org.jetbrains.kotlin:kotlin-stdlib") } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java index 5673cc1d3f2c..a18114da24d6 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java @@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.expression.AccessException; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; @@ -29,11 +30,10 @@ import org.springframework.expression.TypedValue; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; -import org.springframework.tests.EnabledForTestGroups; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * Testing variations on map access. diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java index 7db14d0e0112..b1cbb7f0aa6b 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java @@ -18,15 +18,15 @@ import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser; -import org.springframework.tests.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; ///CLOVER:OFF diff --git a/spring-jdbc/spring-jdbc.gradle b/spring-jdbc/spring-jdbc.gradle index 78e5cced8950..3dc083492fc9 100644 --- a/spring-jdbc/spring-jdbc.gradle +++ b/spring-jdbc/spring-jdbc.gradle @@ -14,4 +14,5 @@ dependencies { optional("org.apache.derby:derbyclient") optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") + testCompile(testFixtures(project(":spring-core"))) } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java index 25b4a13d2dc9..ad5e78c6cf93 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java @@ -29,17 +29,17 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.io.ClassPathResource; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.jdbc.BadSqlGrammarException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.AbstractDriverBasedDataSource; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean; import org.springframework.jdbc.datasource.init.DataSourceInitializer; -import org.springframework.tests.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.springframework.core.test.fixtures.TestGroup.LONG_RUNNING; import static org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.DEFAULT_DATABASE_NAME; -import static org.springframework.tests.TestGroup.LONG_RUNNING; /** * @author Dave Syer diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java index d1cf8f5c8fec..919f4b17dabc 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java @@ -30,9 +30,9 @@ import org.junit.jupiter.api.Test; import org.mockito.InOrder; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.jdbc.UncategorizedSQLException; -import org.springframework.tests.EnabledForTestGroups; import org.springframework.transaction.CannotCreateTransactionException; import org.springframework.transaction.IllegalTransactionStateException; import org.springframework.transaction.PlatformTransactionManager; @@ -58,7 +58,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * @author Juergen Hoeller diff --git a/spring-messaging/spring-messaging.gradle b/spring-messaging/spring-messaging.gradle index 66ddd442ebd2..a2851000418a 100644 --- a/spring-messaging/spring-messaging.gradle +++ b/spring-messaging/spring-messaging.gradle @@ -16,6 +16,8 @@ dependencies { optional("com.google.protobuf:protobuf-java-util") optional("org.jetbrains.kotlinx:kotlinx-coroutines-core") optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") + testCompile(project(":kotlin-coroutines")) + testCompile(testFixtures(project(":spring-core"))) testCompile("javax.inject:javax.inject-tck") testCompile("javax.servlet:javax.servlet-api") testCompile("javax.validation:validation-api") @@ -29,7 +31,6 @@ dependencies { testCompile("org.jetbrains.kotlin:kotlin-stdlib") testCompile("org.xmlunit:xmlunit-assertj") testCompile("org.xmlunit:xmlunit-matchers") - testCompile(project(":kotlin-coroutines")) testRuntime("com.sun.xml.bind:jaxb-core") testRuntime("com.sun.xml.bind:jaxb-impl") testRuntime("com.sun.activation:javax.activation") diff --git a/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java b/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java index eb1e3278cbb1..088a53804c4e 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.util.SerializationTestUtils; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java index 9fb9b0b5aa96..8f256aa50776 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java @@ -25,10 +25,10 @@ import org.junit.jupiter.api.Test; import org.xmlunit.diff.DifferenceEvaluator; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.messaging.Message; import org.springframework.messaging.support.MessageBuilder; import org.springframework.oxm.jaxb.Jaxb2Marshaller; -import org.springframework.tests.XmlContent; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestEncoderMethodReturnValueHandler.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestEncoderMethodReturnValueHandler.java index 74087f82e130..ed40c25a9dd4 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestEncoderMethodReturnValueHandler.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestEncoderMethodReturnValueHandler.java @@ -24,7 +24,7 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.codec.Encoder; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.messaging.Message; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/LeakAwareNettyDataBufferFactory.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/LeakAwareNettyDataBufferFactory.java index 321ff4e38453..762ba52151b3 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/LeakAwareNettyDataBufferFactory.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/LeakAwareNettyDataBufferFactory.java @@ -31,7 +31,7 @@ import org.springframework.util.ObjectUtils; /** - * Unlike {@link org.springframework.core.io.buffer.LeakAwareDataBufferFactory} + * Unlike {@link org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory} * this one is an instance of {@link NettyDataBufferFactory} which is necessary * since {@link PayloadUtils} does instanceof checks, and that also allows * intercepting {@link NettyDataBufferFactory#wrap(ByteBuf)}. diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java index a1ca77d15dda..23d73df77aba 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java @@ -33,7 +33,7 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.core.io.buffer.NettyDataBuffer; import org.springframework.core.io.buffer.NettyDataBufferFactory; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java index 904032a29dad..f368ce745779 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java @@ -30,7 +30,7 @@ import org.springframework.core.io.buffer.DefaultDataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.core.io.buffer.NettyDataBuffer; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java index 99a320340112..3d59175823a8 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java @@ -24,10 +24,10 @@ import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.util.MimeTypeUtils; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-orm/spring-orm.gradle b/spring-orm/spring-orm.gradle index 279b74437f92..7c213fbbc7b2 100644 --- a/spring-orm/spring-orm.gradle +++ b/spring-orm/spring-orm.gradle @@ -11,6 +11,7 @@ dependencies { optional("org.eclipse.persistence:org.eclipse.persistence.jpa") optional("org.hibernate:hibernate-core") optional("javax.servlet:javax.servlet-api:3.1.0") + testCompile(testFixtures(project(":spring-core"))) testCompile("org.aspectj:aspectjweaver") testCompile("org.hsqldb:hsqldb") testRuntime("javax.xml.bind:jaxb-api") diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java index 3212318ec791..51ffa961aa32 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java @@ -26,9 +26,9 @@ import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.orm.jpa.domain.DriversLicense; import org.springframework.orm.jpa.domain.Person; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java index 6cbbdab3c001..23fb944acef9 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java @@ -32,13 +32,13 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.dao.DataAccessException; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver; import org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.interceptor.DefaultTransactionAttribute; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java index cee641e864c1..3be9625da31d 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java @@ -37,6 +37,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.support.GenericApplicationContext; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.orm.jpa.AbstractEntityManagerFactoryBeanTests; import org.springframework.orm.jpa.DefaultJpaDialect; @@ -46,7 +47,6 @@ import org.springframework.tests.context.SimpleMapScope; import org.springframework.tests.mock.jndi.ExpectedLookupTemplate; import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-oxm/spring-oxm.gradle b/spring-oxm/spring-oxm.gradle index 3b31d45b5d89..0c8a0af2442d 100644 --- a/spring-oxm/spring-oxm.gradle +++ b/spring-oxm/spring-oxm.gradle @@ -62,6 +62,7 @@ dependencies { optional("com.thoughtworks.xstream:xstream") optional("org.jibx:jibx-run") testCompile(project(":spring-context")) + testCompile(testFixtures(project(":spring-core"))) testCompile("org.ogce:xpp3") testCompile("org.codehaus.jettison:jettison") { exclude group: "stax", module: "stax-api" diff --git a/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java index e588e74dbc63..6dd6a91f1f76 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java @@ -36,7 +36,7 @@ import org.w3c.dom.Element; import org.w3c.dom.Text; -import org.springframework.tests.XmlContent; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.util.xml.StaxUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java index 59ab3c439368..2dc7d4336109 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java @@ -46,6 +46,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.oxm.AbstractMarshallerTests; import org.springframework.oxm.UncategorizedMappingException; import org.springframework.oxm.XmlMappingException; @@ -53,7 +54,6 @@ import org.springframework.oxm.jaxb.test.Flights; import org.springframework.oxm.jaxb.test.ObjectFactory; import org.springframework.oxm.mime.MimeContainer; -import org.springframework.tests.XmlContent; import org.springframework.util.FileCopyUtils; import org.springframework.util.ReflectionUtils; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java index 88a0ee8154d2..6a904c2dd7d3 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java @@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledOnJre; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.oxm.AbstractMarshallerTests; -import org.springframework.tests.XmlContent; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java index e3321c2e88d3..c57a30455478 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java @@ -56,7 +56,7 @@ import org.xmlunit.builder.Input; import org.xmlunit.xpath.JAXPXPathEngine; -import org.springframework.tests.XmlContent; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.util.xml.StaxUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/spring-test.gradle b/spring-test/spring-test.gradle index 894a06344f48..0b66f51e2779 100644 --- a/spring-test/spring-test.gradle +++ b/spring-test/spring-test.gradle @@ -42,6 +42,7 @@ dependencies { optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") testCompile(project(":spring-context-support")) testCompile(project(":spring-oxm")) + testCompile(testFixtures(project(":spring-core"))) testCompile("javax.annotation:javax.annotation-api") testCompile("javax.cache:cache-api") testCompile("javax.ejb:javax.ejb-api") diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java index af170e251145..5075ccd9f6e3 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java @@ -24,6 +24,7 @@ import org.junit.Test; import org.junit.experimental.ParallelComputer; +import org.springframework.core.test.fixtures.TestGroup; import org.springframework.test.context.junit4.InheritedConfigSpringJUnit4ClassRunnerAppCtxTests; import org.springframework.test.context.junit4.MethodLevelTransactionalSpringRunnerTests; import org.springframework.test.context.junit4.SpringJUnit47ClassRunnerRuleTests; @@ -34,7 +35,6 @@ import org.springframework.test.context.junit4.rules.BasicAnnotationConfigWacSpringRuleTests; import org.springframework.test.context.junit4.rules.SpringClassRule; import org.springframework.test.context.junit4.rules.SpringMethodRule; -import org.springframework.tests.TestGroup; import org.springframework.util.ReflectionUtils; import static org.junit.Assume.assumeTrue; diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java index 83a2e4c251bc..08c0948f33ee 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java @@ -28,7 +28,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpCookie; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java index cc5911e788f9..c5fae22e8844 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java @@ -32,17 +32,17 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.stereotype.Controller; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.tests.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * Unit and integration tests for {@link DelegatingWebConnection}. diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java index da4918121d21..981e25d01a4a 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java @@ -30,10 +30,10 @@ import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Configuration; +import org.springframework.core.test.fixtures.TestGroup; import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.tests.TestGroup; import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PostMapping; diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java index 7e9513c6bff9..16670b908bdb 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java @@ -25,10 +25,10 @@ import org.openqa.selenium.htmlunit.HtmlUnitDriver; import org.springframework.context.annotation.Configuration; +import org.springframework.core.test.fixtures.TestGroup; import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.tests.TestGroup; import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/spring-tx/spring-tx.gradle b/spring-tx/spring-tx.gradle index aa2a6a3fa09e..c026fb2991b5 100644 --- a/spring-tx/spring-tx.gradle +++ b/spring-tx/spring-tx.gradle @@ -19,6 +19,7 @@ dependencies { optional("org.jetbrains.kotlin:kotlin-stdlib") optional("org.jetbrains.kotlinx:kotlinx-coroutines-core") optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") + testCompile(testFixtures(project(":spring-core"))) testCompile("org.aspectj:aspectjweaver") testCompile("org.codehaus.groovy:groovy") testCompile("org.eclipse.persistence:javax.persistence") diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java index a883fabc756c..62ecf10fd5ff 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java @@ -31,13 +31,13 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.interceptor.NoRollbackRuleAttribute; import org.springframework.transaction.interceptor.RollbackRuleAttribute; import org.springframework.transaction.interceptor.RuleBasedTransactionAttribute; import org.springframework.transaction.interceptor.TransactionAttribute; import org.springframework.transaction.interceptor.TransactionInterceptor; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java b/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java index e172b7d7e8dc..114348dcbcb7 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java @@ -27,9 +27,9 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java index 213a591cf22d..dc4d69b840b5 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.util.SerializationTestUtils; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; /** * @author Rod Johnson diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java index bc138e813cee..5eb598d6688d 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java @@ -24,13 +24,13 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionException; import org.springframework.transaction.TransactionManager; import org.springframework.transaction.TransactionStatus; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java index 978dc018d549..6e63dbbde83e 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java @@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.mock.jndi.SimpleNamingContextBuilder; import org.springframework.transaction.jta.JtaTransactionManager; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-web/spring-web.gradle b/spring-web/spring-web.gradle index 6784d44483b3..d8ee7176679f 100644 --- a/spring-web/spring-web.gradle +++ b/spring-web/spring-web.gradle @@ -54,6 +54,7 @@ dependencies { optional("org.codehaus.groovy:groovy") optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") + testCompile(testFixtures(project(":spring-core"))) testCompile("io.projectreactor:reactor-test") testCompile("org.apache.taglibs:taglibs-standard-jstlel") testCompile("com.fasterxml.jackson.datatype:jackson-datatype-jdk8") diff --git a/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java b/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java index 9b50f64516fa..22a30a2af022 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java @@ -33,7 +33,7 @@ import org.springframework.core.codec.CharSequenceEncoder; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; -import org.springframework.core.io.buffer.LeakAwareDataBufferFactory; +import org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpOutputMessage; diff --git a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java index b75f0d819569..26bdaaa5b2f7 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java @@ -27,8 +27,8 @@ import reactor.test.StepVerifier; import org.springframework.core.ResolvableType; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java index 595444ac73d9..152a3eb31cd5 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java @@ -25,10 +25,10 @@ import reactor.test.StepVerifier; import org.springframework.core.ResolvableType; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; diff --git a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java index fa13b1c07479..b213758b4b7e 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java @@ -26,8 +26,8 @@ import reactor.test.StepVerifier; import org.springframework.core.ResolvableType; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; import org.springframework.http.MediaType; import org.springframework.http.codec.json.Jackson2JsonDecoder; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java index 68cf59d39c10..8e9bc7070869 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java @@ -29,10 +29,10 @@ import reactor.test.StepVerifier; import org.springframework.core.ResolvableType; -import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTests; import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.MediaType; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java index a3bc2974820b..4cfe5cb3868b 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java @@ -25,8 +25,8 @@ import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; -import org.springframework.core.codec.AbstractDecoderTests; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; import org.springframework.http.codec.Pojo; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.util.MimeType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java index 0241a13287d9..e1293d55883e 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java @@ -25,9 +25,9 @@ import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.codec.Pojo; import org.springframework.http.codec.ServerSentEvent; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java index 3d4ffb8b84df..6ec074bafb83 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java @@ -34,10 +34,10 @@ import reactor.test.StepVerifier; import org.springframework.core.ResolvableType; -import org.springframework.core.codec.AbstractDecoderTests; import org.springframework.core.codec.CodecException; import org.springframework.core.codec.DecodingException; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; import org.springframework.http.MediaType; import org.springframework.http.codec.Pojo; import org.springframework.http.codec.json.JacksonViewBean.MyJacksonView1; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java index 78083abba242..84a979c0fdc8 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java @@ -32,9 +32,9 @@ import reactor.test.StepVerifier; import org.springframework.core.ResolvableType; -import org.springframework.core.codec.AbstractEncoderTests; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; +import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; import org.springframework.http.MediaType; import org.springframework.http.codec.Pojo; import org.springframework.http.codec.ServerSentEvent; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java index ffb301459eb5..13a8326fd7c9 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java @@ -25,8 +25,8 @@ import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; -import org.springframework.core.codec.AbstractDecoderTests; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; import org.springframework.http.codec.Pojo; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.util.MimeType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java index 8890c7e93739..3fdffe872e5d 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java @@ -28,9 +28,9 @@ import reactor.core.publisher.Mono; import org.springframework.core.ResolvableType; -import org.springframework.core.codec.AbstractEncoderTests; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.codec.Pojo; import org.springframework.http.codec.ServerSentEvent; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java index 6f829a056ec2..20dc4d994b51 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java @@ -33,9 +33,9 @@ import reactor.test.StepVerifier; import org.springframework.core.codec.DecodingException; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferLimitException; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; diff --git a/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java index d1ef5e26f024..87e1f3300dce 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java @@ -32,10 +32,10 @@ import org.springframework.core.codec.StringDecoder; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBufferFactory; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; import org.springframework.http.HttpEntity; import org.springframework.http.MediaType; import org.springframework.http.client.MultipartBodyBuilder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java index 8c09becc4395..b2fb11b3c77c 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java @@ -34,10 +34,10 @@ import org.springframework.core.ResolvableType; import org.springframework.core.codec.DecodingException; import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.client.MultipartBodyBuilder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java index 20b4e490518d..1d3c367ce027 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java @@ -26,10 +26,10 @@ import reactor.test.StepVerifier; import org.springframework.core.ResolvableType; -import org.springframework.core.codec.AbstractDecoderTests; import org.springframework.core.codec.DecodingException; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; +import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; import org.springframework.http.MediaType; import org.springframework.protobuf.Msg; import org.springframework.protobuf.SecondMsg; diff --git a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java index 8bbe558118d8..f0bfbd15a70a 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java @@ -25,9 +25,9 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import org.springframework.core.codec.AbstractEncoderTests; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; +import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; import org.springframework.http.MediaType; import org.springframework.protobuf.Msg; import org.springframework.protobuf.SecondMsg; diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java index 7e969c18ee44..9bc7894d1a08 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java @@ -29,8 +29,8 @@ import reactor.test.StepVerifier; import org.springframework.core.ResolvableType; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; import org.springframework.http.MediaType; import org.springframework.http.codec.Pojo; import org.springframework.http.codec.xml.jaxb.XmlRootElement; diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java index 89def2af9e22..6522f57bf0fe 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java @@ -29,11 +29,11 @@ import reactor.core.publisher.Mono; import org.springframework.core.ResolvableType; -import org.springframework.core.codec.AbstractEncoderTests; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.http.MediaType; import org.springframework.http.codec.Pojo; -import org.springframework.tests.XmlContent; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java index eb1a7b389100..3bd9b8ff50a4 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java @@ -26,9 +26,9 @@ import reactor.core.publisher.Mono; import reactor.test.StepVerifier; -import org.springframework.core.io.buffer.AbstractLeakCheckingTests; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferLimitException; +import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java index 1b057e584aec..4f733570186e 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java @@ -31,10 +31,10 @@ import org.xmlunit.diff.ElementSelectors; import org.xmlunit.diff.NodeMatcher; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; import org.springframework.http.MockHttpOutputMessage; -import org.springframework.tests.XmlContent; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java index 928c2cb9e1f1..cea67dac4111 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java @@ -27,10 +27,10 @@ import com.rometools.rome.feed.rss.Item; import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; import org.springframework.http.MockHttpOutputMessage; -import org.springframework.tests.XmlContent; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java index 49c69b616a62..277eb3291faf 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java @@ -36,11 +36,11 @@ import org.springframework.aop.framework.DefaultAopProxyFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; import org.springframework.http.MockHttpOutputMessage; import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.tests.XmlContent; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java index 38bc72c0c3b6..53ccbb62f9e3 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java @@ -41,11 +41,11 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; import org.springframework.http.MockHttpOutputMessage; import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.tests.XmlContent; import org.springframework.util.FileCopyUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java index 6c5918a13cde..24d14c548f4a 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java @@ -35,7 +35,7 @@ import reactor.test.StepVerifier; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.io.buffer.LeakAwareDataBufferFactory; +import org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java index b34104c7c1cf..83ccd8b089e1 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java @@ -23,8 +23,8 @@ import reactor.core.publisher.Flux; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.io.buffer.LeakAwareDataBufferFactory; import org.springframework.core.io.buffer.NettyDataBufferFactory; +import org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory; import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java index 8472653a7175..f459f4f04aa8 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java @@ -18,13 +18,13 @@ import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.tests.EnabledForTestGroups; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * @author Juergen Hoeller diff --git a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java index 9d296bbe642c..25c0898ed875 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java @@ -29,11 +29,11 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.ClassPathResource; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpSession; import org.springframework.tests.sample.beans.DerivedTestBean; import org.springframework.tests.sample.beans.TestBean; -import org.springframework.util.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/spring-webflux.gradle b/spring-webflux/spring-webflux.gradle index e056a47f283b..900d53484b4b 100644 --- a/spring-webflux/spring-webflux.gradle +++ b/spring-webflux/spring-webflux.gradle @@ -30,6 +30,8 @@ dependencies { optional("com.google.protobuf:protobuf-java-util") optional("org.jetbrains.kotlinx:kotlinx-coroutines-core") optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") + testCompile(project(":kotlin-coroutines")) + testCompile(testFixtures(project(":spring-core"))) testCompile("javax.xml.bind:jaxb-api") testCompile("com.fasterxml:aalto-xml") testCompile("org.hibernate:hibernate-validator") @@ -44,7 +46,6 @@ dependencies { testCompile("org.eclipse.jetty:jetty-reactive-httpclient") testCompile("org.junit.platform:junit-platform-launcher") testCompile("com.squareup.okhttp3:mockwebserver") - testCompile(project(":kotlin-coroutines")) testCompile("org.jetbrains.kotlin:kotlin-script-runtime") testRuntime("org.jetbrains.kotlin:kotlin-scripting-jsr223-embeddable") testRuntime("org.jruby:jruby") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java index 5c7dae213d58..dec3055660d1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java @@ -28,7 +28,7 @@ import org.springframework.cache.concurrent.ConcurrentMapCache; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.CacheControl; import org.springframework.http.server.PathContainer; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java index edcdb983ee52..2a37cf847811 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java @@ -45,7 +45,7 @@ import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpMethod; import org.springframework.http.HttpRange; import org.springframework.http.ReactiveHttpOutputMessage; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java index b6b6e42182c5..64e016e55ec8 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java @@ -27,7 +27,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java index 758d8f625a52..a2e80fe64037 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java @@ -32,9 +32,9 @@ import reactor.test.StepVerifier; import org.springframework.core.ParameterizedTypeReference; -import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTests; import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.NettyDataBufferFactory; +import org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java index 83821b2d0255..838a11cca3ac 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java @@ -39,7 +39,7 @@ import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.CacheControl; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java index b695cc9ae6c0..5da68b75be63 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java @@ -54,7 +54,7 @@ import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.io.buffer.support.DataBufferTestUtils.dumpString; +import static org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils.dumpString; import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.web.method.ResolvableMethod.on; import static org.springframework.web.reactive.HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java index 26019f40b9f8..d55746f8381e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java @@ -33,7 +33,7 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.client.MultipartBodyBuilder; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java index 7a302b6ab4da..58c90779e1f1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java @@ -40,7 +40,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.codec.ByteBufferEncoder; import org.springframework.core.codec.CharSequenceEncoder; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java index 87803b6a7036..acee2437d10d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java @@ -29,7 +29,7 @@ import org.springframework.core.codec.CharSequenceEncoder; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.MediaType; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.codec.xml.Jaxb2XmlEncoder; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java index af52ff8b444e..b461aaaa076e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java @@ -38,7 +38,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.core.io.buffer.support.DataBufferTestUtils; +import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.server.reactive.ServerHttpResponse; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ZeroDemandResponse.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ZeroDemandResponse.java index e75fcdf783a1..d7e150bac8df 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ZeroDemandResponse.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ZeroDemandResponse.java @@ -24,7 +24,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; -import org.springframework.core.io.buffer.LeakAwareDataBufferFactory; +import org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseCookie; diff --git a/spring-webmvc/spring-webmvc.gradle b/spring-webmvc/spring-webmvc.gradle index 8951a318f8d9..f118436eb7d8 100644 --- a/spring-webmvc/spring-webmvc.gradle +++ b/spring-webmvc/spring-webmvc.gradle @@ -35,6 +35,7 @@ dependencies { optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") optional("org.reactivestreams:reactive-streams") + testCompile(testFixtures(project(":spring-core"))) testCompile("javax.servlet:javax.servlet-api") testCompile("org.eclipse.jetty:jetty-servlet") { exclude group: "javax.servlet", module: "javax.servlet" diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java index 4fa838cfd3ef..22486a37426c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java @@ -35,7 +35,6 @@ import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.DummyEnvironment; import org.springframework.http.HttpHeaders; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-core/src/test/java/org/springframework/core/env/DummyEnvironment.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/DummyEnvironment.java similarity index 88% rename from spring-core/src/test/java/org/springframework/core/env/DummyEnvironment.java rename to spring-webmvc/src/test/java/org/springframework/web/servlet/DummyEnvironment.java index bc1cd17899a7..a4f4343b3676 100644 --- a/spring-core/src/test/java/org/springframework/core/env/DummyEnvironment.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/DummyEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -14,9 +14,12 @@ * limitations under the License. */ -package org.springframework.core.env; +package org.springframework.web.servlet; -public class DummyEnvironment implements Environment { +import org.springframework.core.env.Environment; +import org.springframework.core.env.Profiles; + +class DummyEnvironment implements Environment { @Override public boolean containsProperty(String key) { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index 565f785d296f..bbcd9379f55f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -74,6 +74,7 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.core.MethodParameter; import org.springframework.core.convert.converter.Converter; +import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.format.support.FormattingConversionServiceFactoryBean; @@ -110,7 +111,6 @@ import org.springframework.ui.ModelMap; import org.springframework.util.Assert; import org.springframework.util.MultiValueMap; -import org.springframework.util.SerializationTestUtils; import org.springframework.util.StringUtils; import org.springframework.validation.BindingResult; import org.springframework.validation.Errors; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java index 38f8772e727b..f8b7bc7c5356 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java @@ -29,9 +29,9 @@ import com.rometools.rome.feed.atom.Feed; import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.tests.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java index a70d0d5d451a..bc4a2ac49f33 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java @@ -29,9 +29,9 @@ import com.rometools.rome.feed.rss.Item; import org.junit.jupiter.api.Test; +import org.springframework.core.test.fixtures.xml.XmlContent; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.tests.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-websocket/spring-websocket.gradle b/spring-websocket/spring-websocket.gradle index 96355eef5369..614f3c401755 100644 --- a/spring-websocket/spring-websocket.gradle +++ b/spring-websocket/spring-websocket.gradle @@ -21,6 +21,7 @@ dependencies { optional("io.undertow:undertow-servlet") optional("io.undertow:undertow-websockets-jsr") optional("com.fasterxml.jackson.core:jackson-databind") + testCompile(testFixtures(project(":spring-core"))) testCompile("org.apache.tomcat.embed:tomcat-embed-core") testCompile("org.apache.tomcat.embed:tomcat-embed-websocket") testCompile("io.projectreactor.netty:reactor-netty") diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java index bb78d3fa2e96..8af8d83e3d05 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java @@ -49,10 +49,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.http.HttpHeaders; import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; -import org.springframework.tests.EnabledForTestGroups; import org.springframework.util.concurrent.ListenableFutureCallback; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.socket.TextMessage; @@ -69,7 +69,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import static org.springframework.tests.TestGroup.PERFORMANCE; +import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; /** * Abstract base class for integration tests using the diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index 2726dce25761..1c8fbe7218a5 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -3,9 +3,9 @@ - - - + + + @@ -25,7 +25,7 @@ - + From 61d4ee594d38b2b6e793c4ae21e036a6d5ad8d86 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 28 Dec 2019 17:13:39 +0100 Subject: [PATCH 0242/2315] Use Gradle test fixture support for spring-beans and spring-context See gh-23550 --- .../build/testsources/TestSourcesPlugin.java | 2 +- integration-tests/integration-tests.gradle | 1 + ...NamespaceHandlerScopeIntegrationTests.java | 4 +- ...visorAutoProxyCreatorIntegrationTests.java | 2 +- ...ceHandlerScopeIntegrationTests-context.xml | 8 +- ...toProxyCreatorIntegrationTests-context.xml | 10 +- spring-aop/spring-aop.gradle | 1 + .../AspectJExpressionPointcutTests.java | 26 +- .../BeanNamePointcutMatchingTests.java | 2 +- ...hodInvocationProceedingJoinPointTests.java | 4 +- .../TigerAspectJExpressionPointcutTests.java | 4 +- .../aspectj/TypePatternClassFilterTests.java | 28 +- .../AbstractAspectJAdvisorFactoryTests.java | 8 +- .../annotation/ArgumentBindingTests.java | 4 +- .../AspectJPointcutAdvisorTests.java | 2 +- .../AspectJNamespaceHandlerTests.java | 2 +- .../config/AopNamespaceHandlerEventTests.java | 2 +- .../aop/framework/AopProxyUtilsTests.java | 4 +- .../framework/IntroductionBenchmarkTests.java | 4 +- .../aop/framework/MethodInvocationTests.java | 2 +- .../aop/framework/ProxyFactoryTests.java | 6 +- .../ConcurrencyThrottleInterceptorTests.java | 6 +- .../ExposeBeanNameAdvisorsTests.java | 4 +- .../ExposeInvocationInterceptorTests.java | 4 +- .../AbstractRegexpMethodPointcutTests.java | 2 +- .../aop/support/AopUtilsTests.java | 2 +- .../aop/support/ClassFiltersTests.java | 4 +- .../aop/support/ClassUtilsTests.java | 2 +- .../aop/support/ComposablePointcutTests.java | 2 +- .../aop/support/ControlFlowPointcutTests.java | 4 +- ...elegatingIntroductionInterceptorTests.java | 12 +- .../aop/support/MethodMatchersTests.java | 6 +- .../support/NameMatchMethodPointcutTests.java | 4 +- .../aop/support/PointcutsTests.java | 2 +- ...MethodPointcutAdvisorIntegrationTests.java | 6 +- .../aop/support/RootClassFilterTests.java | 2 +- .../CommonsPool2TargetSourceProxyTests.java | 2 +- .../target/HotSwappableTargetSourceTests.java | 6 +- .../aop/target/LazyInitTargetSourceTests.java | 2 +- .../PrototypeBasedTargetSourceTests.java | 4 +- .../target/PrototypeTargetSourceTests.java | 2 +- .../target/ThreadLocalTargetSourceTests.java | 4 +- .../AopNamespaceHandlerEventTests-context.xml | 2 +- ...PointcutErrorTests-pointcutDuplication.xml | 2 +- ...dlerPointcutErrorTests-pointcutMissing.xml | 2 +- ...ointcutAdvisorIntegrationTests-context.xml | 10 +- ...onsPool2TargetSourceProxyTests-context.xml | 2 +- .../HotSwappableTargetSourceTests-context.xml | 4 +- ...LazyInitTargetSourceTests-customTarget.xml | 2 +- .../LazyInitTargetSourceTests-singleton.xml | 2 +- .../PrototypeTargetSourceTests-context.xml | 4 +- .../ThreadLocalTargetSourceTests-context.xml | 6 +- spring-aspects/spring-aspects.gradle | 1 + .../aspectj/AbstractCacheAnnotationTests.java | 882 ++++++++++++++++++ .../aspectj/AspectJCacheAnnotationTests.java | 1 - .../AspectJEnableCachingIsolatedTests.java | 12 +- .../aspectj/AspectJEnableCachingTests.java | 9 +- .../AnnotatedClassCacheableService.java | 4 + .../cache/config/CacheableService.java | 6 +- .../cache/config/DefaultCacheableService.java | 6 +- .../cache/config/SomeKeyGenerator.java | 22 - .../cache/config/TestEntity.java | 9 +- .../cache/config/annotation-cache-aspectj.xml | 4 +- spring-beans/spring-beans.gradle | 2 + .../beans/AbstractPropertyAccessorTests.java | 10 +- .../springframework/beans/BeanUtilsTests.java | 6 +- .../beans/BeanWrapperEnumTests.java | 4 +- .../beans/BeanWrapperGenericsTests.java | 8 +- .../beans/BeanWrapperTests.java | 2 +- .../CachedIntrospectionResultsTests.java | 4 +- .../beans/DirectFieldAccessorTests.java | 2 +- .../beans/ExtendedBeanInfoTests.java | 2 +- .../beans/factory/BeanFactoryUtilsTests.java | 12 +- .../DefaultListableBeanFactoryTests.java | 16 +- ...wiredAnnotationBeanPostProcessorTests.java | 8 +- ...njectAnnotationBeanPostProcessorTests.java | 8 +- .../annotation/LookupAnnotationTests.java | 2 +- .../config/CustomEditorConfigurerTests.java | 2 +- .../FieldRetrievingFactoryBeanTests.java | 4 +- .../config/PropertyPathFactoryBeanTests.java | 4 +- .../PropertyPlaceholderConfigurerTests.java | 2 +- .../PropertyResourceConfigurerTests.java | 4 +- .../factory/config/SimpleScopeTests.java | 2 +- .../parsing/CustomProblemReporterTests.java | 2 +- .../support/BeanDefinitionBuilderTests.java | 2 +- .../factory/support/BeanDefinitionTests.java | 2 +- .../support/BeanFactoryGenericsTests.java | 8 +- .../DefaultSingletonBeanRegistryTests.java | 4 +- ...DefinitionMetadataEqualsHashCodeTests.java | 2 +- .../factory/support/LookupMethodTests.java | 2 +- .../PropertiesBeanDefinitionReaderTests.java | 2 +- .../wiring/BeanConfigurerSupportTests.java | 2 +- .../xml/AutowireWithExclusionTests.java | 2 +- .../factory/xml/CollectionMergingTests.java | 2 +- .../xml/CollectionsWithDefaultTypesTests.java | 2 +- .../xml/ConstructorDependenciesBean.java | 4 +- .../beans/factory/xml/CountingFactory.java | 2 +- .../beans/factory/xml/DummyReferencer.java | 4 +- .../factory/xml/DuplicateBeanIdTests.java | 2 +- .../factory/xml/EventPublicationTests.java | 2 +- .../beans/factory/xml/FactoryMethodTests.java | 2 +- .../beans/factory/xml/FactoryMethods.java | 2 +- .../beans/factory/xml/InstanceFactory.java | 2 +- ...edBeansElementAttributeRecursionTests.java | 2 +- .../factory/xml/SchemaValidationTests.java | 2 +- ...impleConstructorNamespaceHandlerTests.java | 4 +- .../SimplePropertyNamespaceHandlerTests.java | 4 +- .../beans/factory/xml/TestBeanCreator.java | 2 +- .../xml/UtilNamespaceHandlerTests.java | 6 +- .../factory/xml/XmlBeanCollectionTests.java | 4 +- .../xml/XmlBeanDefinitionReaderTests.java | 2 +- .../xml/XmlListableBeanFactoryTests.java | 9 +- .../propertyeditors/CustomEditorTests.java | 14 +- .../beans/support/PagedListHolderTests.java | 2 +- .../annotation/KotlinAutowiredTests.kt | 4 +- .../factory/BeanFactoryUtilsTests-leaf.xml | 2 +- .../factory/BeanFactoryUtilsTests-middle.xml | 4 +- .../factory/BeanFactoryUtilsTests-root.xml | 12 +- ...ieldRetrievingFactoryBeanTests-context.xml | 2 +- .../PropertyPathFactoryBeanTests-context.xml | 18 +- .../config/SimpleScopeTests-context.xml | 2 +- .../CustomProblemReporterTests-context.xml | 9 +- .../factory/support/genericBeanTests.xml | 6 +- .../factory/support/lookupMethodTests.xml | 4 +- .../support/multiConstructorArgs.properties | 2 +- .../support/refConstructorArg.properties | 4 +- .../support/simpleConstructorArg.properties | 2 +- ...uplicateBeanIdTests-multiLevel-context.xml | 4 +- ...DuplicateBeanIdTests-sameLevel-context.xml | 4 +- ...tAttributeRecursionTests-merge-context.xml | 2 +- .../autowire-constructor-with-exclusion.xml | 4 +- .../factory/xml/autowire-with-exclusion.xml | 4 +- .../factory/xml/autowire-with-inclusion.xml | 4 +- .../xml/autowire-with-selective-inclusion.xml | 4 +- .../beans/factory/xml/beanEvents.xml | 8 +- .../beans/factory/xml/collectionMerging.xml | 28 +- .../beans/factory/xml/collections.xml | 54 +- .../xml/collectionsWithDefaultTypes.xml | 4 +- .../beans/factory/xml/factory-methods.xml | 4 +- .../beans/factory/xml/schemaValidated.xml | 10 +- ...simpleConstructorNamespaceHandlerTests.xml | 22 +- ...tructorNamespaceHandlerTestsWithErrors.xml | 2 +- .../simplePropertyNamespaceHandlerTests.xml | 10 +- ...ropertyNamespaceHandlerTestsWithErrors.xml | 4 +- .../beans/factory/xml/test.xml | 32 +- .../beans/factory/xml/testUtilNamespace.xml | 20 +- .../beans/factory/xml/validateWithDtd.xml | 2 +- .../beans/factory/xml/validateWithXsd.xml | 2 +- .../beans/factory/xml/withMeta.xml | 6 +- .../beans/test/fixtures}/beans/AgeHolder.java | 2 +- .../test/fixtures}/beans/AnnotatedBean.java | 2 +- .../test/fixtures}/beans/BooleanTestBean.java | 2 +- .../beans/CollectingReaderEventListener.java | 2 +- .../beans/test/fixtures}/beans/Colour.java | 2 +- .../fixtures}/beans/CountingTestBean.java | 2 +- .../test/fixtures}/beans/CustomEnum.java | 2 +- .../fixtures}/beans/DependenciesBean.java | 2 +- .../test/fixtures}/beans/DerivedTestBean.java | 2 +- .../beans/test/fixtures}/beans/DummyBean.java | 2 +- .../test/fixtures}/beans/DummyFactory.java | 2 +- .../beans/test/fixtures}/beans/Employee.java | 4 +- .../test/fixtures}/beans/GenericBean.java | 2 +- .../fixtures}/beans/GenericIntegerBean.java | 2 +- .../beans/GenericSetOfIntegerBean.java | 2 +- .../beans/test/fixtures}/beans/HasMap.java | 2 +- .../test/fixtures}/beans/INestedTestBean.java | 2 +- .../beans/test/fixtures}/beans/IOther.java | 2 +- .../beans/test/fixtures}/beans/ITestBean.java | 4 +- .../test/fixtures}/beans/IndexedTestBean.java | 2 +- .../test/fixtures}/beans/LifecycleBean.java | 2 +- .../fixtures}/beans/MustBeInitialized.java | 2 +- .../test/fixtures}/beans/NestedTestBean.java | 2 +- .../test/fixtures}/beans/NumberTestBean.java | 2 +- .../beans/PackageLevelVisibleBean.java | 2 +- .../beans/test/fixtures}/beans/Person.java | 2 +- .../beans/test/fixtures}/beans/Pet.java | 2 +- .../fixtures}/beans/SerializablePerson.java | 2 +- .../test/fixtures}/beans/SideEffectBean.java | 2 +- .../test/fixtures}/beans/TestAnnotation.java | 2 +- .../beans/test/fixtures}/beans/TestBean.java | 8 +- .../fixtures}/beans/factory/DummyFactory.java | 4 +- .../test/fixtures}/beans/package-info.java | 2 +- .../test/fixtures}/beans/subpkg/DeepBean.java | 8 +- .../factory/xml/AbstractBeanFactoryTests.java | 10 +- .../xml/AbstractListableBeanFactoryTests.java | 8 +- .../spring-context-support.gradle | 2 + .../cache/caffeine/CaffeineCacheTests.java | 2 +- .../cache/ehcache/EhCacheCacheTests.java | 2 +- .../jcache/JCacheEhCacheAnnotationTests.java | 10 +- .../cache/jcache/JCacheEhCacheApiTests.java | 2 +- .../jcache/config/JCacheJavaConfigTests.java | 2 +- .../scheduling/quartz/QuartzSupportTests.java | 2 +- .../BeanValidationPostProcessorTests.java | 2 +- spring-context/spring-context.gradle | 5 + .../aop/aspectj/AfterAdviceBindingTests.java | 4 +- .../AfterReturningAdviceBindingTests.java | 4 +- .../AfterThrowingAdviceBindingTests.java | 2 +- .../aop/aspectj/AroundAdviceBindingTests.java | 4 +- .../AspectAndAdvicePrecedenceTests.java | 2 +- ...AspectJExpressionPointcutAdvisorTests.java | 2 +- .../BeanNamePointcutAtAspectTests.java | 4 +- .../aop/aspectj/BeanNamePointcutTests.java | 2 +- .../aop/aspectj/BeforeAdviceBindingTests.java | 4 +- .../aop/aspectj/DeclareParentsTests.java | 2 +- ...licitJPArgumentMatchingAtAspectJTests.java | 10 +- .../AspectImplementingInterfaceTests.java | 2 +- ...xyCreatorAndLazyInitTargetSourceTests.java | 4 +- .../AspectJAutoProxyCreatorTests.java | 8 +- .../AtAspectJAfterThrowingTests.java | 4 +- .../autoproxy/benchmark/BenchmarkTests.java | 2 +- ...fterReturningGenericTypeMatchingTests.java | 4 +- ...NamespaceHandlerProxyTargetClassTests.java | 2 +- .../aop/config/AopNamespaceHandlerTests.java | 4 +- .../aop/framework/AbstractAopProxyTests.java | 10 +- .../aop/framework/CglibProxyTests.java | 4 +- .../aop/framework/JdkDynamicProxyTests.java | 6 +- .../aop/framework/ProxyFactoryBeanTests.java | 12 +- .../AdvisorAdapterRegistrationTests.java | 2 +- .../AdvisorAutoProxyCreatorTests.java | 4 +- .../autoproxy/AutoProxyCreatorTests.java | 8 +- .../BeanNameAutoProxyCreatorInitTests.java | 2 +- .../BeanNameAutoProxyCreatorTests.java | 4 +- .../aop/scope/ScopedProxyTests.java | 6 +- .../target/CommonsPool2TargetSourceTests.java | 6 +- .../LookupMethodWrappedByCglibProxyTests.java | 2 +- ...aceHandlerWithExpressionLanguageTests.java | 2 +- .../factory/xml/XmlBeanFactoryTestTypes.java | 8 +- .../factory/xml/XmlBeanFactoryTests.java | 12 +- .../support/CustomNamespaceHandlerTests.java | 4 +- .../cache/CacheReproTests.java | 2 +- .../concurrent/ConcurrentMapCacheTests.java | 2 +- .../AnnotationDrivenCacheConfigTests.java | 1 + .../AnnotationNamespaceDrivenTests.java | 1 + .../config/CacheAdviceNamespaceTests.java | 1 + .../cache/config/CustomInterceptorTests.java | 4 +- .../config/EnableCachingIntegrationTests.java | 6 +- .../cache/config/EnableCachingTests.java | 8 +- .../cache/config/SomeCustomKeyGenerator.java | 46 - .../CacheResolverCustomizationTests.java | 6 +- .../interceptor/CacheSyncFailureTests.java | 2 +- .../context/BeanThatBroadcasts.java | 37 - .../context/LifecycleContextBean.java | 2 +- .../springframework/context/TestListener.java | 42 - .../AbstractCircularImportDetectionTests.java | 2 +- .../AnnotationProcessorPerformanceTests.java | 4 +- .../ClassPathBeanDefinitionScannerTests.java | 2 +- ...PathFactoryBeanDefinitionScannerTests.java | 4 +- ...anningCandidateComponentProviderTests.java | 2 +- ...ommonAnnotationBeanPostProcessorTests.java | 10 +- ...mponentScanAnnotationIntegrationTests.java | 2 +- .../ComponentScanParserScopedProxyTests.java | 2 +- .../ConfigurationClassAndBFPPTests.java | 2 +- ...nClassPostConstructAndAutowiringTests.java | 2 +- .../ConfigurationClassPostProcessorTests.java | 4 +- .../FooServiceDependentConverter.java | 6 +- ...wiredAnnotationBeanPostProcessorTests.java | 2 +- .../context/annotation/MyTestBean.java | 4 +- .../NestedConfigurationClassTests.java | 2 +- .../PropertySourceAnnotationTests.java | 2 +- .../componentscan/level1/Level1Config.java | 2 +- .../componentscan/level2/Level2Config.java | 2 +- .../AutowiredConfigurationTests.java | 4 +- .../BeanMethodQualificationTests.java | 4 +- ...figurationClassAspectIntegrationTests.java | 6 +- .../ConfigurationClassProcessingTests.java | 6 +- ...assWithPlaceholderConfigurerBeanTests.java | 4 +- .../ConfigurationMetaAnnotationTests.java | 2 +- .../ImportAnnotationDetectionTests.java | 2 +- .../configuration/ImportResourceTests.java | 4 +- .../annotation/configuration/ImportTests.java | 4 +- ...tedConfigurationClassEnhancementTests.java | 2 +- .../configuration/ScopingTests.java | 4 +- .../annotation4/FactoryMethodComponent.java | 2 +- .../context/annotation4/SimpleBean.java | 2 +- .../annotation6/ConfigForScanning.java | 2 +- .../event/ApplicationContextEventTests.java | 6 +- .../EventPublicationInterceptorTests.java | 12 +- .../ApplicationContextExpressionTests.java | 2 +- .../EnvironmentAccessorIntegrationTests.java | 2 +- .../CandidateComponentsIndexLoaderTests.java | 1 + .../BeanFactoryPostProcessorTests.java | 2 +- ...rtyResourceConfigurerIntegrationTests.java | 2 +- ...ertySourcesPlaceholderConfigurerTests.java | 2 +- .../support/SimpleThreadScopeTests.java | 2 +- ...ticApplicationContextMulticasterTests.java | 8 +- .../StaticApplicationContextTests.java | 8 +- .../support/StaticMessageSourceTests.java | 10 +- .../config/JeeNamespaceHandlerEventTests.java | 2 +- .../ejb/config/JeeNamespaceHandlerTests.java | 4 +- .../jmx/export/MBeanExporterTests.java | 2 +- .../jndi/JndiObjectFactoryBeanTests.java | 10 +- .../jndi/JndiPropertySourceTests.java | 2 +- .../scripting/ContextScriptBean.java | 2 +- .../scripting/TestBeanAwareMessenger.java | 2 +- .../scripting/bsh/BshScriptFactoryTests.java | 2 +- .../groovy/GroovyScriptFactoryTests.java | 2 +- .../tests/context/TestMethodInvokingTask.java | 52 -- .../tests/mock/jndi/package-info.java | 9 - .../tests/sample/beans/FieldAccessBean.java | 2 + .../org/springframework/ui/ModelMapTests.java | 2 +- .../DataBinderFieldAccessTests.java | 2 +- .../validation/DataBinderTests.java | 20 +- .../DefaultMessageCodesResolverTests.java | 17 +- .../validation/ValidationUtilsTests.java | 2 +- .../BeanValidationPostProcessorTests.java | 2 +- .../java/test/aspect/TwoAdviceAspect.java | 4 +- .../aop/aspectj/AfterAdviceBindingTests.xml | 2 +- .../AfterReturningAdviceBindingTests.xml | 4 +- .../AfterThrowingAdviceBindingTests.xml | 2 +- .../aop/aspectj/AroundAdviceBindingTests.xml | 2 +- .../aop/aspectj/AroundAdviceCircularTests.xml | 4 +- .../AspectAndAdvicePrecedenceTests.xml | 2 +- .../AspectJExpressionPointcutAdvisorTests.xml | 4 +- .../aspectj/BeanNamePointcutAtAspectTests.xml | 6 +- .../aop/aspectj/BeanNamePointcutTests.xml | 12 +- .../aop/aspectj/BeforeAdviceBindingTests.xml | 2 +- .../aop/aspectj/DeclareParentsTests.xml | 4 +- ...plicitJPArgumentMatchingAtAspectJTests.xml | 2 +- .../ImplicitJPArgumentMatchingTests.xml | 4 +- .../OverloadedAdviceTests-ambiguous.xml | 2 +- .../aop/aspectj/OverloadedAdviceTests.xml | 2 +- ...pectImplementingInterfaceTests-context.xml | 2 +- .../AspectJAutoProxyCreatorTests-aspects.xml | 4 +- ...toProxyCreatorTests-aspectsPlusAdvisor.xml | 6 +- ...xyCreatorTests-aspectsWithAbstractBean.xml | 2 +- ...oProxyCreatorTests-aspectsWithOrdering.xml | 2 +- ...AspectJAutoProxyCreatorTests-pertarget.xml | 4 +- .../AspectJAutoProxyCreatorTests-perthis.xml | 2 +- ...JAutoProxyCreatorTests-twoAdviceAspect.xml | 2 +- ...yCreatorTests-twoAdviceAspectPrototype.xml | 2 +- ...yCreatorTests-twoAdviceAspectSingleton.xml | 2 +- ...pectJAutoProxyCreatorTests-usesInclude.xml | 2 +- ...oProxyCreatorTests-usesJoinPointAspect.xml | 2 +- .../AtAspectJAfterThrowingTests-context.xml | 2 +- .../benchmark/BenchmarkTests-aspectj.xml | 2 +- .../benchmark/BenchmarkTests-springAop.xml | 2 +- ...pNamespaceHandlerAdviceTypeTests-error.xml | 2 +- .../AopNamespaceHandlerAdviceTypeTests-ok.xml | 2 +- ...AopNamespaceHandlerArgNamesTests-error.xml | 2 +- .../AopNamespaceHandlerArgNamesTests-ok.xml | 2 +- ...ceHandlerProxyTargetClassTests-context.xml | 2 +- ...opNamespaceHandlerReturningTests-error.xml | 2 +- .../AopNamespaceHandlerReturningTests-ok.xml | 2 +- .../AopNamespaceHandlerTests-context.xml | 2 +- ...AopNamespaceHandlerThrowingTests-error.xml | 2 +- .../AopNamespaceHandlerThrowingTests-ok.xml | 2 +- .../config/PrototypeProxyTests-context.xml | 8 +- .../ProxyFactoryBeanTests-autowiring.xml | 2 +- .../ProxyFactoryBeanTests-context.xml | 26 +- ...xyFactoryBeanTests-double-targetsource.xml | 8 +- .../ProxyFactoryBeanTests-frozen.xml | 4 +- ...roxyFactoryBeanTests-inner-bean-target.xml | 2 +- .../ProxyFactoryBeanTests-invalid.xml | 4 +- ...yFactoryBeanTests-notlast-targetsource.xml | 4 +- .../ProxyFactoryBeanTests-prototype.xml | 4 +- .../ProxyFactoryBeanTests-serialization.xml | 10 +- .../ProxyFactoryBeanTests-targetsource.xml | 4 +- ...visorAdapterRegistrationTests-with-bpp.xml | 4 +- ...orAdapterRegistrationTests-without-bpp.xml | 4 +- ...oProxyCreatorTests-common-interceptors.xml | 4 +- ...oProxyCreatorTests-custom-targetsource.xml | 8 +- ...AdvisorAutoProxyCreatorTests-optimized.xml | 2 +- ...toProxyCreatorTests-quick-targetsource.xml | 10 +- ...nNameAutoProxyCreatorInitTests-context.xml | 2 +- .../BeanNameAutoProxyCreatorTests-context.xml | 16 +- .../aop/scope/ScopedProxyTests-list.xml | 2 +- .../aop/scope/ScopedProxyTests-override.xml | 2 +- .../aop/scope/ScopedProxyTests-testbean.xml | 2 +- .../CommonsPool2TargetSourceTests-context.xml | 4 +- ...MethodWrappedByCglibProxyTests-context.xml | 2 +- .../xml/XmlBeanFactoryTests-autowire.xml | 12 +- .../factory/xml/XmlBeanFactoryTests-child.xml | 6 +- .../xml/XmlBeanFactoryTests-collections.xml | 46 +- ...lBeanFactoryTests-complexFactoryCircle.xml | 8 +- .../XmlBeanFactoryTests-constructorArg.xml | 12 +- ...lBeanFactoryTests-constructorOverrides.xml | 2 +- .../XmlBeanFactoryTests-defaultAutowire.xml | 8 +- .../XmlBeanFactoryTests-defaultLazyInit.xml | 2 +- ...mlBeanFactoryTests-delegationOverrides.xml | 4 +- .../xml/XmlBeanFactoryTests-factoryCircle.xml | 2 +- .../xml/XmlBeanFactoryTests-initializers.xml | 2 +- .../xml/XmlBeanFactoryTests-invalid.xml | 2 +- ...toryTests-invalidOverridesNoSuchMethod.xml | 2 +- ...nFactoryTests-localCollectionsUsingXsd.xml | 2 +- .../xml/XmlBeanFactoryTests-overrides.xml | 16 +- .../xml/XmlBeanFactoryTests-parent.xml | 6 +- .../xml/XmlBeanFactoryTests-reftypes.xml | 80 +- ...toryTests-testWithDuplicateNameInAlias.xml | 4 +- ...eanFactoryTests-testWithDuplicateNames.xml | 4 +- ...paceHandlerWithExpressionLanguageTests.xml | 4 +- .../CustomNamespaceHandlerTests-context.xml | 8 +- .../config/annotationDrivenCacheConfig.xml | 8 +- .../config/annotationDrivenCacheNamespace.xml | 8 +- .../cache/config/cache-advice.xml | 8 +- ...ndiBeanFactoryLocatorTests-collections.xml | 46 +- ...textJndiBeanFactoryLocatorTests-parent.xml | 6 +- ...ortNonXmlResourceConfig-context.properties | 2 +- .../configuration/ImportXmlConfig-context.xml | 2 +- .../ImportXmlWithAopNamespace-context.xml | 2 +- .../support/simpleThreadScopeTests.xml | 18 +- .../context/support/testBeans.properties | 20 +- .../ejb/config/jeeNamespaceHandlerTests.xml | 14 +- .../export/propertyPlaceholderConfigurer.xml | 2 +- .../scripting/bsh/MessengerImpl.bsh | 2 +- .../scripting/bsh/bsh-with-xsd.xml | 2 +- .../scripting/groovy/ScriptBean.groovy | 2 +- .../groovy/groovy-multiple-properties.xml | 2 +- .../AbstractApplicationContextTests.java | 21 +- .../test/fixtures}/SimpleMapScope.java | 2 +- .../test/fixtures/beans}/ACATester.java | 11 +- .../fixtures/beans}/BeanThatBroadcasts.java | 7 +- .../test/fixtures/beans}/BeanThatListens.java | 7 +- .../beans/TestApplicationListener.java | 7 +- .../cache}/AbstractCacheAnnotationTests.java | 11 +- .../fixtures}/cache/AbstractCacheTests.java | 4 +- .../AbstractValueAdaptingCacheTests.java | 2 +- .../test/fixtures}/cache/CacheTestUtils.java | 4 +- .../cache}/SomeCustomKeyGenerator.java | 6 +- .../fixtures/cache}/SomeKeyGenerator.java | 2 +- .../AnnotatedClassCacheableService.java | 2 +- .../cache/beans}/CacheableService.java | 2 +- .../cache/beans}/DefaultCacheableService.java | 2 +- .../fixtures/cache/beans}/TestEntity.java | 2 +- .../CandidateComponentsTestClassLoader.java | 7 +- .../jndi/ExpectedLookupTemplate.java | 9 +- .../fixtures}/jndi/SimpleNamingContext.java | 11 +- .../jndi/SimpleNamingContextBuilder.java | 9 +- spring-jdbc/spring-jdbc.gradle | 1 + .../jdbc/core/RowMapperTests.java | 2 +- .../BeanPropertySqlParameterSourceTests.java | 2 +- .../JdbcBeanDefinitionReaderTests.java | 5 +- spring-jms/spring-jms.gradle | 1 + .../jms/config/JmsNamespaceHandlerTests.java | 2 +- .../jms/remoting/JmsInvokerTests.java | 4 +- .../jms/config/jmsNamespaceHandlerTests.xml | 4 +- spring-orm/spring-orm.gradle | 2 + .../orm/jpa/domain/Person.java | 2 +- .../DefaultPersistenceUnitManagerTests.java | 2 +- .../PersistenceXmlParsingTests.java | 2 +- .../support/PersistenceInjectionTests.java | 4 +- .../orm/jpa/domain/persistence-multi.xml | 2 +- spring-test/spring-test.gradle | 2 + .../mock}/jndi/SimpleNamingContextTests.java | 14 +- ...dingPropertiesAndInheritedLoaderTests.java | 2 +- ...ithPropertiesExtendingPropertiesTests.java | 2 +- .../ActiveProfilesInterfaceTests.java | 2 +- .../ContextConfigurationInterfaceTests.java | 2 +- .../ContextConfigurationTestInterface.java | 2 +- ...riptDetectionGroovySpringContextTests.java | 4 +- .../groovy/GroovyControlGroupTests.java | 4 +- .../groovy/GroovySpringContextTests.java | 4 +- .../MixedXmlAndGroovySpringContextTests.java | 4 +- ...TransactionalJUnit4SpringContextTests.java | 4 +- ...ltContextLoaderClassSpringRunnerTests.java | 2 +- ...ParameterizedDependencyInjectionTests.java | 4 +- ...sedSpringJUnit4ClassRunnerAppCtxTests.java | 2 +- .../SpringJUnit4ClassRunnerAppCtxTests.java | 4 +- ...ingDefaultConfigClassesInheritedTests.java | 2 +- .../DefaultConfigClassesBaseTests.java | 2 +- .../DefaultConfigClassesInheritedTests.java | 2 +- ...ingDefaultConfigClassesInheritedTests.java | 2 +- ...ltLoaderDefaultConfigClassesBaseTests.java | 2 +- ...derDefaultConfigClassesInheritedTests.java | 2 +- ...tLoaderExplicitConfigClassesBaseTests.java | 2 +- ...erExplicitConfigClassesInheritedTests.java | 2 +- .../ExplicitConfigClassesBaseTests.java | 2 +- .../ExplicitConfigClassesInheritedTests.java | 2 +- .../annotation/PojoAndStringConfig.java | 4 +- ...mDefaultsMetaConfigWithOverridesTests.java | 4 +- .../DefaultProfileAnnotationConfigTests.java | 4 +- .../annotation/DefaultProfileConfig.java | 2 +- .../profile/annotation/DevProfileConfig.java | 2 +- .../DefaultProfileAnnotationConfigTests.java | 4 +- .../importresource/DefaultProfileConfig.java | 2 +- .../xml/DefaultProfileXmlConfigTests.java | 4 +- .../rules/ParameterizedSpringRuleTests.java | 4 +- .../spr3896/DefaultLocationsBaseTests.java | 2 +- .../DefaultLocationsInheritedTests.java | 2 +- .../spr3896/ExplicitLocationsBaseTests.java | 2 +- .../ExplicitLocationsInheritedTests.java | 2 +- ...ransactionalAnnotatedConfigClassTests.java | 2 +- ...edConfigClassWithAtConfigurationTests.java | 2 +- ...figClassesWithoutAtConfigurationTests.java | 2 +- ...otationConfigTestNGSpringContextTests.java | 4 +- ...TransactionalTestNGSpringContextTests.java | 4 +- ...TransactionalTestNGSpringContextTests.java | 4 +- .../RequestAndSessionScopedBeansWacTests.java | 2 +- ...AndInheritedLoaderTests-context.properties | 2 +- ...xtendingPropertiesTests-context.properties | 2 +- ...tionGroovySpringContextTestsContext.groovy | 4 +- .../test/context/groovy/context.groovy | 4 +- .../test/context/groovy/contextB.xml | 4 +- ...tionalJUnit4SpringContextTests-context.xml | 4 +- ...gJUnit4ClassRunnerAppCtxTests-context1.xml | 2 +- ...gJUnit4ClassRunnerAppCtxTests-context2.xml | 2 +- ...erizedDependencyInjectionTests-context.xml | 6 +- ...4ClassRunnerAppCtxTests-context.properties | 2 +- ...ngJUnit4ClassRunnerAppCtxTests-context.xml | 4 +- .../junit4/profile/importresource/import.xml | 2 +- .../DefaultProfileXmlConfigTests-context.xml | 4 +- ...DefaultLocationsInheritedTests-context.xml | 2 +- .../DefaultLocationsBaseTests-context.xml | 2 +- ...DefaultLocationsInheritedTests-context.xml | 2 +- ...tionalTestNGSpringContextTests-context.xml | 4 +- ...tAndSessionScopedBeansWacTests-context.xml | 4 +- spring-tx/spring-tx.gradle | 2 + .../JndiJtaTransactionManagerTests.java | 2 +- .../TxNamespaceHandlerEventTests.java | 2 +- .../transaction/TxNamespaceHandlerTests.java | 2 +- .../AbstractTransactionAspectTests.java | 4 +- .../BeanFactoryTransactionTests.java | 6 +- .../interceptor/ImplementsNoInterfaces.java | 2 +- .../WebSphereUowTransactionManagerTests.java | 2 +- ...aTransactionManagerSerializationTests.java | 2 +- .../support/SimpleTransactionScopeTests.java | 4 +- .../noTransactionAttributeSource.xml | 2 +- .../interceptor/transactionalBeanFactory.xml | 12 +- .../transaction/txNamespaceHandlerTests.xml | 2 +- spring-web/spring-web.gradle | 2 + .../remoting/caucho/CauchoRemotingTests.java | 4 +- .../httpinvoker/HttpInvokerTests.java | 4 +- .../web/bind/EscapedErrorsTests.java | 2 +- .../bind/ServletRequestDataBinderTests.java | 4 +- .../support/WebExchangeDataBinderTests.java | 4 +- .../support/WebRequestDataBinderTests.java | 4 +- .../RequestAndSessionScopedBeanTests.java | 2 +- .../context/request/RequestScopeTests.java | 4 +- .../request/RequestScopedProxyTests.java | 8 +- .../context/request/SessionScopeTests.java | 4 +- .../WebApplicationContextScopeTests.java | 2 +- .../SpringBeanAutowiringSupportTests.java | 4 +- .../StandardServletEnvironmentTests.java | 2 +- .../ModelAttributeMethodProcessorTests.java | 2 +- .../SessionAttributesHandlerTests.java | 2 +- .../web/context/request/requestScopeTests.xml | 18 +- .../request/requestScopedProxyTests.xml | 20 +- .../web/context/request/sessionScopeTests.xml | 4 +- spring-webflux/spring-webflux.gradle | 1 + .../SessionAttributesHandlerTests.java | 2 +- .../result/view/AbstractViewTests.java | 2 +- .../view/freemarker/FreeMarkerMacroTests.java | 2 +- spring-webmvc/spring-webmvc.gradle | 2 + .../springframework/context/ACATester.java | 49 - .../context/BeanThatListens.java | 62 -- .../context/LifecycleContextBean.java | 3 +- .../web/context/ContextLoaderTests.java | 4 +- .../XmlWebApplicationContextTests.java | 14 +- .../support/ServletContextSupportTests.java | 2 +- .../web/servlet/DispatcherServletTests.java | 2 +- ...MvcConfigurationSupportExtensionTests.java | 2 +- .../ResponseStatusExceptionResolverTests.java | 2 +- ...ExtendedServletRequestDataBinderTests.java | 2 +- ...ResolverMethodReturnValueHandlerTests.java | 2 +- ...MappingHandlerAdapterIntegrationTests.java | 2 +- ...nnotationControllerHandlerMethodTests.java | 10 +- ...letModelAttributeMethodProcessorTests.java | 2 +- .../DefaultHandlerExceptionResolverTests.java | 2 +- .../RedirectAttributesModelMapTests.java | 2 +- .../web/servlet/tags/BindTagTests.java | 6 +- .../tags/form/AbstractFormTagTests.java | 2 +- .../web/servlet/tags/form/ButtonTagTests.java | 2 +- .../servlet/tags/form/CheckboxTagTests.java | 6 +- .../servlet/tags/form/CheckboxesTagTests.java | 6 +- .../web/servlet/tags/form/ErrorsTagTests.java | 2 +- .../tags/form/HiddenInputTagTests.java | 2 +- .../web/servlet/tags/form/InputTagTests.java | 2 +- .../web/servlet/tags/form/LabelTagTests.java | 2 +- .../servlet/tags/form/OptionTagEnumTests.java | 4 +- .../web/servlet/tags/form/OptionTagTests.java | 4 +- .../servlet/tags/form/OptionsTagTests.java | 2 +- .../tags/form/RadioButtonTagTests.java | 4 +- .../tags/form/RadioButtonsTagTests.java | 6 +- .../web/servlet/tags/form/SelectTagTests.java | 4 +- .../tags/form/TestBeanWithRealCountry.java | 2 +- .../servlet/tags/form/TextareaTagTests.java | 2 +- .../web/servlet/view/RedirectViewTests.java | 2 +- .../web/servlet/view/ViewResolverTests.java | 2 +- .../view/freemarker/FreeMarkerMacroTests.java | 2 +- .../ContextLoaderTests-acc-context.xml | 2 +- .../context/WEB-INF/applicationContext.xml | 10 +- .../web/context/WEB-INF/context-addition.xml | 20 +- .../web/context/WEB-INF/contextInclude.xml | 2 +- .../web/context/WEB-INF/sessionContext.xml | 4 +- .../web/context/WEB-INF/test-servlet.xml | 22 +- .../web/context/WEB-INF/testNamespace.xml | 4 +- 585 files changed, 2270 insertions(+), 1618 deletions(-) create mode 100644 spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java delete mode 100644 spring-aspects/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/AgeHolder.java (93%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/AnnotatedBean.java (92%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/BooleanTestBean.java (94%) rename spring-beans/src/{test/java/org/springframework/tests => testFixtures/java/org/springframework/beans/test/fixtures}/beans/CollectingReaderEventListener.java (98%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/Colour.java (95%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/CountingTestBean.java (93%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/CustomEnum.java (93%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/DependenciesBean.java (96%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/DerivedTestBean.java (97%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/DummyBean.java (96%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/DummyFactory.java (98%) rename {spring-context/src/test/java/org/springframework/tests/sample => spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures}/beans/Employee.java (88%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/GenericBean.java (99%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/GenericIntegerBean.java (92%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/GenericSetOfIntegerBean.java (93%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/HasMap.java (97%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/INestedTestBean.java (92%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/IOther.java (92%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/ITestBean.java (92%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/IndexedTestBean.java (98%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/LifecycleBean.java (98%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/MustBeInitialized.java (96%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/NestedTestBean.java (96%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/NumberTestBean.java (97%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/PackageLevelVisibleBean.java (93%) rename {spring-aop/src/test/java/org/springframework/tests/sample => spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures}/beans/Person.java (94%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/Pet.java (95%) rename {spring-aop/src/test/java/org/springframework/tests/sample => spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures}/beans/SerializablePerson.java (96%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/SideEffectBean.java (94%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/TestAnnotation.java (93%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/TestBean.java (96%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/factory/DummyFactory.java (97%) rename spring-beans/src/{test/java/org/springframework/tests/sample => testFixtures/java/org/springframework/beans/test/fixtures}/beans/package-info.java (55%) rename {spring-aop/src/test/java/org/springframework/tests/sample => spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures}/beans/subpkg/DeepBean.java (74%) rename spring-beans/src/{test/java/org/springframework/beans => testFixtures/java/org/springframework/beans/test/fixtures}/factory/xml/AbstractBeanFactoryTests.java (96%) rename spring-beans/src/{test/java/org/springframework/beans => testFixtures/java/org/springframework/beans/test/fixtures}/factory/xml/AbstractListableBeanFactoryTests.java (90%) delete mode 100644 spring-context/src/test/java/org/springframework/cache/config/SomeCustomKeyGenerator.java delete mode 100644 spring-context/src/test/java/org/springframework/context/BeanThatBroadcasts.java delete mode 100644 spring-context/src/test/java/org/springframework/context/TestListener.java delete mode 100644 spring-context/src/test/java/org/springframework/tests/context/TestMethodInvokingTask.java delete mode 100644 spring-context/src/test/java/org/springframework/tests/mock/jndi/package-info.java rename spring-context/src/{test/java/org/springframework/context => testFixtures/java/org/springframework/context/test/fixtures}/AbstractApplicationContextTests.java (87%) rename spring-context/src/{test/java/org/springframework/tests/context => testFixtures/java/org/springframework/context/test/fixtures}/SimpleMapScope.java (97%) rename spring-context/src/{test/java/org/springframework/context => testFixtures/java/org/springframework/context/test/fixtures/beans}/ACATester.java (75%) rename {spring-webmvc/src/test/java/org/springframework/context => spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans}/BeanThatBroadcasts.java (81%) rename spring-context/src/{test/java/org/springframework/context => testFixtures/java/org/springframework/context/test/fixtures/beans}/BeanThatListens.java (87%) rename spring-webmvc/src/test/java/org/springframework/context/TestListener.java => spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/TestApplicationListener.java (78%) rename spring-context/src/{test/java/org/springframework/cache/config => testFixtures/java/org/springframework/context/test/fixtures/cache}/AbstractCacheAnnotationTests.java (97%) rename spring-context/src/{test/java/org/springframework => testFixtures/java/org/springframework/context/test/fixtures}/cache/AbstractCacheTests.java (98%) rename spring-context/src/{test/java/org/springframework => testFixtures/java/org/springframework/context/test/fixtures}/cache/AbstractValueAdaptingCacheTests.java (96%) rename spring-context/src/{test/java/org/springframework => testFixtures/java/org/springframework/context/test/fixtures}/cache/CacheTestUtils.java (93%) rename {spring-aspects/src/test/java/org/springframework/cache/config => spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache}/SomeCustomKeyGenerator.java (88%) rename spring-context/src/{test/java/org/springframework/cache/config => testFixtures/java/org/springframework/context/test/fixtures/cache}/SomeKeyGenerator.java (92%) rename spring-context/src/{test/java/org/springframework/cache/config => testFixtures/java/org/springframework/context/test/fixtures/cache/beans}/AnnotatedClassCacheableService.java (99%) rename spring-context/src/{test/java/org/springframework/cache/config => testFixtures/java/org/springframework/context/test/fixtures/cache/beans}/CacheableService.java (96%) rename spring-context/src/{test/java/org/springframework/cache/config => testFixtures/java/org/springframework/context/test/fixtures/cache/beans}/DefaultCacheableService.java (99%) rename spring-context/src/{test/java/org/springframework/cache/config => testFixtures/java/org/springframework/context/test/fixtures/cache/beans}/TestEntity.java (95%) rename spring-context/src/{test/java/org/springframework/context => testFixtures/java/org/springframework/context/test/fixtures}/index/CandidateComponentsTestClassLoader.java (91%) rename spring-context/src/{test/java/org/springframework/tests/mock => testFixtures/java/org/springframework/context/test/fixtures}/jndi/ExpectedLookupTemplate.java (87%) rename spring-context/src/{test/java/org/springframework/tests/mock => testFixtures/java/org/springframework/context/test/fixtures}/jndi/SimpleNamingContext.java (96%) rename spring-context/src/{test/java/org/springframework/tests/mock => testFixtures/java/org/springframework/context/test/fixtures}/jndi/SimpleNamingContextBuilder.java (96%) rename {spring-context/src/test/java/org/springframework => spring-test/src/test/java/org/springframework/mock}/jndi/SimpleNamingContextTests.java (96%) delete mode 100644 spring-webmvc/src/test/java/org/springframework/context/ACATester.java delete mode 100644 spring-webmvc/src/test/java/org/springframework/context/BeanThatListens.java diff --git a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java index b93ca0f77df1..db5a10a7683e 100644 --- a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java +++ b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java @@ -59,7 +59,7 @@ public class TestSourcesPlugin implements Plugin { * Projects which will not be automatically added as a test dependency. *

    This is used to assist with the migration to Gradle test fixtures. */ - private static final List excludedProjects = Arrays.asList("spring-core"); + private static final List excludedProjects = Arrays.asList("spring-beans", "spring-core", "spring-context"); @Override diff --git a/integration-tests/integration-tests.gradle b/integration-tests/integration-tests.gradle index afaa939a61b5..539c743372d8 100644 --- a/integration-tests/integration-tests.gradle +++ b/integration-tests/integration-tests.gradle @@ -7,6 +7,7 @@ dependencies { testCompile(project(":spring-beans")) testCompile(project(":spring-context")) testCompile(project(":spring-core")) + testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-core"))) testCompile(project(":spring-expression")) testCompile(project(":spring-jdbc")) diff --git a/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java b/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java index 173da6e54d7a..c2a265443ab9 100644 --- a/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java @@ -21,12 +21,12 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpSession; import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; diff --git a/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java b/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java index e8d30cd33b96..e7060f909837 100644 --- a/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java @@ -28,12 +28,12 @@ import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.lang.Nullable; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.advice.MethodCounter; import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.NoTransactionException; import org.springframework.transaction.interceptor.TransactionInterceptor; diff --git a/integration-tests/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml b/integration-tests/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml index 56d265dc06fe..ccbe045e9a5e 100644 --- a/integration-tests/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml +++ b/integration-tests/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml @@ -11,19 +11,19 @@ - + - + - + - + diff --git a/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml b/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml index 7c2adb9e0120..4e7280580da2 100644 --- a/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml +++ b/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml @@ -74,20 +74,20 @@ - + - + - org.springframework.tests.sample.beans.ITestBean.getName + org.springframework.beans.test.fixtures.beans.ITestBean.getName - + 4 @@ -97,7 +97,7 @@ - + diff --git a/spring-aop/spring-aop.gradle b/spring-aop/spring-aop.gradle index 3d000edc2d4d..64c8fc6ef607 100644 --- a/spring-aop/spring-aop.gradle +++ b/spring-aop/spring-aop.gradle @@ -6,5 +6,6 @@ dependencies { optional("org.aspectj:aspectjweaver") optional("org.apache.commons:commons-pool2") optional("com.jamonapi:jamon") + testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-core"))) } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java index 2ba65e3502b4..3e9603edc187 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java @@ -31,10 +31,10 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.support.DefaultPointcutAdvisor; -import org.springframework.tests.sample.beans.IOther; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.tests.sample.beans.subpkg.DeepBean; +import org.springframework.beans.test.fixtures.beans.IOther; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.subpkg.DeepBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -67,7 +67,7 @@ public void setUp() throws NoSuchMethodException { @Test public void testMatchExplicit() { - String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())"; + String expression = "execution(int org.springframework.beans.test.fixtures.beans.TestBean.getAge())"; Pointcut pointcut = getPointcut(expression); ClassFilter classFilter = pointcut.getClassFilter(); @@ -117,8 +117,8 @@ public void testTarget() throws SecurityException, NoSuchMethodException { * @param which this or target */ private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException { - String matchesTestBean = which + "(org.springframework.tests.sample.beans.TestBean)"; - String matchesIOther = which + "(org.springframework.tests.sample.beans.IOther)"; + String matchesTestBean = which + "(org.springframework.beans.test.fixtures.beans.TestBean)"; + String matchesIOther = which + "(org.springframework.beans.test.fixtures.beans.IOther)"; AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut(); testBeanPc.setExpression(matchesTestBean); @@ -142,7 +142,7 @@ public void testWithinRootAndSubpackages() throws SecurityException, NoSuchMetho } private void testWithinPackage(boolean matchSubpackages) throws SecurityException, NoSuchMethodException { - String withinBeansPackage = "within(org.springframework.tests.sample.beans."; + String withinBeansPackage = "within(org.springframework.beans.test.fixtures.beans."; // Subpackages are matched by ** if (matchSubpackages) { withinBeansPackage += "."; @@ -187,7 +187,7 @@ public void testFriendlyErrorOnNoLocation3ArgMatching() { @Test public void testMatchWithArgs() throws Exception { - String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)"; + String expression = "execution(void org.springframework.beans.test.fixtures.beans.TestBean.setSomeNumber(Number)) && args(Double)"; Pointcut pointcut = getPointcut(expression); ClassFilter classFilter = pointcut.getClassFilter(); @@ -206,7 +206,7 @@ public void testMatchWithArgs() throws Exception { @Test public void testSimpleAdvice() { - String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())"; + String expression = "execution(int org.springframework.beans.test.fixtures.beans.TestBean.getAge())"; CallCountingInterceptor interceptor = new CallCountingInterceptor(); TestBean testBean = getAdvisedProxy(expression, interceptor); @@ -219,7 +219,7 @@ public void testSimpleAdvice() { @Test public void testDynamicMatchingProxy() { - String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)"; + String expression = "execution(void org.springframework.beans.test.fixtures.beans.TestBean.setSomeNumber(Number)) && args(Double)"; CallCountingInterceptor interceptor = new CallCountingInterceptor(); TestBean testBean = getAdvisedProxy(expression, interceptor); @@ -233,7 +233,7 @@ public void testDynamicMatchingProxy() { @Test public void testInvalidExpression() { - String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number) && args(Double)"; + String expression = "execution(void org.springframework.beans.test.fixtures.beans.TestBean.setSomeNumber(Number) && args(Double)"; assertThatIllegalArgumentException().isThrownBy( getPointcut(expression)::getClassFilter); // call to getClassFilter forces resolution } @@ -264,7 +264,7 @@ private void assertMatchesTestBeanClass(ClassFilter classFilter) { @Test public void testWithUnsupportedPointcutPrimitive() { - String expression = "call(int org.springframework.tests.sample.beans.TestBean.getAge())"; + String expression = "call(int org.springframework.beans.test.fixtures.beans.TestBean.getAge())"; assertThatExceptionOfType(UnsupportedPointcutPrimitiveException.class).isThrownBy(() -> getPointcut(expression).getClassFilter()) // call to getClassFilter forces resolution... .satisfies(ex -> assertThat(ex.getUnsupportedPrimitive()).isEqualTo(PointcutPrimitive.CALL)); diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java index 37787c686464..f64fbdaf301b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java index 13c911c3343a..157c85f0e646 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java @@ -33,8 +33,8 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.support.AopUtils; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java index 5e9acc89d426..6a87160981fd 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java @@ -27,7 +27,7 @@ import test.annotation.transaction.Tx; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; @@ -56,7 +56,7 @@ public void setup() throws NoSuchMethodException { @Test public void testMatchGenericArgument() { - String expression = "execution(* set*(java.util.List) )"; + String expression = "execution(* set*(java.util.List) )"; AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); ajexp.setExpression(expression); diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java index feaefe0e7f70..c95710517425 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java @@ -20,11 +20,11 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.tests.sample.beans.CountingTestBean; -import org.springframework.tests.sample.beans.IOther; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.tests.sample.beans.subpkg.DeepBean; +import org.springframework.beans.test.fixtures.beans.CountingTestBean; +import org.springframework.beans.test.fixtures.beans.IOther; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.subpkg.DeepBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -57,7 +57,7 @@ void invocationOfMatchesMethodBlowsUpWhenNoTypePatternHasBeenSet() throws Except @Test void validPatternMatching() { - TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.*"); + TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); assertThat(tpcf.matches(TestBean.class)).as("Must match: in package").isTrue(); assertThat(tpcf.matches(ITestBean.class)).as("Must match: in package").isTrue(); @@ -70,7 +70,7 @@ void validPatternMatching() { @Test void subclassMatching() { - TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.ITestBean+"); + TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.ITestBean+"); assertThat(tpcf.matches(TestBean.class)).as("Must match: in package").isTrue(); assertThat(tpcf.matches(ITestBean.class)).as("Must match: in package").isTrue(); @@ -98,8 +98,8 @@ void andOrNotReplacement() { @Test void testEquals() { - TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*"); - TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*"); + TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); + TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*"); assertThat(filter1).isEqualTo(filter2); @@ -108,8 +108,8 @@ void testEquals() { @Test void testHashCode() { - TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*"); - TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*"); + TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); + TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*"); assertThat(filter1.hashCode()).isEqualTo(filter2.hashCode()); @@ -118,11 +118,11 @@ void testHashCode() { @Test void testToString() { - TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*"); - TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*"); + TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); + TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); assertThat(filter1.toString()) - .isEqualTo("org.springframework.aop.aspectj.TypePatternClassFilter: org.springframework.tests.sample.beans.*"); + .isEqualTo("org.springframework.aop.aspectj.TypePatternClassFilter: org.springframework.beans.test.fixtures.beans.*"); assertThat(filter1.toString()).isEqualTo(filter2.toString()); } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java index 0790a58f8adb..c71218f6384c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java @@ -50,11 +50,11 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.support.AopUtils; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.OrderComparator; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ObjectUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -590,7 +590,7 @@ public void countSetter() { } - @Aspect("pertypewithin(org.springframework.tests.sample.beans.IOther+)") + @Aspect("pertypewithin(org.springframework.beans.test.fixtures.beans.IOther+)") public static class PerTypeWithinAspect { public int count; @@ -931,7 +931,7 @@ private Method getGetterFromSetter(Method setter) { @Aspect class MakeITestBeanModifiable extends AbstractMakeModifiable { - @DeclareParents(value = "org.springframework.tests.sample.beans.ITestBean+", + @DeclareParents(value = "org.springframework.beans.test.fixtures.beans.ITestBean+", defaultImpl=ModifiableImpl.class) public static MutableModifiable mixin; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java index e0806be6f060..432dfef3757a 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java @@ -27,8 +27,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java index bbc816b3289a..02345f252298 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java @@ -23,7 +23,7 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcut; import org.springframework.aop.aspectj.AspectJExpressionPointcutTests; import org.springframework.aop.framework.AopConfigException; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java index b2b1323b4fd9..c8188315f7e3 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java @@ -29,7 +29,7 @@ import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlReaderContext; -import org.springframework.tests.beans.CollectingReaderEventListener; +import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java index d713be7450f9..2896114e7bb9 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java @@ -29,8 +29,8 @@ import org.springframework.beans.factory.parsing.CompositeComponentDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; import org.springframework.core.io.Resource; -import org.springframework.tests.beans.CollectingReaderEventListener; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java index f2f9c624424e..eaa9e7ff524c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java @@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.SpringProxy; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java index 50092ca733b7..98493976ca4f 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java @@ -19,8 +19,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.support.DelegatingIntroductionInterceptor; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.util.StopWatch; /** diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java index 9de8bd658c15..dbbaaf60af93 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java @@ -23,7 +23,7 @@ import org.aopalliance.intercept.MethodInterceptor; import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java index 06545b23b00e..9ba9c837dd59 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java @@ -34,14 +34,14 @@ import org.springframework.aop.support.DefaultIntroductionAdvisor; import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.aop.support.DelegatingIntroductionInterceptor; +import org.springframework.beans.test.fixtures.beans.IOther; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.Order; import org.springframework.core.test.fixtures.TimeStamped; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.sample.beans.IOther; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java index 316d212c12d9..e50ebf8dc2ee 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java @@ -22,10 +22,10 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.test.fixtures.io.SerializationTestUtils; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java index ccb4d526313b..2fb5200e4b4c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java @@ -20,8 +20,8 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.NamedBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java index aaba0ed62314..2c0d1f1e3797 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java @@ -21,8 +21,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java index 1b32923d4da5..e4358b3883be 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.test.fixtures.io.SerializationTestUtils; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java index 09d88705f80e..bf98f8ac491a 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java @@ -25,10 +25,10 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.target.EmptyTargetSource; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java index 00ea9213e536..de4fecfecc27 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java @@ -19,9 +19,9 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.ClassFilter; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.NestedRuntimeException; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java index 39139bbbd02e..5e07be7dd192 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.util.ClassUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java index c4400b3371b9..769db77bf047 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java @@ -23,9 +23,9 @@ import org.springframework.aop.ClassFilter; import org.springframework.aop.MethodMatcher; import org.springframework.aop.Pointcut; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.NestedRuntimeException; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java index 72623dbf6559..956143c3a3e6 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java @@ -20,9 +20,9 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.framework.ProxyFactory; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java index 55da6fee78b1..21f0b04e05ad 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java @@ -24,15 +24,15 @@ import org.springframework.aop.IntroductionAdvisor; import org.springframework.aop.IntroductionInterceptor; import org.springframework.aop.framework.ProxyFactory; +import org.springframework.beans.test.fixtures.beans.INestedTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.NestedTestBean; +import org.springframework.beans.test.fixtures.beans.Person; +import org.springframework.beans.test.fixtures.beans.SerializablePerson; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.test.fixtures.TimeStamped; import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; -import org.springframework.tests.sample.beans.INestedTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.NestedTestBean; -import org.springframework.tests.sample.beans.Person; -import org.springframework.tests.sample.beans.SerializablePerson; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java index b69e8450b491..206a2e871185 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java @@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.MethodMatcher; +import org.springframework.beans.test.fixtures.beans.IOther; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.IOther; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java index 87241091caf7..0e921e05862b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java @@ -21,11 +21,11 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; +import org.springframework.beans.test.fixtures.beans.Person; +import org.springframework.beans.test.fixtures.beans.SerializablePerson; import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; -import org.springframework.tests.sample.beans.Person; -import org.springframework.tests.sample.beans.SerializablePerson; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java index 599354821a02..0b913b97030b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java @@ -22,8 +22,8 @@ import org.springframework.aop.ClassFilter; import org.springframework.aop.Pointcut; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java index 34fd0e47775e..62d1d1e5a87e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java @@ -21,13 +21,13 @@ import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.Person; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.Resource; import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.Person; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/RootClassFilterTests.java b/spring-aop/src/test/java/org/springframework/aop/support/RootClassFilterTests.java index 0c132f327e3b..184858d27f0b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/RootClassFilterTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/RootClassFilterTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.ClassFilter; -import org.springframework.tests.sample.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java index 5536a17c8f0d..9ddd2a53e071 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java @@ -21,8 +21,8 @@ import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.core.io.Resource; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java index a5298674de79..85396507092a 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java @@ -25,11 +25,11 @@ import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.Person; +import org.springframework.beans.test.fixtures.beans.SerializablePerson; +import org.springframework.beans.test.fixtures.beans.SideEffectBean; import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; -import org.springframework.tests.sample.beans.Person; -import org.springframework.tests.sample.beans.SerializablePerson; -import org.springframework.tests.sample.beans.SideEffectBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java index 54ea0552c769..8f1ffc90be89 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java @@ -22,8 +22,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.core.io.Resource; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java index a4006bd888ed..c1eaa77ea39a 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java @@ -23,9 +23,9 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.SerializablePerson; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.test.fixtures.io.SerializationTestUtils; -import org.springframework.tests.sample.beans.SerializablePerson; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java index 37bf57a27417..04a3c695f6eb 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java @@ -21,7 +21,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.tests.sample.beans.SideEffectBean; +import org.springframework.beans.test.fixtures.beans.SideEffectBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java index 1ff3816db8bc..4170e6402f3c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java @@ -21,8 +21,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.SideEffectBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.SideEffectBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml index 48da214eb4d6..745dbc3e40fb 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml @@ -20,7 +20,7 @@ - + diff --git a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml index 1162d714f32e..59bd49621c61 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml @@ -14,7 +14,7 @@ - + diff --git a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml index b47670e08d34..955540049e93 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml @@ -14,7 +14,7 @@ - + diff --git a/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml index e67171818b5d..7ce48dc01edf 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml @@ -4,7 +4,7 @@ - + custom 666 @@ -21,15 +21,15 @@ - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean settersAdvisor - org.springframework.tests.sample.beans.Person + org.springframework.beans.test.fixtures.beans.Person - + serializableSettersAdvised @@ -48,7 +48,7 @@ - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean true diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests-context.xml index c3c614d4a634..a18634ee9ff3 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests-context.xml @@ -3,7 +3,7 @@ - + diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml index dcc43922efd5..a5d28ca2f8d7 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml @@ -4,11 +4,11 @@ - + 10 - + 20 diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-customTarget.xml b/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-customTarget.xml index cec1c980ba5a..d48cdb081756 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-customTarget.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-customTarget.xml @@ -3,7 +3,7 @@ - + 10 diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-singleton.xml b/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-singleton.xml index 1e5c69f5499b..7f29fec4f784 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-singleton.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-singleton.xml @@ -3,7 +3,7 @@ - + 10 diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml index 4ee787b20fb4..6b2801a1e9ec 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml @@ -4,11 +4,11 @@ - + 10 - + 10 diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml index 6400db2f215f..5d71019c5fc6 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml @@ -3,7 +3,7 @@ - + 10 @@ -34,12 +34,12 @@ - + Rod - + Kerry diff --git a/spring-aspects/spring-aspects.gradle b/spring-aspects/spring-aspects.gradle index fbb219643771..202014e728c9 100644 --- a/spring-aspects/spring-aspects.gradle +++ b/spring-aspects/spring-aspects.gradle @@ -24,6 +24,7 @@ dependencies { optional("javax.transaction:javax.transaction-api") // for @javax.transaction.Transactional support testCompile(project(":spring-core")) // for CodeStyleAspect testCompile(project(":spring-test")) + testCompile(testFixtures(project(":spring-context"))) testCompile(testFixtures(project(":spring-core"))) testCompile("javax.mail:javax.mail-api") testCompileOnly("org.aspectj:aspectjrt") diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java new file mode 100644 index 000000000000..24fd8a30b9ac --- /dev/null +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java @@ -0,0 +1,882 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cache.aspectj; + +import java.util.Collection; +import java.util.UUID; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import org.springframework.aop.framework.AopProxyUtils; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.cache.config.AnnotatedClassCacheableService; +import org.springframework.cache.config.CacheableService; +import org.springframework.cache.config.TestEntity; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIOException; + +/** + * Copy of the shared {@code AbstractCacheAnnotationTests}: necessary + * due to issues with Gradle test fixtures and AspectJ configuration + * in the Gradle build. + * + *

    Abstract cache annotation tests (containing several reusable methods). + * + * @author Costin Leau + * @author Chris Beams + * @author Phillip Webb + * @author Stephane Nicoll + */ +public abstract class AbstractCacheAnnotationTests { + + protected ConfigurableApplicationContext ctx; + + protected CacheableService cs; + + protected CacheableService ccs; + + protected CacheManager cm; + + + /** + * @return a refreshed application context + */ + protected abstract ConfigurableApplicationContext getApplicationContext(); + + + @BeforeEach + public void setup() { + this.ctx = getApplicationContext(); + this.cs = ctx.getBean("service", CacheableService.class); + this.ccs = ctx.getBean("classService", CacheableService.class); + this.cm = ctx.getBean("cacheManager", CacheManager.class); + + Collection cn = this.cm.getCacheNames(); + assertThat(cn).containsOnly("testCache", "secondary", "primary"); + } + + @AfterEach + public void close() { + if (this.ctx != null) { + this.ctx.close(); + } + } + + + protected void testCacheable(CacheableService service) { + Object o1 = new Object(); + + Object r1 = service.cache(o1); + Object r2 = service.cache(o1); + Object r3 = service.cache(o1); + + assertThat(r2).isSameAs(r1); + assertThat(r3).isSameAs(r1); + } + + protected void testCacheableNull(CacheableService service) { + Object o1 = new Object(); + assertThat(this.cm.getCache("testCache").get(o1)).isNull(); + + Object r1 = service.cacheNull(o1); + Object r2 = service.cacheNull(o1); + Object r3 = service.cacheNull(o1); + + assertThat(r2).isSameAs(r1); + assertThat(r3).isSameAs(r1); + + assertThat(this.cm.getCache("testCache")).as("testCache").isNotNull(); + assertThat(this.cm.getCache("testCache").get(o1)).as("cached object").isNotNull(); + assertThat(this.cm.getCache("testCache").get(o1).get()).isEqualTo(r3); + assertThat(r3).as("Cached value should be null").isNull(); + } + + protected void testCacheableSync(CacheableService service) { + Object o1 = new Object(); + + Object r1 = service.cacheSync(o1); + Object r2 = service.cacheSync(o1); + Object r3 = service.cacheSync(o1); + + assertThat(r2).isSameAs(r1); + assertThat(r3).isSameAs(r1); + } + + protected void testCacheableSyncNull(CacheableService service) { + Object o1 = new Object(); + assertThat(this.cm.getCache("testCache").get(o1)).isNull(); + + Object r1 = service.cacheSyncNull(o1); + Object r2 = service.cacheSyncNull(o1); + Object r3 = service.cacheSyncNull(o1); + + assertThat(r2).isSameAs(r1); + assertThat(r3).isSameAs(r1); + + assertThat(this.cm.getCache("testCache").get(o1).get()).isEqualTo(r3); + assertThat(r3).as("Cached value should be null").isNull(); + } + + protected void testEvict(CacheableService service, boolean successExpected) { + Cache cache = this.cm.getCache("testCache"); + + Object o1 = new Object(); + cache.putIfAbsent(o1, -1L); + Object r1 = service.cache(o1); + + service.evict(o1, null); + if (successExpected) { + assertThat(cache.get(o1)).isNull(); + } + else { + assertThat(cache.get(o1)).isNotNull(); + } + + Object r2 = service.cache(o1); + if (successExpected) { + assertThat(r2).isNotSameAs(r1); + } + else { + assertThat(r2).isSameAs(r1); + } + } + + protected void testEvictEarly(CacheableService service) { + Cache cache = this.cm.getCache("testCache"); + + Object o1 = new Object(); + cache.putIfAbsent(o1, -1L); + Object r1 = service.cache(o1); + + try { + service.evictEarly(o1); + } + catch (RuntimeException ex) { + // expected + } + assertThat(cache.get(o1)).isNull(); + + Object r2 = service.cache(o1); + assertThat(r2).isNotSameAs(r1); + } + + protected void testEvictException(CacheableService service) { + Object o1 = new Object(); + Object r1 = service.cache(o1); + + try { + service.evictWithException(o1); + } + catch (RuntimeException ex) { + // expected + } + // exception occurred, eviction skipped, data should still be in the cache + Object r2 = service.cache(o1); + assertThat(r2).isSameAs(r1); + } + + protected void testEvictWithKey(CacheableService service) { + Object o1 = new Object(); + Object r1 = service.cache(o1); + + service.evict(o1, null); + Object r2 = service.cache(o1); + assertThat(r2).isNotSameAs(r1); + } + + protected void testEvictWithKeyEarly(CacheableService service) { + Object o1 = new Object(); + Object r1 = service.cache(o1); + + try { + service.evictEarly(o1); + } + catch (Exception ex) { + // expected + } + Object r2 = service.cache(o1); + assertThat(r2).isNotSameAs(r1); + } + + protected void testEvictAll(CacheableService service, boolean successExpected) { + Cache cache = this.cm.getCache("testCache"); + + Object o1 = new Object(); + Object o2 = new Object(); + cache.putIfAbsent(o1, -1L); + cache.putIfAbsent(o2, -2L); + + Object r1 = service.cache(o1); + Object r2 = service.cache(o2); + assertThat(r2).isNotSameAs(r1); + + service.evictAll(new Object()); + if (successExpected) { + assertThat(cache.get(o1)).isNull(); + assertThat(cache.get(o2)).isNull(); + } + else { + assertThat(cache.get(o1)).isNotNull(); + assertThat(cache.get(o2)).isNotNull(); + } + + Object r3 = service.cache(o1); + Object r4 = service.cache(o2); + if (successExpected) { + assertThat(r3).isNotSameAs(r1); + assertThat(r4).isNotSameAs(r2); + } + else { + assertThat(r3).isSameAs(r1); + assertThat(r4).isSameAs(r2); + } + } + + protected void testEvictAllEarly(CacheableService service) { + Cache cache = this.cm.getCache("testCache"); + + Object o1 = new Object(); + Object o2 = new Object(); + cache.putIfAbsent(o1, -1L); + cache.putIfAbsent(o2, -2L); + + Object r1 = service.cache(o1); + Object r2 = service.cache(o2); + assertThat(r2).isNotSameAs(r1); + + try { + service.evictAllEarly(new Object()); + } + catch (Exception ex) { + // expected + } + assertThat(cache.get(o1)).isNull(); + assertThat(cache.get(o2)).isNull(); + + Object r3 = service.cache(o1); + Object r4 = service.cache(o2); + assertThat(r3).isNotSameAs(r1); + assertThat(r4).isNotSameAs(r2); + } + + protected void testConditionalExpression(CacheableService service) { + Object r1 = service.conditional(4); + Object r2 = service.conditional(4); + + assertThat(r2).isNotSameAs(r1); + + Object r3 = service.conditional(3); + Object r4 = service.conditional(3); + + assertThat(r4).isSameAs(r3); + } + + protected void testConditionalExpressionSync(CacheableService service) { + Object r1 = service.conditionalSync(4); + Object r2 = service.conditionalSync(4); + + assertThat(r2).isNotSameAs(r1); + + Object r3 = service.conditionalSync(3); + Object r4 = service.conditionalSync(3); + + assertThat(r4).isSameAs(r3); + } + + protected void testUnlessExpression(CacheableService service) { + Cache cache = this.cm.getCache("testCache"); + cache.clear(); + service.unless(10); + service.unless(11); + assertThat(cache.get(10).get()).isEqualTo(10L); + assertThat(cache.get(11)).isNull(); + } + + protected void testKeyExpression(CacheableService service) { + Object r1 = service.key(5, 1); + Object r2 = service.key(5, 2); + + assertThat(r2).isSameAs(r1); + + Object r3 = service.key(1, 5); + Object r4 = service.key(2, 5); + + assertThat(r4).isNotSameAs(r3); + } + + protected void testVarArgsKey(CacheableService service) { + Object r1 = service.varArgsKey(1, 2, 3); + Object r2 = service.varArgsKey(1, 2, 3); + + assertThat(r2).isSameAs(r1); + + Object r3 = service.varArgsKey(1, 2, 3); + Object r4 = service.varArgsKey(1, 2); + + assertThat(r4).isNotSameAs(r3); + } + + protected void testNullValue(CacheableService service) { + Object key = new Object(); + assertThat(service.nullValue(key)).isNull(); + int nr = service.nullInvocations().intValue(); + assertThat(service.nullValue(key)).isNull(); + assertThat(service.nullInvocations().intValue()).isEqualTo(nr); + assertThat(service.nullValue(new Object())).isNull(); + assertThat(service.nullInvocations().intValue()).isEqualTo(nr + 1); + } + + protected void testMethodName(CacheableService service, String keyName) { + Object key = new Object(); + Object r1 = service.name(key); + assertThat(service.name(key)).isSameAs(r1); + Cache cache = this.cm.getCache("testCache"); + // assert the method name is used + assertThat(cache.get(keyName)).isNotNull(); + } + + protected void testRootVars(CacheableService service) { + Object key = new Object(); + Object r1 = service.rootVars(key); + assertThat(service.rootVars(key)).isSameAs(r1); + Cache cache = this.cm.getCache("testCache"); + // assert the method name is used + String expectedKey = "rootVarsrootVars" + AopProxyUtils.ultimateTargetClass(service) + service; + assertThat(cache.get(expectedKey)).isNotNull(); + } + + protected void testCheckedThrowable(CacheableService service) { + String arg = UUID.randomUUID().toString(); + assertThatIOException().isThrownBy(() -> + service.throwChecked(arg)) + .withMessage(arg); + } + + protected void testUncheckedThrowable(CacheableService service) { + assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> + service.throwUnchecked(1L)) + .withMessage("1"); + } + + protected void testCheckedThrowableSync(CacheableService service) { + String arg = UUID.randomUUID().toString(); + assertThatIOException().isThrownBy(() -> + service.throwCheckedSync(arg)) + .withMessage(arg); + } + + protected void testUncheckedThrowableSync(CacheableService service) { + assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> + service.throwUncheckedSync(1L)) + .withMessage("1"); + } + + protected void testNullArg(CacheableService service) { + Object r1 = service.cache(null); + assertThat(service.cache(null)).isSameAs(r1); + } + + protected void testCacheUpdate(CacheableService service) { + Object o = new Object(); + Cache cache = this.cm.getCache("testCache"); + assertThat(cache.get(o)).isNull(); + Object r1 = service.update(o); + assertThat(cache.get(o).get()).isSameAs(r1); + + o = new Object(); + assertThat(cache.get(o)).isNull(); + Object r2 = service.update(o); + assertThat(cache.get(o).get()).isSameAs(r2); + } + + protected void testConditionalCacheUpdate(CacheableService service) { + Integer one = 1; + Integer three = 3; + + Cache cache = this.cm.getCache("testCache"); + assertThat((int) Integer.valueOf(service.conditionalUpdate(one).toString())).isEqualTo((int) one); + assertThat(cache.get(one)).isNull(); + + assertThat((int) Integer.valueOf(service.conditionalUpdate(three).toString())).isEqualTo((int) three); + assertThat((int) Integer.valueOf(cache.get(three).get().toString())).isEqualTo((int) three); + } + + protected void testMultiCache(CacheableService service) { + Object o1 = new Object(); + Object o2 = new Object(); + + Cache primary = this.cm.getCache("primary"); + Cache secondary = this.cm.getCache("secondary"); + + assertThat(primary.get(o1)).isNull(); + assertThat(secondary.get(o1)).isNull(); + Object r1 = service.multiCache(o1); + assertThat(primary.get(o1).get()).isSameAs(r1); + assertThat(secondary.get(o1).get()).isSameAs(r1); + + Object r2 = service.multiCache(o1); + Object r3 = service.multiCache(o1); + + assertThat(r2).isSameAs(r1); + assertThat(r3).isSameAs(r1); + + assertThat(primary.get(o2)).isNull(); + assertThat(secondary.get(o2)).isNull(); + Object r4 = service.multiCache(o2); + assertThat(primary.get(o2).get()).isSameAs(r4); + assertThat(secondary.get(o2).get()).isSameAs(r4); + } + + protected void testMultiEvict(CacheableService service) { + Object o1 = new Object(); + Object o2 = o1.toString() + "A"; + + + Object r1 = service.multiCache(o1); + Object r2 = service.multiCache(o1); + + Cache primary = this.cm.getCache("primary"); + Cache secondary = this.cm.getCache("secondary"); + + primary.put(o2, o2); + assertThat(r2).isSameAs(r1); + assertThat(primary.get(o1).get()).isSameAs(r1); + assertThat(secondary.get(o1).get()).isSameAs(r1); + + service.multiEvict(o1); + assertThat(primary.get(o1)).isNull(); + assertThat(secondary.get(o1)).isNull(); + assertThat(primary.get(o2)).isNull(); + + Object r3 = service.multiCache(o1); + Object r4 = service.multiCache(o1); + assertThat(r3).isNotSameAs(r1); + assertThat(r4).isSameAs(r3); + + assertThat(primary.get(o1).get()).isSameAs(r3); + assertThat(secondary.get(o1).get()).isSameAs(r4); + } + + protected void testMultiPut(CacheableService service) { + Object o = 1; + + Cache primary = this.cm.getCache("primary"); + Cache secondary = this.cm.getCache("secondary"); + + assertThat(primary.get(o)).isNull(); + assertThat(secondary.get(o)).isNull(); + Object r1 = service.multiUpdate(o); + assertThat(primary.get(o).get()).isSameAs(r1); + assertThat(secondary.get(o).get()).isSameAs(r1); + + o = 2; + assertThat(primary.get(o)).isNull(); + assertThat(secondary.get(o)).isNull(); + Object r2 = service.multiUpdate(o); + assertThat(primary.get(o).get()).isSameAs(r2); + assertThat(secondary.get(o).get()).isSameAs(r2); + } + + protected void testPutRefersToResult(CacheableService service) { + Long id = Long.MIN_VALUE; + TestEntity entity = new TestEntity(); + Cache primary = this.cm.getCache("primary"); + assertThat(primary.get(id)).isNull(); + assertThat(entity.getId()).isNull(); + service.putRefersToResult(entity); + assertThat(primary.get(id).get()).isSameAs(entity); + } + + protected void testMultiCacheAndEvict(CacheableService service) { + String methodName = "multiCacheAndEvict"; + + Cache primary = this.cm.getCache("primary"); + Cache secondary = this.cm.getCache("secondary"); + Object key = 1; + + secondary.put(key, key); + + assertThat(secondary.get(methodName)).isNull(); + assertThat(secondary.get(key).get()).isSameAs(key); + + Object r1 = service.multiCacheAndEvict(key); + assertThat(service.multiCacheAndEvict(key)).isSameAs(r1); + + // assert the method name is used + assertThat(primary.get(methodName).get()).isSameAs(r1); + assertThat(secondary.get(methodName)).isNull(); + assertThat(secondary.get(key)).isNull(); + } + + protected void testMultiConditionalCacheAndEvict(CacheableService service) { + Cache primary = this.cm.getCache("primary"); + Cache secondary = this.cm.getCache("secondary"); + Object key = 1; + + secondary.put(key, key); + + assertThat(primary.get(key)).isNull(); + assertThat(secondary.get(key).get()).isSameAs(key); + + Object r1 = service.multiConditionalCacheAndEvict(key); + Object r3 = service.multiConditionalCacheAndEvict(key); + + assertThat(!r1.equals(r3)).isTrue(); + assertThat(primary.get(key)).isNull(); + + Object key2 = 3; + Object r2 = service.multiConditionalCacheAndEvict(key2); + assertThat(service.multiConditionalCacheAndEvict(key2)).isSameAs(r2); + + // assert the method name is used + assertThat(primary.get(key2).get()).isSameAs(r2); + assertThat(secondary.get(key2)).isNull(); + } + + @Test + public void testCacheable() { + testCacheable(this.cs); + } + + @Test + public void testCacheableNull() { + testCacheableNull(this.cs); + } + + @Test + public void testCacheableSync() { + testCacheableSync(this.cs); + } + + @Test + public void testCacheableSyncNull() { + testCacheableSyncNull(this.cs); + } + + @Test + public void testEvict() { + testEvict(this.cs, true); + } + + @Test + public void testEvictEarly() { + testEvictEarly(this.cs); + } + + @Test + public void testEvictWithException() { + testEvictException(this.cs); + } + + @Test + public void testEvictAll() { + testEvictAll(this.cs, true); + } + + @Test + public void testEvictAllEarly() { + testEvictAllEarly(this.cs); + } + + @Test + public void testEvictWithKey() { + testEvictWithKey(this.cs); + } + + @Test + public void testEvictWithKeyEarly() { + testEvictWithKeyEarly(this.cs); + } + + @Test + public void testConditionalExpression() { + testConditionalExpression(this.cs); + } + + @Test + public void testConditionalExpressionSync() { + testConditionalExpressionSync(this.cs); + } + + @Test + public void testUnlessExpression() { + testUnlessExpression(this.cs); + } + + @Test + public void testClassCacheUnlessExpression() { + testUnlessExpression(this.cs); + } + + @Test + public void testKeyExpression() { + testKeyExpression(this.cs); + } + + @Test + public void testVarArgsKey() { + testVarArgsKey(this.cs); + } + + @Test + public void testClassCacheCacheable() { + testCacheable(this.ccs); + } + + @Test + public void testClassCacheEvict() { + testEvict(this.ccs, true); + } + + @Test + public void testClassEvictEarly() { + testEvictEarly(this.ccs); + } + + @Test + public void testClassEvictAll() { + testEvictAll(this.ccs, true); + } + + @Test + public void testClassEvictWithException() { + testEvictException(this.ccs); + } + + @Test + public void testClassCacheEvictWithWKey() { + testEvictWithKey(this.ccs); + } + + @Test + public void testClassEvictWithKeyEarly() { + testEvictWithKeyEarly(this.ccs); + } + + @Test + public void testNullValue() { + testNullValue(this.cs); + } + + @Test + public void testClassNullValue() { + Object key = new Object(); + assertThat(this.ccs.nullValue(key)).isNull(); + int nr = this.ccs.nullInvocations().intValue(); + assertThat(this.ccs.nullValue(key)).isNull(); + assertThat(this.ccs.nullInvocations().intValue()).isEqualTo(nr); + assertThat(this.ccs.nullValue(new Object())).isNull(); + // the check method is also cached + assertThat(this.ccs.nullInvocations().intValue()).isEqualTo(nr); + assertThat(AnnotatedClassCacheableService.nullInvocations.intValue()).isEqualTo(nr + 1); + } + + @Test + public void testMethodName() { + testMethodName(this.cs, "name"); + } + + @Test + public void testClassMethodName() { + testMethodName(this.ccs, "nametestCache"); + } + + @Test + public void testRootVars() { + testRootVars(this.cs); + } + + @Test + public void testClassRootVars() { + testRootVars(this.ccs); + } + + @Test + public void testCustomKeyGenerator() { + Object param = new Object(); + Object r1 = this.cs.customKeyGenerator(param); + assertThat(this.cs.customKeyGenerator(param)).isSameAs(r1); + Cache cache = this.cm.getCache("testCache"); + // Checks that the custom keyGenerator was used + Object expectedKey = SomeCustomKeyGenerator.generateKey("customKeyGenerator", param); + assertThat(cache.get(expectedKey)).isNotNull(); + } + + @Test + public void testUnknownCustomKeyGenerator() { + Object param = new Object(); + assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> + this.cs.unknownCustomKeyGenerator(param)); + } + + @Test + public void testCustomCacheManager() { + CacheManager customCm = this.ctx.getBean("customCacheManager", CacheManager.class); + Object key = new Object(); + Object r1 = this.cs.customCacheManager(key); + assertThat(this.cs.customCacheManager(key)).isSameAs(r1); + + Cache cache = customCm.getCache("testCache"); + assertThat(cache.get(key)).isNotNull(); + } + + @Test + public void testUnknownCustomCacheManager() { + Object param = new Object(); + assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> + this.cs.unknownCustomCacheManager(param)); + } + + @Test + public void testNullArg() { + testNullArg(this.cs); + } + + @Test + public void testClassNullArg() { + testNullArg(this.ccs); + } + + @Test + public void testCheckedException() { + testCheckedThrowable(this.cs); + } + + @Test + public void testClassCheckedException() { + testCheckedThrowable(this.ccs); + } + + @Test + public void testCheckedExceptionSync() { + testCheckedThrowableSync(this.cs); + } + + @Test + public void testClassCheckedExceptionSync() { + testCheckedThrowableSync(this.ccs); + } + + @Test + public void testUncheckedException() { + testUncheckedThrowable(this.cs); + } + + @Test + public void testClassUncheckedException() { + testUncheckedThrowable(this.ccs); + } + + @Test + public void testUncheckedExceptionSync() { + testUncheckedThrowableSync(this.cs); + } + + @Test + public void testClassUncheckedExceptionSync() { + testUncheckedThrowableSync(this.ccs); + } + + @Test + public void testUpdate() { + testCacheUpdate(this.cs); + } + + @Test + public void testClassUpdate() { + testCacheUpdate(this.ccs); + } + + @Test + public void testConditionalUpdate() { + testConditionalCacheUpdate(this.cs); + } + + @Test + public void testClassConditionalUpdate() { + testConditionalCacheUpdate(this.ccs); + } + + @Test + public void testMultiCache() { + testMultiCache(this.cs); + } + + @Test + public void testClassMultiCache() { + testMultiCache(this.ccs); + } + + @Test + public void testMultiEvict() { + testMultiEvict(this.cs); + } + + @Test + public void testClassMultiEvict() { + testMultiEvict(this.ccs); + } + + @Test + public void testMultiPut() { + testMultiPut(this.cs); + } + + @Test + public void testClassMultiPut() { + testMultiPut(this.ccs); + } + + @Test + public void testPutRefersToResult() { + testPutRefersToResult(this.cs); + } + + @Test + public void testClassPutRefersToResult() { + testPutRefersToResult(this.ccs); + } + + @Test + public void testMultiCacheAndEvict() { + testMultiCacheAndEvict(this.cs); + } + + @Test + public void testClassMultiCacheAndEvict() { + testMultiCacheAndEvict(this.ccs); + } + + @Test + public void testMultiConditionalCacheAndEvict() { + testMultiConditionalCacheAndEvict(this.cs); + } + + @Test + public void testClassMultiConditionalCacheAndEvict() { + testMultiConditionalCacheAndEvict(this.ccs); + } + +} diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java index e952eacd3b00..4601c0ea814c 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java @@ -19,7 +19,6 @@ import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; -import org.springframework.cache.config.AbstractCacheAnnotationTests; import org.springframework.cache.config.CacheableService; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java index 57b9b90f5596..686acc548515 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java @@ -22,14 +22,8 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.cache.CacheManager; -import org.springframework.cache.CacheTestUtils; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; -import org.springframework.cache.config.AnnotatedClassCacheableService; -import org.springframework.cache.config.CacheableService; -import org.springframework.cache.config.DefaultCacheableService; -import org.springframework.cache.config.SomeCustomKeyGenerator; -import org.springframework.cache.config.SomeKeyGenerator; import org.springframework.cache.interceptor.CacheErrorHandler; import org.springframework.cache.interceptor.CacheResolver; import org.springframework.cache.interceptor.KeyGenerator; @@ -42,6 +36,12 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.test.fixtures.cache.CacheTestUtils; +import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator; +import org.springframework.context.test.fixtures.cache.SomeKeyGenerator; +import org.springframework.context.test.fixtures.cache.beans.AnnotatedClassCacheableService; +import org.springframework.context.test.fixtures.cache.beans.CacheableService; +import org.springframework.context.test.fixtures.cache.beans.DefaultCacheableService; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java index 7857394de16f..8fc14ff04523 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 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,15 +17,11 @@ package org.springframework.cache.aspectj; import org.springframework.cache.CacheManager; -import org.springframework.cache.CacheTestUtils; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; -import org.springframework.cache.config.AbstractCacheAnnotationTests; import org.springframework.cache.config.AnnotatedClassCacheableService; import org.springframework.cache.config.CacheableService; import org.springframework.cache.config.DefaultCacheableService; -import org.springframework.cache.config.SomeCustomKeyGenerator; -import org.springframework.cache.config.SomeKeyGenerator; import org.springframework.cache.interceptor.CacheErrorHandler; import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.cache.interceptor.SimpleCacheErrorHandler; @@ -34,6 +30,9 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.test.fixtures.cache.CacheTestUtils; +import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator; +import org.springframework.context.test.fixtures.cache.SomeKeyGenerator; /** * @author Stephane Nicoll diff --git a/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java b/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java index 5872dffc7808..fa494c921280 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java +++ b/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java @@ -25,6 +25,10 @@ import org.springframework.cache.annotation.Caching; /** + * Copy of the shared {@code AbstractCacheAnnotationTests}: necessary + * due to issues with Gradle test fixtures and AspectJ configuration + * in the Gradle build. + * * @author Costin Leau * @author Phillip Webb * @author Stephane Nicoll diff --git a/spring-aspects/src/test/java/org/springframework/cache/config/CacheableService.java b/spring-aspects/src/test/java/org/springframework/cache/config/CacheableService.java index e5ab4a5f94cc..3ec6212bac60 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/config/CacheableService.java +++ b/spring-aspects/src/test/java/org/springframework/cache/config/CacheableService.java @@ -17,7 +17,11 @@ package org.springframework.cache.config; /** - * Basic service interface for caching tests. + * Copy of the shared {@code CacheableService}: necessary + * due to issues with Gradle test fixtures and AspectJ configuration + * in the Gradle build. + * + *

    Basic service interface for caching tests. * * @author Costin Leau * @author Phillip Webb diff --git a/spring-aspects/src/test/java/org/springframework/cache/config/DefaultCacheableService.java b/spring-aspects/src/test/java/org/springframework/cache/config/DefaultCacheableService.java index 7df2bb4ea27d..47a3a83a34a1 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/config/DefaultCacheableService.java +++ b/spring-aspects/src/test/java/org/springframework/cache/config/DefaultCacheableService.java @@ -25,7 +25,11 @@ import org.springframework.cache.annotation.Caching; /** - * Simple cacheable service. + * Copy of the shared {@code DefaultCacheableService}: necessary + * due to issues with Gradle test fixtures and AspectJ configuration + * in the Gradle build. + * + *

    Simple cacheable service. * * @author Costin Leau * @author Phillip Webb diff --git a/spring-aspects/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java b/spring-aspects/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java deleted file mode 100644 index 11e757b062fd..000000000000 --- a/spring-aspects/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2002-2016 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cache.config; - -import org.springframework.cache.interceptor.SimpleKeyGenerator; - -public class SomeKeyGenerator extends SimpleKeyGenerator { -} diff --git a/spring-aspects/src/test/java/org/springframework/cache/config/TestEntity.java b/spring-aspects/src/test/java/org/springframework/cache/config/TestEntity.java index 087019a37641..b308741ee147 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/config/TestEntity.java +++ b/spring-aspects/src/test/java/org/springframework/cache/config/TestEntity.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2019 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. @@ -19,7 +19,11 @@ import org.springframework.util.ObjectUtils; /** - * Simple test entity for use with caching tests. + * Copy of the shared {@code TestEntity}: necessary + * due to issues with Gradle test fixtures and AspectJ configuration + * in the Gradle build. + * + *

    Simple test entity for use with caching tests. * * @author Michael Plod */ @@ -53,5 +57,4 @@ public boolean equals(Object obj) { } return false; } - } diff --git a/spring-aspects/src/test/resources/org/springframework/cache/config/annotation-cache-aspectj.xml b/spring-aspects/src/test/resources/org/springframework/cache/config/annotation-cache-aspectj.xml index 1ff47150738c..f9df2c29bf75 100644 --- a/spring-aspects/src/test/resources/org/springframework/cache/config/annotation-cache-aspectj.xml +++ b/spring-aspects/src/test/resources/org/springframework/cache/config/annotation-cache-aspectj.xml @@ -22,7 +22,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/spring-beans/spring-beans.gradle b/spring-beans/spring-beans.gradle index 9ab23dedff8d..0e9670811509 100644 --- a/spring-beans/spring-beans.gradle +++ b/spring-beans/spring-beans.gradle @@ -12,6 +12,8 @@ dependencies { optional("org.jetbrains.kotlin:kotlin-stdlib") testCompile(testFixtures(project(":spring-core"))) testCompile("javax.annotation:javax.annotation-api") + testFixturesApi("org.junit.jupiter:junit-jupiter-api") + testFixturesImplementation("org.assertj:assertj-core") } // This module does joint compilation for Java and Groovy code with the compileGroovy task. diff --git a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java index 723ee31c2388..156df6d2802e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java @@ -43,6 +43,11 @@ import org.springframework.beans.propertyeditors.StringArrayPropertyEditor; import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.beans.support.DerivedFromProtectedBaseBean; +import org.springframework.beans.test.fixtures.beans.BooleanTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.NumberTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.convert.ConversionFailedException; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.support.DefaultConversionService; @@ -50,11 +55,6 @@ import org.springframework.core.test.fixtures.Assume; import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.BooleanTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.IndexedTestBean; -import org.springframework.tests.sample.beans.NumberTestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.StopWatch; import org.springframework.util.StringUtils; diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java index 544d06750a92..948d1913f9bf 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java @@ -34,12 +34,12 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.propertyeditors.CustomDateEditor; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceEditor; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java index 5327e70a3a45..492cb10d4947 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java @@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.CustomEnum; +import org.springframework.beans.test.fixtures.beans.GenericBean; import org.springframework.core.convert.support.DefaultConversionService; -import org.springframework.tests.sample.beans.CustomEnum; -import org.springframework.tests.sample.beans.GenericBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java index 9205b2c5f995..9e6f50e2cfdc 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java @@ -33,11 +33,11 @@ import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.beans.propertyeditors.StringTrimmerEditor; +import org.springframework.beans.test.fixtures.beans.GenericBean; +import org.springframework.beans.test.fixtures.beans.GenericIntegerBean; +import org.springframework.beans.test.fixtures.beans.GenericSetOfIntegerBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.UrlResource; -import org.springframework.tests.sample.beans.GenericBean; -import org.springframework.tests.sample.beans.GenericIntegerBean; -import org.springframework.tests.sample.beans.GenericSetOfIntegerBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java index a46b1957d994..f9661e84492e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java b/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java index 4c867e3b69ef..78f2fdf5a73f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java @@ -22,8 +22,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.OverridingClassLoader; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; @@ -42,7 +42,7 @@ public void acceptAndClearClassLoader() throws Exception { assertThat(CachedIntrospectionResults.strongClassCache.containsKey(TestBean.class)).isTrue(); ClassLoader child = new OverridingClassLoader(getClass().getClassLoader()); - Class tbClass = child.loadClass("org.springframework.tests.sample.beans.TestBean"); + Class tbClass = child.loadClass("org.springframework.beans.test.fixtures.beans.TestBean"); assertThat(CachedIntrospectionResults.strongClassCache.containsKey(tbClass)).isFalse(); CachedIntrospectionResults.acceptClassLoader(child); bw = new BeanWrapperImpl(tbClass); diff --git a/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java b/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java index de10f1a982b6..9f7ff9dda23b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java index 640b1b920fb9..732e61131a55 100644 --- a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java index 4f7a9659bc0c..2fc77072a28e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java @@ -26,14 +26,14 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.StaticListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.AnnotatedBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.TestAnnotation; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; import org.springframework.cglib.proxy.NoOp; import org.springframework.core.io.Resource; -import org.springframework.tests.sample.beans.AnnotatedBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.IndexedTestBean; -import org.springframework.tests.sample.beans.TestAnnotation; -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.tests.sample.beans.factory.DummyFactory; import org.springframework.util.ObjectUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java index 20fde13c848e..6d50c6e1df66 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java @@ -78,6 +78,14 @@ import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.ConstructorDependenciesBean; import org.springframework.beans.propertyeditors.CustomNumberEditor; +import org.springframework.beans.test.fixtures.beans.DependenciesBean; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.LifecycleBean; +import org.springframework.beans.test.fixtures.beans.NestedTestBean; +import org.springframework.beans.test.fixtures.beans.SideEffectBean; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; import org.springframework.core.MethodParameter; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationAwareOrderComparator; @@ -91,14 +99,6 @@ import org.springframework.core.test.fixtures.TestGroup; import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.DependenciesBean; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.LifecycleBean; -import org.springframework.tests.sample.beans.NestedTestBean; -import org.springframework.tests.sample.beans.SideEffectBean; -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.tests.sample.beans.factory.DummyFactory; import org.springframework.util.StopWatch; import org.springframework.util.StringValueResolver; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java index 2a552309f637..e7e79b6b3e54 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java @@ -64,15 +64,15 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.NestedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.Ordered; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.Order; import org.springframework.core.test.fixtures.io.SerializationTestUtils; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.IndexedTestBean; -import org.springframework.tests.sample.beans.NestedTestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java index 2a39ac4fbafb..d6cd527c74ec 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java @@ -40,11 +40,11 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.NestedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.test.fixtures.io.SerializationTestUtils; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.IndexedTestBean; -import org.springframework.tests.sample.beans.NestedTestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java index a2bf1a162627..d610040ed688 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java index 921e76100c5c..3fa7f2b4e9ac 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java @@ -33,7 +33,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.propertyeditors.CustomDateEditor; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java index 770a6bddd0bf..e9241a8353b2 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; @@ -115,7 +115,7 @@ public void testJustTargetObject() throws Exception { @Test public void testWithConstantOnClassWithPackageLevelVisibility() throws Exception { FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean(); - fr.setBeanName("org.springframework.tests.sample.beans.PackageLevelVisibleBean.CONSTANT"); + fr.setBeanName("org.springframework.beans.test.fixtures.beans.PackageLevelVisibleBean.CONSTANT"); fr.afterPropertiesSet(); assertThat(fr.getObject()).isEqualTo("Wuby"); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java index c9ba85ae21be..1dc74c7115af 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java @@ -20,9 +20,9 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.Resource; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java index ac0643b3f28c..b3efca4647f3 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java @@ -24,9 +24,9 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java index cf8cf8ac18ae..f48ec3470c2a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java @@ -39,9 +39,9 @@ import org.springframework.beans.factory.support.ManagedMap; import org.springframework.beans.factory.support.ManagedSet; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.Resource; -import org.springframework.tests.sample.beans.IndexedTestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java index 5844bb080690..6bfc37ad9222 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java index c8287913ef8b..40b07c0b628a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java index 6d416cdcf798..de163b96e34e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java index a7af6e8f2924..e5fe0a0e8681 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinitionHolder; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java index e89a49b4b3be..311b87088907 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java @@ -43,6 +43,10 @@ import org.springframework.beans.factory.config.TypedStringValue; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.propertyeditors.CustomNumberEditor; +import org.springframework.beans.test.fixtures.beans.GenericBean; +import org.springframework.beans.test.fixtures.beans.GenericIntegerBean; +import org.springframework.beans.test.fixtures.beans.GenericSetOfIntegerBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.OverridingClassLoader; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationAwareOrderComparator; @@ -50,10 +54,6 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.UrlResource; import org.springframework.core.test.fixtures.EnabledForTestGroups; -import org.springframework.tests.sample.beans.GenericBean; -import org.springframework.tests.sample.beans.GenericIntegerBean; -import org.springframework.tests.sample.beans.GenericSetOfIntegerBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java index 303bc31ec4a9..a325c67a35ef 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java @@ -20,8 +20,8 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.ObjectFactory; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java index ca09f9ee8464..866556a180cd 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java @@ -20,7 +20,7 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.RuntimeBeanReference; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java index a12a21772b77..e6781ed74d42 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java @@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java index dd811aa41239..7efdfe4c0012 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java @@ -18,8 +18,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java index 8c5cb1e8b5c6..05fa60b0b4cc 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java @@ -21,7 +21,7 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java index 2ed794e57470..f7c2542aecc7 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java @@ -22,8 +22,8 @@ import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java index 720bf605f38f..bc119e2b1835 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java @@ -27,8 +27,8 @@ import org.springframework.beans.factory.support.BeanDefinitionReader; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java index 1cdd84ba9fad..e0ceb48a1edc 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java @@ -22,8 +22,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java index f4ca864f830e..df644ab49cca 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java @@ -18,8 +18,8 @@ import java.io.Serializable; -import org.springframework.tests.sample.beans.IndexedTestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; /** * Simple bean used to check constructor dependency checking. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java index 3a992e3334ba..2d2720ff1e3d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java @@ -17,7 +17,7 @@ package org.springframework.beans.factory.xml; import org.springframework.beans.factory.FactoryBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; /** * @author Juergen Hoeller diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java index 352e08958048..2c1a8b99b5b7 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java @@ -17,8 +17,8 @@ package org.springframework.beans.factory.xml; -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.tests.sample.beans.factory.DummyFactory; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; /** * @author Juergen Hoeller diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java index 983292c56aad..8f9a71541469 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java @@ -19,8 +19,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java index 7fef2df708e3..0d872c14fa20 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java @@ -30,8 +30,8 @@ import org.springframework.beans.factory.parsing.ImportDefinition; import org.springframework.beans.factory.parsing.PassThroughSourceExtractor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.beans.CollectingReaderEventListener; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java index 3985567eb54c..f6ac02ae32a9 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java @@ -25,8 +25,8 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java index 49fb74a1dd4f..80b7747d969e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java @@ -19,7 +19,7 @@ import java.util.Collections; import java.util.List; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; /** * Test class for Spring's ability to create objects using static diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java index 8cf0fa91099c..e5b1d4d24f3e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; /** * Test class for Spring's ability to create objects using diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java index 6934e5166bc2..a5bc425d7673 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java @@ -20,8 +20,8 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java index 1d51dc3f0bb1..c1fa690bf5ae 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java @@ -21,8 +21,8 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java index 0d4921e4138d..b6eef0422c75 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java @@ -20,9 +20,9 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.DummyBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.DummyBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java index b8f943fccd22..054e51e95fc7 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java @@ -20,9 +20,9 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java index adee655ad494..cf6eb8aa42cd 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; /** * Test class for Spring's ability to create diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java index be6be77551c5..2e0bb5bb33c2 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java @@ -32,10 +32,10 @@ import org.springframework.beans.factory.parsing.ComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; +import org.springframework.beans.test.fixtures.beans.CustomEnum; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.beans.CollectingReaderEventListener; -import org.springframework.tests.sample.beans.CustomEnum; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.LinkedCaseInsensitiveMap; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java index 17eadf0c61dc..51200a52e47b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java @@ -38,9 +38,9 @@ import org.springframework.beans.factory.config.MapFactoryBean; import org.springframework.beans.factory.config.SetFactoryBean; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.HasMap; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.HasMap; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java index 9b460c6601af..34474e075da3 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java @@ -25,10 +25,10 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.Resource; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ObjectUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java index d0b83d98155a..e3f69d70bfdc 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java @@ -30,11 +30,12 @@ import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.LifecycleBean; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; +import org.springframework.beans.test.fixtures.factory.xml.AbstractListableBeanFactoryTests; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.LifecycleBean; -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.tests.sample.beans.factory.DummyFactory; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java index 85bf11b9d619..eb3c0b6d7f18 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java @@ -43,11 +43,11 @@ import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.PropertyValue; -import org.springframework.tests.sample.beans.BooleanTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.IndexedTestBean; -import org.springframework.tests.sample.beans.NumberTestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.BooleanTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.NumberTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -593,9 +593,9 @@ public void testClassEditorWithNonExistentClass() throws Exception { @Test public void testClassEditorWithArray() { PropertyEditor classEditor = new ClassEditor(); - classEditor.setAsText("org.springframework.tests.sample.beans.TestBean[]"); + classEditor.setAsText("org.springframework.beans.test.fixtures.beans.TestBean[]"); assertThat(classEditor.getValue()).isEqualTo(TestBean[].class); - assertThat(classEditor.getAsText()).isEqualTo("org.springframework.tests.sample.beans.TestBean[]"); + assertThat(classEditor.getAsText()).isEqualTo("org.springframework.beans.test.fixtures.beans.TestBean[]"); } /* diff --git a/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java b/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java index 74a8769d7044..e244830c1c55 100644 --- a/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt b/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt index a254900fa36b..81c910b2b154 100644 --- a/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt +++ b/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt @@ -22,8 +22,8 @@ import org.junit.jupiter.api.Test import org.springframework.beans.factory.BeanCreationException import org.springframework.beans.factory.support.DefaultListableBeanFactory import org.springframework.beans.factory.support.RootBeanDefinition -import org.springframework.tests.sample.beans.Colour -import org.springframework.tests.sample.beans.TestBean +import org.springframework.beans.test.fixtures.beans.Colour +import org.springframework.beans.test.fixtures.beans.TestBean /** * Tests for Kotlin support with [Autowired]. diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-leaf.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-leaf.xml index e9abc664d662..08e3ff9ab394 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-leaf.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-leaf.xml @@ -3,7 +3,7 @@ - + custom 25 diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-middle.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-middle.xml index 4807313fed67..29fdf9a87253 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-middle.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-middle.xml @@ -4,7 +4,7 @@ - + custom 666 @@ -13,7 +13,7 @@ Check that invoker is automatically added to wrap target. Non pointcut bean name should be wrapped in invoker. --> - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-root.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-root.xml index 26560b27fb4c..75ee49e0ee72 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-root.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-root.xml @@ -6,21 +6,21 @@ - + - + - + - + custom 25 - + - + false diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests-context.xml index c14569c7fa57..7cb6892b03dc 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests-context.xml @@ -3,7 +3,7 @@ - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests-context.xml index dbcea8f953b0..9b1e2953138a 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests-context.xml @@ -3,19 +3,19 @@ - + 10 - + 11 - + 98 - + 99 @@ -23,7 +23,7 @@ - + 12 @@ -46,10 +46,10 @@ tb spouse - org.springframework.tests.sample.beans.TestBean + org.springframework.beans.test.fixtures.beans.TestBean - + @@ -59,11 +59,11 @@ - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/config/SimpleScopeTests-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/config/SimpleScopeTests-context.xml index 5a180e701381..22cfc5d272b4 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/config/SimpleScopeTests-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/config/SimpleScopeTests-context.xml @@ -3,6 +3,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/parsing/CustomProblemReporterTests-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/parsing/CustomProblemReporterTests-context.xml index 12b096820436..b1c5df805a98 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/parsing/CustomProblemReporterTests-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/parsing/CustomProblemReporterTests-context.xml @@ -6,7 +6,7 @@ - + @@ -14,9 +14,9 @@ - + - + @@ -26,5 +26,6 @@ - + + \ No newline at end of file diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/support/genericBeanTests.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/support/genericBeanTests.xml index c8a0ab7549d7..37f949c079b8 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/support/genericBeanTests.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/support/genericBeanTests.xml @@ -3,7 +3,7 @@ - + @@ -43,7 +43,7 @@ autowire="constructor"> - + @@ -53,7 +53,7 @@ - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/support/lookupMethodTests.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/support/lookupMethodTests.xml index 1334415c7460..2fb5d2204f58 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/support/lookupMethodTests.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/support/lookupMethodTests.xml @@ -13,9 +13,9 @@ - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/support/multiConstructorArgs.properties b/spring-beans/src/test/resources/org/springframework/beans/factory/support/multiConstructorArgs.properties index 8d5f74fc31a9..529c97ce9e17 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/support/multiConstructorArgs.properties +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/support/multiConstructorArgs.properties @@ -1,3 +1,3 @@ -testBean.(class)=org.springframework.tests.sample.beans.TestBean +testBean.(class)=org.springframework.beans.test.fixtures.beans.TestBean testBean.$0=Rob Harrop testBean.$1=23 diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/support/refConstructorArg.properties b/spring-beans/src/test/resources/org/springframework/beans/factory/support/refConstructorArg.properties index 4d3723c7de8a..ff4aff4552ec 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/support/refConstructorArg.properties +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/support/refConstructorArg.properties @@ -1,5 +1,5 @@ -sally.(class)=org.springframework.tests.sample.beans.TestBean +sally.(class)=org.springframework.beans.test.fixtures.beans.TestBean sally.name=Sally -rob.(class)=org.springframework.tests.sample.beans.TestBean +rob.(class)=org.springframework.beans.test.fixtures.beans.TestBean rob.$0(ref)=sally diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/support/simpleConstructorArg.properties b/spring-beans/src/test/resources/org/springframework/beans/factory/support/simpleConstructorArg.properties index d0f1eea32665..8d4246bba2be 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/support/simpleConstructorArg.properties +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/support/simpleConstructorArg.properties @@ -1,2 +1,2 @@ -testBean.(class)=org.springframework.tests.sample.beans.TestBean +testBean.(class)=org.springframework.beans.test.fixtures.beans.TestBean testBean.$0=Rob Harrop diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-multiLevel-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-multiLevel-context.xml index f5f975bf7b51..ee803599bb66 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-multiLevel-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-multiLevel-context.xml @@ -4,12 +4,12 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-sameLevel-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-sameLevel-context.xml index 7bd11a987175..58e3415afc8d 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-sameLevel-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-sameLevel-context.xml @@ -4,12 +4,12 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests-merge-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests-merge-context.xml index 55a5cf04e7fe..10015b0fc0de 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests-merge-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests-merge-context.xml @@ -5,7 +5,7 @@ https://www.springframework.org/schema/beans/spring-beans-3.1.xsd" default-merge="false"> - + alpha diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-constructor-with-exclusion.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-constructor-with-exclusion.xml index 0b67be5d8748..8f5f1b01b1ed 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-constructor-with-exclusion.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-constructor-with-exclusion.xml @@ -3,9 +3,9 @@ - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-exclusion.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-exclusion.xml index 37a98d0ce810..26651d8bbbed 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-exclusion.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-exclusion.xml @@ -3,9 +3,9 @@ - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-inclusion.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-inclusion.xml index b47d4231ce0c..0b9bb1ceb03c 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-inclusion.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-inclusion.xml @@ -4,9 +4,9 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd" default-autowire-candidates=""> - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-selective-inclusion.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-selective-inclusion.xml index 5df4f9c21dca..d23d1888d212 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-selective-inclusion.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-selective-inclusion.xml @@ -4,9 +4,9 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd" default-autowire-candidates="props*,*ly"> - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/beanEvents.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/beanEvents.xml index 9b019ee2ff2a..7a5640559d3a 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/beanEvents.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/beanEvents.xml @@ -10,22 +10,22 @@ - + - + - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionMerging.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionMerging.xml index b3a6142b54fa..9243ec32bc4d 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionMerging.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionMerging.xml @@ -3,7 +3,7 @@ - + Rob Harrop @@ -23,12 +23,12 @@ - + - + Rob Harrop @@ -47,14 +47,14 @@ - + - + @@ -76,7 +76,7 @@ - + @@ -84,7 +84,7 @@ - + Sall @@ -103,7 +103,7 @@ - + Rob Harrop @@ -123,12 +123,12 @@ - + - + Rob Harrop @@ -147,14 +147,14 @@ - + - + @@ -176,7 +176,7 @@ - + @@ -184,7 +184,7 @@ - + Sall diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml index 0f2fff8c9b91..d245ac3afc3b 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - + Jenny 30 @@ -12,7 +12,7 @@ - + Simple bean, without any collections. @@ -23,7 +23,7 @@ 27 - + Rod 32 @@ -35,7 +35,7 @@ - + Jenny 30 @@ -43,13 +43,13 @@ - + David 27 - + Rod 32 @@ -63,7 +63,7 @@ - + loner 26 @@ -101,26 +101,26 @@ - + verbose - + - + - + - + @@ -130,7 +130,7 @@ - + @@ -157,7 +157,7 @@ - + @@ -176,7 +176,7 @@ - + @@ -185,7 +185,7 @@ - + @@ -217,14 +217,14 @@ - + - + bar @@ -234,7 +234,7 @@ - + bar @@ -244,7 +244,7 @@ - + @@ -253,7 +253,7 @@ - + @@ -261,7 +261,7 @@ - + bar @@ -270,7 +270,7 @@ - + @@ -279,7 +279,7 @@ - + one @@ -288,7 +288,7 @@ - + 0 @@ -298,11 +298,11 @@ - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionsWithDefaultTypes.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionsWithDefaultTypes.xml index 92d5d3db1dbd..e68a24410a74 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionsWithDefaultTypes.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionsWithDefaultTypes.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - + 1 @@ -28,7 +28,7 @@ - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml index 86d94732956d..d9ba0aaeba67 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml @@ -107,7 +107,7 @@ - + Juergen @@ -130,7 +130,7 @@ - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/schemaValidated.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/schemaValidated.xml index 5f22ea3cef42..5fc58aa6093a 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/schemaValidated.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/schemaValidated.xml @@ -3,16 +3,16 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> - + - + - + - - + + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTests.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTests.xml index 0c6b70e59ac5..eab699ae5f6e 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTests.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTests.xml @@ -5,43 +5,43 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + - + - + - + - + - + \ No newline at end of file diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTestsWithErrors.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTestsWithErrors.xml index 932492e9d14c..037baf8b0939 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTestsWithErrors.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTestsWithErrors.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTests.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTests.xml index 7b62d39e2792..82954f02b3ab 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTests.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTests.xml @@ -4,20 +4,20 @@ xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + - + - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTestsWithErrors.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTestsWithErrors.xml index c0335508acc8..a761f9e86a8c 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTestsWithErrors.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTestsWithErrors.xml @@ -4,10 +4,10 @@ xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/test.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/test.xml index 3a0b944bef3c..d1bf86605390 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/test.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/test.xml @@ -3,7 +3,7 @@ - + I have no properties and I'm happy without them. @@ -12,7 +12,7 @@ - + aliased @@ -20,17 +20,17 @@ - + aliased - + aliased - + @@ -40,7 +40,7 @@ - + Rod 31 @@ -52,29 +52,29 @@ - + Kerry 34 - + Kathy 28 - + typeMismatch 34x - + - true @@ -85,10 +85,10 @@ - + - + false @@ -113,14 +113,14 @@ - + listenerVeto 66 - + - + this is a ]]> diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/testUtilNamespace.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/testUtilNamespace.xml index b2bad9b4c515..47bce335d181 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/testUtilNamespace.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/testUtilNamespace.xml @@ -17,7 +17,7 @@ name "/> - + @@ -26,13 +26,13 @@ - + - + @@ -50,7 +50,7 @@ + key-type="java.lang.String" value-type="org.springframework.beans.test.fixtures.beans.TestBean"> @@ -72,7 +72,7 @@ Rob Harrop - + foo @@ -94,13 +94,13 @@ - + - + @@ -116,13 +116,13 @@ min - + - + @@ -152,7 +152,7 @@ - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithDtd.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithDtd.xml index a872ae9d23d7..f58440bfa423 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithDtd.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithDtd.xml @@ -9,5 +9,5 @@ This is a top level block comment - + \ No newline at end of file diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithXsd.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithXsd.xml index c7e8abe5a55b..615980708143 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithXsd.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithXsd.xml @@ -7,5 +7,5 @@ This is a top level block comment the parser now --> - + \ No newline at end of file diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/withMeta.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/withMeta.xml index 5126d253957b..4148dffe92a6 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/withMeta.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/withMeta.xml @@ -4,15 +4,15 @@ xmlns:spring="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - + - + - + diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/AgeHolder.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AgeHolder.java similarity index 93% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/AgeHolder.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AgeHolder.java index adced8acea9a..e48d4ff72500 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/AgeHolder.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AgeHolder.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; public interface AgeHolder { diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/AnnotatedBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AnnotatedBean.java similarity index 92% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/AnnotatedBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AnnotatedBean.java index 6b4e063563bd..9a071690a352 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/AnnotatedBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AnnotatedBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** * @author Stephane Nicoll diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/BooleanTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/BooleanTestBean.java similarity index 94% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/BooleanTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/BooleanTestBean.java index bf6105ca55f6..52375b011383 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/BooleanTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/BooleanTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** * @author Juergen Hoeller diff --git a/spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CollectingReaderEventListener.java similarity index 98% rename from spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CollectingReaderEventListener.java index c46e59c3665a..2145e26679f6 100644 --- a/spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CollectingReaderEventListener.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.beans; +package org.springframework.beans.test.fixtures.beans; import java.util.ArrayList; import java.util.Collection; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/Colour.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Colour.java similarity index 95% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/Colour.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Colour.java index a1910a9dfa41..011dbf0edb3e 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/Colour.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Colour.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** * @author Rob Harrop diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/CountingTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CountingTestBean.java similarity index 93% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/CountingTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CountingTestBean.java index 74faeba68b85..892f71d5305f 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/CountingTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CountingTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/CustomEnum.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CustomEnum.java similarity index 93% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/CustomEnum.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CustomEnum.java index dec612088da0..5bb56eaf26f5 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/CustomEnum.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CustomEnum.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** * @author Juergen Hoeller diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/DependenciesBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DependenciesBean.java similarity index 96% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/DependenciesBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DependenciesBean.java index 4f0e958c7f74..cb81eb3b1696 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/DependenciesBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DependenciesBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/DerivedTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DerivedTestBean.java similarity index 97% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/DerivedTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DerivedTestBean.java index 92c62dd5da87..6851deb9973a 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/DerivedTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DerivedTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import java.io.Serializable; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/DummyBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyBean.java similarity index 96% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/DummyBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyBean.java index cae1b3993305..caa0a461b5b3 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/DummyBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyBean.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** * @author Costin Leau diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/DummyFactory.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyFactory.java similarity index 98% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/DummyFactory.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyFactory.java index 3939fc9372d6..623884a8acc0 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/DummyFactory.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; diff --git a/spring-context/src/test/java/org/springframework/tests/sample/beans/Employee.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Employee.java similarity index 88% rename from spring-context/src/test/java/org/springframework/tests/sample/beans/Employee.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Employee.java index 86c3eedb19d8..eaf350ed1e38 100644 --- a/spring-context/src/test/java/org/springframework/tests/sample/beans/Employee.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Employee.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; public class Employee extends TestBean { diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericBean.java similarity index 99% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericBean.java index 26b536b78664..6946e890f8f4 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import java.util.ArrayList; import java.util.Collection; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericIntegerBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericIntegerBean.java similarity index 92% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericIntegerBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericIntegerBean.java index 398ca1e06cd8..375d57fac97d 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericIntegerBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericIntegerBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericSetOfIntegerBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericSetOfIntegerBean.java similarity index 93% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericSetOfIntegerBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericSetOfIntegerBean.java index cbd0a043a6b9..d39f9078b79d 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericSetOfIntegerBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericSetOfIntegerBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import java.util.Set; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/HasMap.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/HasMap.java similarity index 97% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/HasMap.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/HasMap.java index 29359e4c5581..02cf25b1ca8f 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/HasMap.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/HasMap.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import java.util.IdentityHashMap; import java.util.List; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/INestedTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/INestedTestBean.java similarity index 92% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/INestedTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/INestedTestBean.java index adf4f46168fb..ab83dd232241 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/INestedTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/INestedTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; public interface INestedTestBean { diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/IOther.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IOther.java similarity index 92% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/IOther.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IOther.java index f674ff7bb712..36d287fc9aac 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/IOther.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IOther.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; public interface IOther { diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/ITestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/ITestBean.java similarity index 92% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/ITestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/ITestBean.java index 1fe055dac0b6..9572e1265e0e 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/ITestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/ITestBean.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import java.io.IOException; /** - * Interface used for {@link org.springframework.tests.sample.beans.TestBean}. + * Interface used for {@link org.springframework.beans.test.fixtures.beans.TestBean}. * *

    Two methods are the same as on Person, but if this * extends person it breaks quite a few tests.. diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/IndexedTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IndexedTestBean.java similarity index 98% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/IndexedTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IndexedTestBean.java index 2c8f85189fc7..92de9d367806 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/IndexedTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IndexedTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import java.util.ArrayList; import java.util.Collection; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/LifecycleBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/LifecycleBean.java similarity index 98% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/LifecycleBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/LifecycleBean.java index 67712dd76079..3a070b01e524 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/LifecycleBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/LifecycleBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/MustBeInitialized.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/MustBeInitialized.java similarity index 96% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/MustBeInitialized.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/MustBeInitialized.java index 2dde17d219f4..39309643620d 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/MustBeInitialized.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/MustBeInitialized.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import org.springframework.beans.factory.InitializingBean; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/NestedTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NestedTestBean.java similarity index 96% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/NestedTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NestedTestBean.java index 46e6a9110f67..179fa2a561d8 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/NestedTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NestedTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** * Simple nested test bean used for testing bean factories, AOP framework etc. diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/NumberTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NumberTestBean.java similarity index 97% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/NumberTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NumberTestBean.java index 08b1649d42ad..e8874a2f92e1 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/NumberTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NumberTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import java.math.BigDecimal; import java.math.BigInteger; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/PackageLevelVisibleBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/PackageLevelVisibleBean.java similarity index 93% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/PackageLevelVisibleBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/PackageLevelVisibleBean.java index 1f446321132f..1a7300325d8f 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/PackageLevelVisibleBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/PackageLevelVisibleBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** * @see org.springframework.beans.factory.config.FieldRetrievingFactoryBeanTests diff --git a/spring-aop/src/test/java/org/springframework/tests/sample/beans/Person.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Person.java similarity index 94% rename from spring-aop/src/test/java/org/springframework/tests/sample/beans/Person.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Person.java index 1e9acb09646e..37f5a55a9cb6 100644 --- a/spring-aop/src/test/java/org/springframework/tests/sample/beans/Person.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Person.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** * diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/Pet.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Pet.java similarity index 95% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/Pet.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Pet.java index 5e9040db0c0b..44073a367c70 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/Pet.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Pet.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** * @author Rob Harrop diff --git a/spring-aop/src/test/java/org/springframework/tests/sample/beans/SerializablePerson.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SerializablePerson.java similarity index 96% rename from spring-aop/src/test/java/org/springframework/tests/sample/beans/SerializablePerson.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SerializablePerson.java index 0496d09a9682..e9d9398deff0 100644 --- a/spring-aop/src/test/java/org/springframework/tests/sample/beans/SerializablePerson.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SerializablePerson.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import java.io.Serializable; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/SideEffectBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SideEffectBean.java similarity index 94% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/SideEffectBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SideEffectBean.java index ac09e8d76425..cc1333610ed0 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/SideEffectBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SideEffectBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; /** * Bean that changes state on a business invocation, so that diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/TestAnnotation.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestAnnotation.java similarity index 93% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/TestAnnotation.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestAnnotation.java index ed1b8d528975..83090e6bb83d 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/TestAnnotation.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestAnnotation.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/TestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestBean.java similarity index 96% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/TestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestBean.java index 1e83a21a13ce..9cd31e42f00f 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/TestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; import java.io.IOException; import java.util.ArrayList; @@ -421,7 +421,7 @@ public void setPets(List pets) { /** - * @see org.springframework.tests.sample.beans.ITestBean#exceptional(Throwable) + * @see org.springframework.beans.test.fixtures.beans.ITestBean#exceptional(Throwable) */ @Override public void exceptional(Throwable t) throws Throwable { @@ -435,7 +435,7 @@ public void unreliableFileOperation() throws IOException { throw new IOException(); } /** - * @see org.springframework.tests.sample.beans.ITestBean#returnsThis() + * @see org.springframework.beans.test.fixtures.beans.ITestBean#returnsThis() */ @Override public Object returnsThis() { @@ -443,7 +443,7 @@ public Object returnsThis() { } /** - * @see org.springframework.tests.sample.beans.IOther#absquatulate() + * @see org.springframework.beans.test.fixtures.beans.IOther#absquatulate() */ @Override public void absquatulate() { diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/factory/DummyFactory.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/factory/DummyFactory.java similarity index 97% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/factory/DummyFactory.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/factory/DummyFactory.java index e707f05853d7..ea27e526d174 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/factory/DummyFactory.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/factory/DummyFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans.factory; +package org.springframework.beans.test.fixtures.beans.factory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; @@ -24,7 +24,7 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; /** * Simple factory to allow testing of FactoryBean support in AbstractBeanFactory. diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/package-info.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/package-info.java similarity index 55% rename from spring-beans/src/test/java/org/springframework/tests/sample/beans/package-info.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/package-info.java index 575bd1933f9b..010c228ef82e 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/package-info.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/package-info.java @@ -1,4 +1,4 @@ /** * General purpose sample beans that can be used with tests. */ -package org.springframework.tests.sample.beans; +package org.springframework.beans.test.fixtures.beans; diff --git a/spring-aop/src/test/java/org/springframework/tests/sample/beans/subpkg/DeepBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/subpkg/DeepBean.java similarity index 74% rename from spring-aop/src/test/java/org/springframework/tests/sample/beans/subpkg/DeepBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/subpkg/DeepBean.java index 41dd7e33b9cb..fb5950c205c4 100644 --- a/spring-aop/src/test/java/org/springframework/tests/sample/beans/subpkg/DeepBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/subpkg/DeepBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2019 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. @@ -14,14 +14,12 @@ * limitations under the License. */ -package org.springframework.tests.sample.beans.subpkg; - -import org.springframework.aop.aspectj.AspectJExpressionPointcutTests; +package org.springframework.beans.test.fixtures.beans.subpkg; /** * Used for testing pointcut matching. * - * @see AspectJExpressionPointcutTests#testWithinRootAndSubpackages() + * @see org.springframework.aop.aspectj.AspectJExpressionPointcutTests#testWithinRootAndSubpackages() * * @author Chris Beams */ diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractBeanFactoryTests.java similarity index 96% rename from spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractBeanFactoryTests.java index 31c1984c35c3..5695b05d4aa8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractBeanFactoryTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.factory.xml; +package org.springframework.beans.test.fixtures.factory.xml; import java.beans.PropertyEditorSupport; import java.util.StringTokenizer; @@ -29,10 +29,10 @@ import org.springframework.beans.factory.BeanNotOfRequiredTypeException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.tests.sample.beans.LifecycleBean; -import org.springframework.tests.sample.beans.MustBeInitialized; -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.tests.sample.beans.factory.DummyFactory; +import org.springframework.beans.test.fixtures.beans.LifecycleBean; +import org.springframework.beans.test.fixtures.beans.MustBeInitialized; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractListableBeanFactoryTests.java b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractListableBeanFactoryTests.java similarity index 90% rename from spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractListableBeanFactoryTests.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractListableBeanFactoryTests.java index dbae0ebed703..2d319fe47f16 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractListableBeanFactoryTests.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractListableBeanFactoryTests.java @@ -14,14 +14,14 @@ * limitations under the License. */ -package org.springframework.beans.factory.xml; +package org.springframework.beans.test.fixtures.factory.xml; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; @@ -55,13 +55,13 @@ protected final void assertCount(int count) { protected void assertTestBeanCount(int count) { String[] defNames = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, false); - assertThat(defNames.length == count).as("We should have " + count + " beans for class org.springframework.tests.sample.beans.TestBean, not " + + assertThat(defNames.length == count).as("We should have " + count + " beans for class org.springframework.beans.test.fixtures.beans.TestBean, not " + defNames.length).isTrue(); int countIncludingFactoryBeans = count + 2; String[] names = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, true); assertThat(names.length == countIncludingFactoryBeans).as("We should have " + countIncludingFactoryBeans + - " beans for class org.springframework.tests.sample.beans.TestBean, not " + names.length).isTrue(); + " beans for class org.springframework.beans.test.fixtures.beans.TestBean, not " + names.length).isTrue(); } @Test diff --git a/spring-context-support/spring-context-support.gradle b/spring-context-support/spring-context-support.gradle index f2fb5feedeb1..be8fb24dfeb9 100644 --- a/spring-context-support/spring-context-support.gradle +++ b/spring-context-support/spring-context-support.gradle @@ -15,6 +15,8 @@ dependencies { optional("org.codehaus.fabric3.api:commonj") optional("org.freemarker:freemarker") testCompile(project(":spring-context")) + testCompile(testFixtures(project(":spring-beans"))) + testCompile(testFixtures(project(":spring-context"))) testCompile(testFixtures(project(":spring-core"))) testCompile("org.hsqldb:hsqldb") testCompile("org.hibernate:hibernate-validator") diff --git a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java index eae5f14bb449..07af88796fb4 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java @@ -20,8 +20,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.cache.AbstractValueAdaptingCacheTests; import org.springframework.cache.Cache; +import org.springframework.context.test.fixtures.cache.AbstractValueAdaptingCacheTests; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java index b35768a7bf9a..e5a548cacd2d 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.cache.AbstractCacheTests; +import org.springframework.context.test.fixtures.cache.AbstractCacheTests; import org.springframework.core.test.fixtures.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java index 1c0031854174..bb7741478f1c 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java @@ -28,17 +28,17 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; -import org.springframework.cache.config.AbstractCacheAnnotationTests; -import org.springframework.cache.config.AnnotatedClassCacheableService; -import org.springframework.cache.config.CacheableService; -import org.springframework.cache.config.DefaultCacheableService; -import org.springframework.cache.config.SomeCustomKeyGenerator; import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.cache.interceptor.SimpleKeyGenerator; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.test.fixtures.cache.AbstractCacheAnnotationTests; +import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator; +import org.springframework.context.test.fixtures.cache.beans.AnnotatedClassCacheableService; +import org.springframework.context.test.fixtures.cache.beans.CacheableService; +import org.springframework.context.test.fixtures.cache.beans.DefaultCacheableService; import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.support.TransactionTemplate; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java index d0797dd92696..4f9adba6ee8a 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.springframework.cache.AbstractValueAdaptingCacheTests; +import org.springframework.context.test.fixtures.cache.AbstractValueAdaptingCacheTests; /** * @author Stephane Nicoll diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java index 60555a7a3e76..b7f3007dd78d 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java @@ -25,7 +25,6 @@ import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.concurrent.ConcurrentMapCache; import org.springframework.cache.concurrent.ConcurrentMapCacheManager; -import org.springframework.cache.config.SomeKeyGenerator; import org.springframework.cache.interceptor.CacheErrorHandler; import org.springframework.cache.interceptor.CacheResolver; import org.springframework.cache.interceptor.KeyGenerator; @@ -43,6 +42,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.test.fixtures.cache.SomeKeyGenerator; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java index 3e22f8483523..c6b4efeff831 100644 --- a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java +++ b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java @@ -34,12 +34,12 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.StaticApplicationContext; import org.springframework.core.task.TaskExecutor; import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/BeanValidationPostProcessorTests.java b/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/BeanValidationPostProcessorTests.java index 0f6e099f6f48..39c6aae3808a 100644 --- a/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/BeanValidationPostProcessorTests.java +++ b/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/BeanValidationPostProcessorTests.java @@ -24,9 +24,9 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.beanvalidation.BeanValidationPostProcessor; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/spring-context.gradle b/spring-context/spring-context.gradle index 0894c8d55f02..77ab633b3e47 100644 --- a/spring-context/spring-context.gradle +++ b/spring-context/spring-context.gradle @@ -26,6 +26,7 @@ dependencies { optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") optional("org.reactivestreams:reactive-streams") + testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-core"))) testCompile("io.projectreactor:reactor-core") testCompile("org.codehaus.groovy:groovy-jsr223") @@ -41,4 +42,8 @@ dependencies { testRuntime("org.glassfish:javax.el") testRuntime("org.javamoney:moneta") testRuntime("org.junit.vintage:junit-vintage-engine") // for @Inject TCK + testFixturesApi("org.junit.jupiter:junit-jupiter-api") + testFixturesImplementation(testFixtures(project(":spring-beans"))) + testFixturesImplementation("com.google.code.findbugs:jsr305") + testFixturesImplementation("org.assertj:assertj-core") } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java index e23567fe45ea..b5046caae516 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java @@ -22,9 +22,9 @@ import org.springframework.aop.aspectj.AdviceBindingTestAspect.AdviceBindingCollaborator; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java index 864cdad0837c..224e749c670b 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java @@ -22,9 +22,9 @@ import org.springframework.aop.aspectj.AfterReturningAdviceBindingTestAspect.AfterReturningAdviceBindingCollaborator; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java index 89acdb48e4b2..95829f7c96ee 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java @@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.aspectj.AfterThrowingAdviceBindingTestAspect.AfterThrowingAdviceBindingCollaborator; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.Mockito.mock; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java index bc7afb597800..f01b706f3ac8 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java @@ -23,10 +23,10 @@ import org.springframework.aop.aspectj.AroundAdviceBindingTestAspect.AroundAdviceBindingCollaborator; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java index 9f61a85b1b67..159d40ef02b8 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java @@ -24,10 +24,10 @@ import org.springframework.aop.MethodBeforeAdvice; import org.springframework.beans.factory.BeanNameAware; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.Ordered; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.ITestBean; /** * @author Adrian Colyer diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java index b912acd586eb..53441e6f8525 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java index 1f0bee00d20c..60de4114d9d8 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java @@ -22,9 +22,9 @@ import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; import org.springframework.aop.framework.Advised; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java index 38068cb9d2d6..f315b7643b16 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java @@ -25,9 +25,9 @@ import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java index 05deebd0044e..e3be4ccc2006 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java @@ -22,9 +22,9 @@ import org.springframework.aop.aspectj.AdviceBindingTestAspect.AdviceBindingCollaborator; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java index 5c86668424f7..ce1c128623f9 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java @@ -21,8 +21,8 @@ import test.mixin.Lockable; import org.springframework.aop.support.AopUtils; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.java index 8c2ce72a22cf..0ac74719adcd 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2019 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.aop.aspectj; import org.aspectj.lang.ProceedingJoinPoint; @@ -20,8 +21,8 @@ import org.aspectj.lang.annotation.Aspect; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.TestBean; /** * Tests to check if the first implicit join point argument is correctly processed. @@ -33,14 +34,15 @@ public class ImplicitJPArgumentMatchingAtAspectJTests { @Test + @SuppressWarnings("resource") public void testAspect() { - // nothing to really test; it is enough if we don't get error while creating app context + // nothing to really test; it is enough if we don't get error while creating the app context new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); } @Aspect static class CounterAtAspectJAspect { - @Around(value="execution(* org.springframework.tests.sample.beans.TestBean.*(..)) and this(bean) and args(argument)", + @Around(value="execution(* org.springframework.beans.test.fixtures.beans.TestBean.*(..)) and this(bean) and args(argument)", argNames="bean,argument") public void increment(ProceedingJoinPoint pjp, TestBean bean, Object argument) throws Throwable { pjp.proceed(); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java index f92eee68ab99..f4b650f8da62 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java @@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorAndLazyInitTargetSourceTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorAndLazyInitTargetSourceTests.java index 84e3e1176fd4..43c9226c9953 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorAndLazyInitTargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorAndLazyInitTargetSourceTests.java @@ -18,9 +18,9 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java index 8c88ad34b78a..fee1f223aebf 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java @@ -43,6 +43,10 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.INestedTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.NestedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.GenericApplicationContext; @@ -54,10 +58,6 @@ import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.core.test.fixtures.TestGroup; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.INestedTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.NestedTestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java index 002159ef739b..eb254e8dd1ca 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java @@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; @@ -64,7 +64,7 @@ class ExceptionHandlingAspect { public IOException lastException; - @AfterThrowing(pointcut = "within(org.springframework.tests.sample.beans.ITestBean+)", throwing = "ex") + @AfterThrowing(pointcut = "within(org.springframework.beans.test.fixtures.beans.ITestBean+)", throwing = "ex") public void handleIOException(IOException ex) { handled++; lastException = ex; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java index 1557110b08a4..0ed10779ddc6 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java @@ -32,8 +32,8 @@ import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.aop.support.StaticMethodMatcherPointcut; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java index ff70f11c0f5f..2b37c428ab1e 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java @@ -25,9 +25,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java b/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java index f6a807125d43..a57e1113e3ac 100644 --- a/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java +++ b/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java @@ -20,7 +20,7 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; -import org.springframework.tests.sample.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java index c359b76fc603..3b5af8a87a48 100644 --- a/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java @@ -23,11 +23,11 @@ import org.springframework.aop.Advisor; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.tests.aop.advice.CountingBeforeAdvice; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java index 8fb952e12f0c..3876a78a33d4 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java @@ -57,6 +57,11 @@ import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; import org.springframework.aop.target.HotSwappableTargetSource; import org.springframework.aop.target.SingletonTargetSource; +import org.springframework.beans.test.fixtures.beans.IOther; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.Person; +import org.springframework.beans.test.fixtures.beans.SerializablePerson; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.core.test.fixtures.TestGroup; import org.springframework.core.test.fixtures.TimeStamped; @@ -69,11 +74,6 @@ import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import org.springframework.tests.aop.interceptor.TimestampIntroductionInterceptor; -import org.springframework.tests.sample.beans.IOther; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.Person; -import org.springframework.tests.sample.beans.SerializablePerson; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java index d324c58c5989..aec81a331e8c 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java @@ -28,13 +28,13 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.DefaultPointcutAdvisor; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java index 732d867aa24e..d34ac00a3ad0 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java @@ -24,9 +24,9 @@ import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.support.AopUtils; -import org.springframework.tests.sample.beans.IOther; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.IOther; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java index 24c744ccba74..22ca040e5173 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java @@ -45,8 +45,12 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.Person; +import org.springframework.beans.test.fixtures.beans.SideEffectBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationListener; -import org.springframework.context.TestListener; +import org.springframework.context.test.fixtures.beans.TestApplicationListener; import org.springframework.core.io.ClassPathResource; import org.springframework.core.test.fixtures.TimeStamped; import org.springframework.core.test.fixtures.io.SerializationTestUtils; @@ -55,10 +59,6 @@ import org.springframework.tests.aop.advice.MyThrowsHandler; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.aop.interceptor.TimestampIntroductionInterceptor; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.Person; -import org.springframework.tests.sample.beans.SideEffectBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -93,7 +93,7 @@ public class ProxyFactoryBeanTests { @BeforeEach public void setUp() throws Exception { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); - parent.registerBeanDefinition("target2", new RootBeanDefinition(TestListener.class)); + parent.registerBeanDefinition("target2", new RootBeanDefinition(TestApplicationListener.class)); this.factory = new DefaultListableBeanFactory(parent); new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.factory).loadBeanDefinitions( new ClassPathResource(CONTEXT, getClass())); diff --git a/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java b/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java index 0c285b6bee21..cb71798c54f6 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java @@ -28,8 +28,8 @@ import org.springframework.aop.Advisor; import org.springframework.aop.BeforeAdvice; import org.springframework.aop.framework.Advised; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java index 46fde4423f4e..1b83b1680d12 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java @@ -31,11 +31,11 @@ import org.springframework.aop.target.PrototypeTargetSource; import org.springframework.aop.target.ThreadLocalTargetSource; import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.test.fixtures.beans.CountingTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.sample.beans.CountingTestBean; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java index 3bcb291eccbb..e2565bde7910 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java @@ -37,16 +37,16 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.MessageSource; import org.springframework.context.support.StaticApplicationContext; import org.springframework.context.support.StaticMessageSource; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.IndexedTestBean; -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.tests.sample.beans.factory.DummyFactory; import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java index 6b18de04ffe6..2374a56fcbb4 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java @@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.MethodBeforeAdvice; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java index 1af446bf16fe..e60395ef6f86 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java @@ -25,12 +25,12 @@ import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.test.fixtures.TimeStamped; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java index 82e9f0100439..3a2bf91f916d 100644 --- a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java @@ -25,12 +25,12 @@ import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; +import org.springframework.context.test.fixtures.SimpleMapScope; import org.springframework.core.io.ClassPathResource; import org.springframework.core.test.fixtures.io.SerializationTestUtils; -import org.springframework.tests.context.SimpleMapScope; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java index beb840ae6ca3..0c2390d12435 100644 --- a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java @@ -25,12 +25,12 @@ import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.Person; +import org.springframework.beans.test.fixtures.beans.SerializablePerson; +import org.springframework.beans.test.fixtures.beans.SideEffectBean; import org.springframework.context.support.StaticApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.test.fixtures.io.SerializationTestUtils; -import org.springframework.tests.sample.beans.Person; -import org.springframework.tests.sample.beans.SerializablePerson; -import org.springframework.tests.sample.beans.SideEffectBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java index b96476066088..275ddd9fcbb0 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java @@ -20,9 +20,9 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.interceptor.DebugInterceptor; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerWithExpressionLanguageTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerWithExpressionLanguageTests.java index a6c9a870f6e4..18ef636ee135 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerWithExpressionLanguageTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerWithExpressionLanguageTests.java @@ -18,9 +18,9 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java index f9d5edba0dbb..936981add7b3 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java @@ -33,10 +33,10 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.support.MethodReplacer; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.IndexedTestBean; -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.tests.sample.beans.factory.DummyFactory; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; /** * Types used by {@link XmlBeanFactoryTests} and its attendant XML config files. diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java index d820baa13561..311a933b21a0 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java @@ -51,18 +51,18 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.MethodReplacer; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.DependenciesBean; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.UrlResource; import org.springframework.core.io.support.EncodedResource; import org.springframework.core.test.fixtures.io.SerializationTestUtils; -import org.springframework.tests.sample.beans.DependenciesBean; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.IndexedTestBean; import org.springframework.tests.sample.beans.ResourceTestBean; -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.tests.sample.beans.factory.DummyFactory; import org.springframework.util.ClassUtils; import org.springframework.util.FileCopyUtils; import org.springframework.util.StopWatch; diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java index a280952bc4ac..a03a18f4a1e3 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java @@ -51,13 +51,13 @@ import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.PluggableSchemaResolver; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationListener; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java b/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java index 2d9ca8f647f2..4ade8ae382a6 100644 --- a/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java +++ b/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java @@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Caching; @@ -39,7 +40,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java index 2a6d4641c7d2..e933a9bf028e 100644 --- a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java +++ b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.cache.AbstractValueAdaptingCacheTests; +import org.springframework.context.test.fixtures.cache.AbstractValueAdaptingCacheTests; import org.springframework.core.serializer.support.SerializationDelegate; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/cache/config/AnnotationDrivenCacheConfigTests.java b/spring-context/src/test/java/org/springframework/cache/config/AnnotationDrivenCacheConfigTests.java index 81c3764536ed..1e99b6f79658 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/AnnotationDrivenCacheConfigTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/AnnotationDrivenCacheConfigTests.java @@ -18,6 +18,7 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; +import org.springframework.context.test.fixtures.cache.AbstractCacheAnnotationTests; /** * @author Costin Leau diff --git a/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java b/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java index 13a420feef8c..e032e3674222 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java @@ -22,6 +22,7 @@ import org.springframework.cache.interceptor.CacheInterceptor; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; +import org.springframework.context.test.fixtures.cache.AbstractCacheAnnotationTests; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java b/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java index 097559767d53..5b679a3269e8 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java @@ -21,6 +21,7 @@ import org.springframework.cache.interceptor.CacheInterceptor; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; +import org.springframework.context.test.fixtures.cache.AbstractCacheAnnotationTests; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java b/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java index cc8aeb18ba8c..b94b3811de45 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import org.springframework.cache.CacheManager; -import org.springframework.cache.CacheTestUtils; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.interceptor.CacheInterceptor; import org.springframework.cache.interceptor.CacheOperationInvoker; @@ -33,6 +32,9 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.test.fixtures.cache.CacheTestUtils; +import org.springframework.context.test.fixtures.cache.beans.CacheableService; +import org.springframework.context.test.fixtures.cache.beans.DefaultCacheableService; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java index 57a186f1dfae..2b1de9a12f18 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java @@ -24,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; -import org.springframework.cache.CacheTestUtils; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.CachingConfigurerSupport; @@ -34,12 +33,13 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import org.springframework.context.test.fixtures.cache.CacheTestUtils; import org.springframework.core.env.Environment; import org.springframework.mock.env.MockEnvironment; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.cache.CacheTestUtils.assertCacheHit; -import static org.springframework.cache.CacheTestUtils.assertCacheMiss; +import static org.springframework.context.test.fixtures.cache.CacheTestUtils.assertCacheHit; +import static org.springframework.context.test.fixtures.cache.CacheTestUtils.assertCacheMiss; /** * Tests that represent real use cases with advanced configuration. diff --git a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java index 94235e694b3f..551b28c50fd4 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java @@ -20,7 +20,6 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.cache.CacheManager; -import org.springframework.cache.CacheTestUtils; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.interceptor.CacheErrorHandler; @@ -35,6 +34,13 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.test.fixtures.cache.AbstractCacheAnnotationTests; +import org.springframework.context.test.fixtures.cache.CacheTestUtils; +import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator; +import org.springframework.context.test.fixtures.cache.SomeKeyGenerator; +import org.springframework.context.test.fixtures.cache.beans.AnnotatedClassCacheableService; +import org.springframework.context.test.fixtures.cache.beans.CacheableService; +import org.springframework.context.test.fixtures.cache.beans.DefaultCacheableService; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/cache/config/SomeCustomKeyGenerator.java b/spring-context/src/test/java/org/springframework/cache/config/SomeCustomKeyGenerator.java deleted file mode 100644 index 8f1b961ce5d8..000000000000 --- a/spring-context/src/test/java/org/springframework/cache/config/SomeCustomKeyGenerator.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2002-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cache.config; - -import java.lang.reflect.Method; - -import org.springframework.cache.interceptor.KeyGenerator; - -/** - * A custom {@link KeyGenerator} that exposes the algorithm used to compute the key - * for convenience in tests scenario. - * - * @author Stephane Nicoll - */ -public class SomeCustomKeyGenerator implements KeyGenerator { - - @Override - public Object generate(Object target, Method method, Object... params) { - return generateKey(method.getName(), params); - } - - /** - * @see #generate(Object, java.lang.reflect.Method, Object...) - */ - static Object generateKey(String methodName, Object... params) { - final StringBuilder sb = new StringBuilder(methodName); - for (Object param : params) { - sb.append(param); - } - return sb.toString(); - } -} diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java index c1be67af2bb3..45e3d575327f 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java @@ -27,7 +27,6 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; -import org.springframework.cache.CacheTestUtils; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.CachingConfigurerSupport; @@ -36,14 +35,15 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.test.fixtures.cache.CacheTestUtils; import org.springframework.lang.Nullable; import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.springframework.cache.CacheTestUtils.assertCacheHit; -import static org.springframework.cache.CacheTestUtils.assertCacheMiss; +import static org.springframework.context.test.fixtures.cache.CacheTestUtils.assertCacheHit; +import static org.springframework.context.test.fixtures.cache.CacheTestUtils.assertCacheMiss; /** * Provides various {@link CacheResolver} customisations scenario diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java index 3bd47bd1fbe5..cc5ffb063440 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java @@ -23,7 +23,6 @@ import org.junit.jupiter.api.Test; import org.springframework.cache.CacheManager; -import org.springframework.cache.CacheTestUtils; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Caching; @@ -33,6 +32,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.test.fixtures.cache.CacheTestUtils; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-context/src/test/java/org/springframework/context/BeanThatBroadcasts.java b/spring-context/src/test/java/org/springframework/context/BeanThatBroadcasts.java deleted file mode 100644 index d452c8123a37..000000000000 --- a/spring-context/src/test/java/org/springframework/context/BeanThatBroadcasts.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2002-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.context; - -/** - * @author Juergen Hoeller - */ -public class BeanThatBroadcasts implements ApplicationContextAware { - - public ApplicationContext applicationContext; - - public int receivedCount; - - - @Override - public void setApplicationContext(ApplicationContext applicationContext) { - this.applicationContext = applicationContext; - if (applicationContext.getDisplayName().contains("listener")) { - applicationContext.getBean("listener"); - } - } - -} diff --git a/spring-context/src/test/java/org/springframework/context/LifecycleContextBean.java b/spring-context/src/test/java/org/springframework/context/LifecycleContextBean.java index 010c27acd95a..c6e1fe0b1942 100644 --- a/spring-context/src/test/java/org/springframework/context/LifecycleContextBean.java +++ b/spring-context/src/test/java/org/springframework/context/LifecycleContextBean.java @@ -18,7 +18,7 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; -import org.springframework.tests.sample.beans.LifecycleBean; +import org.springframework.beans.test.fixtures.beans.LifecycleBean; /** * Simple bean to test ApplicationContext lifecycle methods for beans diff --git a/spring-context/src/test/java/org/springframework/context/TestListener.java b/spring-context/src/test/java/org/springframework/context/TestListener.java deleted file mode 100644 index bc8949f2700d..000000000000 --- a/spring-context/src/test/java/org/springframework/context/TestListener.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2002-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.context; - -/** - * Listener that maintains a global count of events. - * - * @author Rod Johnson - * @since January 21, 2001 - */ -public class TestListener implements ApplicationListener { - - private int eventCount; - - public int getEventCount() { - return eventCount; - } - - public void zeroCounter() { - eventCount = 0; - } - - @Override - public void onApplicationEvent(ApplicationEvent e) { - ++eventCount; - } - -} diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java index bb33ca5b79d6..3ad2a49c70a5 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java index bf789c112054..128bd67f2d6d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java @@ -33,11 +33,11 @@ import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.test.fixtures.Assume; import org.springframework.core.test.fixtures.EnabledForTestGroups; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java index 22a2d8f21968..f569b9e252dc 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java @@ -31,13 +31,13 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.support.StaticListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.MessageSource; import org.springframework.context.annotation2.NamedStubDao2; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.type.filter.AnnotationTypeFilter; import org.springframework.core.type.filter.AssignableTypeFilter; import org.springframework.stereotype.Component; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java index c4c9101a0cd6..b8cd73c5b046 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java @@ -23,12 +23,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation4.DependencyBean; import org.springframework.context.annotation4.FactoryMethodComponent; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.tests.context.SimpleMapScope; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.context.test.fixtures.SimpleMapScope; import org.springframework.util.ClassUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java index bcef50b12791..949fbd356d17 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java @@ -42,7 +42,7 @@ import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.context.index.CandidateComponentsTestClassLoader; +import org.springframework.context.test.fixtures.index.CandidateComponentsTestClassLoader; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.StandardEnvironment; import org.springframework.core.io.ClassPathResource; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java index 96b9d1f78740..405aa16ccbcb 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java @@ -36,14 +36,14 @@ import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.INestedTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.NestedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; +import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.jndi.support.SimpleJndiBeanFactory; -import org.springframework.tests.mock.jndi.ExpectedLookupTemplate; -import org.springframework.tests.sample.beans.INestedTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.NestedTestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java index 4f13113e52f6..441ca88cd0d2 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java @@ -51,6 +51,7 @@ import org.springframework.context.annotation.componentscan.simple.ClassWithNestedComponents; import org.springframework.context.annotation.componentscan.simple.SimpleComponent; import org.springframework.context.support.GenericApplicationContext; +import org.springframework.context.test.fixtures.SimpleMapScope; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Environment; import org.springframework.core.env.Profiles; @@ -59,7 +60,6 @@ import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.filter.TypeFilter; -import org.springframework.tests.context.SimpleMapScope; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java index 4c3f6baef119..4b1630566016 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java @@ -23,8 +23,8 @@ import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.context.test.fixtures.SimpleMapScope; import org.springframework.core.test.fixtures.io.SerializationTestUtils; -import org.springframework.tests.context.SimpleMapScope; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java index 4b9d0c993e45..4eb979370fe2 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java index 9888d8895b12..5d8fe0c6e1fc 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java index cacdc161af96..f6ac667ba901 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java @@ -53,6 +53,8 @@ import org.springframework.beans.factory.support.ChildBeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.componentscan.simple.SimpleComponent; import org.springframework.core.ResolvableType; @@ -61,8 +63,6 @@ import org.springframework.core.env.StandardEnvironment; import org.springframework.core.io.DescriptiveResource; import org.springframework.stereotype.Component; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/FooServiceDependentConverter.java b/spring-context/src/test/java/org/springframework/context/annotation/FooServiceDependentConverter.java index 318d3463c71f..b2f5d054444c 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/FooServiceDependentConverter.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/FooServiceDependentConverter.java @@ -23,7 +23,7 @@ /** * @author Juergen Hoeller */ -public class FooServiceDependentConverter implements Converter { +public class FooServiceDependentConverter implements Converter { @SuppressWarnings("unused") private FooService fooService; @@ -33,8 +33,8 @@ public void setFooService(FooService fooService) { } @Override - public org.springframework.tests.sample.beans.TestBean convert(String source) { - return new org.springframework.tests.sample.beans.TestBean(source); + public org.springframework.beans.test.fixtures.beans.TestBean convert(String source) { + return new org.springframework.beans.test.fixtures.beans.TestBean(source); } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java index d68d8e48606f..3befa5d860a1 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java @@ -28,7 +28,7 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/MyTestBean.java b/spring-context/src/test/java/org/springframework/context/annotation/MyTestBean.java index ca4159dd9b3d..f72bc3498c38 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/MyTestBean.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/MyTestBean.java @@ -23,8 +23,8 @@ class MyTestBean { @Bean - public org.springframework.tests.sample.beans.TestBean myTestBean() { - return new org.springframework.tests.sample.beans.TestBean(); + public org.springframework.beans.test.fixtures.beans.TestBean myTestBean() { + return new org.springframework.beans.test.fixtures.beans.TestBean(); } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java b/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java index b601afea1bdd..f3e98bdc2f53 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java @@ -18,8 +18,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.stereotype.Component; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java index aa14ae691577..701ce6288c94 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java @@ -30,6 +30,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.annotation.AliasFor; import org.springframework.core.env.Environment; import org.springframework.core.env.MapPropertySource; @@ -37,7 +38,6 @@ import org.springframework.core.io.support.EncodedResource; import org.springframework.core.io.support.PropertiesLoaderUtils; import org.springframework.core.io.support.PropertySourceFactory; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level1/Level1Config.java b/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level1/Level1Config.java index 1bfa4b00a8f7..e570cb88ace6 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level1/Level1Config.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level1/Level1Config.java @@ -16,10 +16,10 @@ package org.springframework.context.annotation.componentscan.level1; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.tests.sample.beans.TestBean; @Configuration @ComponentScan("org.springframework.context.annotation.componentscan.level2") diff --git a/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level2/Level2Config.java b/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level2/Level2Config.java index 611bce955e68..24c38b01d187 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level2/Level2Config.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level2/Level2Config.java @@ -16,10 +16,10 @@ package org.springframework.context.annotation.componentscan.level2; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.tests.sample.beans.TestBean; @Configuration @ComponentScan("org.springframework.context.annotation.componentscan.level3") diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java index a4b7ded80ba2..77bbe0efe021 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java @@ -33,6 +33,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.Colour; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -42,8 +44,6 @@ import org.springframework.core.annotation.AliasFor; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.tests.sample.beans.Colour; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java index 6190c13fcaaf..1022a6eb18b5 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java @@ -25,6 +25,8 @@ import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.NestedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -32,8 +34,6 @@ import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.stereotype.Component; -import org.springframework.tests.sample.beans.NestedTestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java index 4cf2d628164d..2ada5e53b202 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -33,7 +34,6 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; @@ -97,7 +97,7 @@ public TestBean testBean() { return new TestBean("name"); } - @Before("execution(* org.springframework.tests.sample.beans.TestBean.absquatulate(..)) && target(testBean)") + @Before("execution(* org.springframework.beans.test.fixtures.beans.TestBean.absquatulate(..)) && target(testBean)") public void touchBean(TestBean testBean) { testBean.setName("advisedName"); } @@ -122,7 +122,7 @@ public NameChangingAspect nameChangingAspect() { @Aspect static class NameChangingAspect { - @Before("execution(* org.springframework.tests.sample.beans.TestBean.absquatulate(..)) && target(testBean)") + @Before("execution(* org.springframework.beans.test.fixtures.beans.TestBean.absquatulate(..)) && target(testBean)") public void touchBean(TestBean testBean) { testBean.setName("advisedName"); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java index ed2c86dc1fac..7fc345371f49 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java @@ -46,6 +46,9 @@ import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.NestedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationListener; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigUtils; @@ -56,9 +59,6 @@ import org.springframework.context.event.ContextClosedEvent; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.NestedTestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java index fb83e0789ad6..7b030fe87410 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java @@ -19,12 +19,12 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java index 39e4dd9e46c3..7dd91b4dca69 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java @@ -21,10 +21,10 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java index 1028b349dc5b..04f566a259fe 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java @@ -23,11 +23,11 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java index 283ac0e63cfc..80aa7fa7bf5a 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java @@ -26,13 +26,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.PropertySource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; @@ -147,7 +147,7 @@ static class ImportXmlWithAopNamespaceConfig { @Aspect static class AnAspect { - @Before("execution(* org.springframework.tests.sample.beans.TestBean.*(..))") + @Before("execution(* org.springframework.beans.test.fixtures.beans.TestBean.*(..))") public void advice() { } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java index 6e49c97b031d..1d6968ba81c9 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java @@ -20,14 +20,14 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ConfigurationClassPostProcessor; import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.Import; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java index 98f5f12af0a0..1dfe75633feb 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java @@ -19,12 +19,12 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ClassUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java index a3391b69cad9..d9cac63a3b14 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java @@ -31,14 +31,14 @@ import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation4/FactoryMethodComponent.java b/spring-context/src/test/java/org/springframework/context/annotation4/FactoryMethodComponent.java index 3dff11c4bbbd..68659f6c67d5 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation4/FactoryMethodComponent.java +++ b/spring-context/src/test/java/org/springframework/context/annotation4/FactoryMethodComponent.java @@ -18,12 +18,12 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.BeanAge; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.stereotype.Component; -import org.springframework.tests.sample.beans.TestBean; /** * Class used to test the functionality of factory method bean definitions diff --git a/spring-context/src/test/java/org/springframework/context/annotation4/SimpleBean.java b/spring-context/src/test/java/org/springframework/context/annotation4/SimpleBean.java index da806faf795f..b3250692f590 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation4/SimpleBean.java +++ b/spring-context/src/test/java/org/springframework/context/annotation4/SimpleBean.java @@ -16,8 +16,8 @@ package org.springframework.context.annotation4; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.Bean; -import org.springframework.tests.sample.beans.TestBean; /** * Class to test that @FactoryMethods are detected only when inside a class with an @Component diff --git a/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java b/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java index 74875917f502..ec576df29c58 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java +++ b/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java @@ -16,9 +16,9 @@ package org.springframework.context.annotation6; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.tests.sample.beans.TestBean; @Configuration public class ConfigForScanning { diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java index 1366cb6bdde1..1b88c9807e31 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java @@ -31,22 +31,22 @@ import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; -import org.springframework.context.BeanThatBroadcasts; -import org.springframework.context.BeanThatListens; import org.springframework.context.PayloadApplicationEvent; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.support.StaticApplicationContext; import org.springframework.context.support.StaticMessageSource; +import org.springframework.context.test.fixtures.beans.BeanThatBroadcasts; +import org.springframework.context.test.fixtures.beans.BeanThatListens; import org.springframework.core.Ordered; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.Order; import org.springframework.scheduling.support.TaskUtils; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java index 1ec94b8e047d..cd6a0d93ddb5 100644 --- a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java @@ -22,13 +22,13 @@ import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.TestListener; import org.springframework.context.event.test.TestEvent; import org.springframework.context.support.StaticApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.context.test.fixtures.beans.TestApplicationListener; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -85,7 +85,7 @@ public void testWithApplicationEventClassThatDoesntExposeAValidCtor() { @Test public void testExpectedBehavior() { TestBean target = new TestBean(); - final TestListener listener = new TestListener(); + final TestApplicationListener listener = new TestApplicationListener(); class TestContext extends StaticApplicationContext { @Override @@ -114,7 +114,7 @@ protected void onRefresh() throws BeansException { // two events: ContextRefreshedEvent and TestEvent assertThat(listener.getEventCount() == 2).as("Interceptor must have published 2 events").isTrue(); - TestListener otherListener = (TestListener) ctx.getBean("&otherListener"); + TestApplicationListener otherListener = (TestApplicationListener) ctx.getBean("&otherListener"); assertThat(otherListener.getEventCount() == 2).as("Interceptor must have published 2 events").isTrue(); } @@ -128,7 +128,7 @@ public TestEventWithNoValidOneArgObjectCtor() { } - public static class FactoryBeanTestListener extends TestListener implements FactoryBean { + public static class FactoryBeanTestListener extends TestApplicationListener implements FactoryBean { @Override public Object getObject() { diff --git a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java index 0c1e65b76f81..598c1a0c8633 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java @@ -43,6 +43,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigUtils; import org.springframework.context.support.GenericApplicationContext; @@ -54,7 +55,6 @@ import org.springframework.core.test.fixtures.Assume; import org.springframework.core.test.fixtures.EnabledForTestGroups; import org.springframework.core.test.fixtures.io.SerializationTestUtils; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.FileCopyUtils; import org.springframework.util.StopWatch; diff --git a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java index a68066125ebd..8db30517da02 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java @@ -19,10 +19,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.test.fixtures.env.MockPropertySource; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java index dc5798a3b507..402dc3cdb77a 100644 --- a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java +++ b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java @@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test; +import org.springframework.context.test.fixtures.index.CandidateComponentsTestClassLoader; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java index 2976825d6d96..d17406dec442 100644 --- a/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java @@ -27,13 +27,13 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.core.Ordered; import org.springframework.core.PriorityOrdered; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.Assert; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java index 0cc659c51143..47cabda4f517 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java @@ -26,8 +26,8 @@ import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.config.PropertyResourceConfigurer; import org.springframework.beans.factory.config.RuntimeBeanReference; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java index fb1f12ac1955..bc71706e11f8 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java @@ -23,6 +23,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; @@ -31,7 +32,6 @@ import org.springframework.core.io.Resource; import org.springframework.core.test.fixtures.env.MockPropertySource; import org.springframework.mock.env.MockEnvironment; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java b/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java index f1e0c9cc3127..2dfc95a76a38 100644 --- a/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java @@ -21,8 +21,8 @@ import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java index aa4b7d25fce6..9eda916bce5a 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java @@ -24,18 +24,18 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; -import org.springframework.context.ACATester; -import org.springframework.context.AbstractApplicationContextTests; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationEvent; -import org.springframework.context.BeanThatListens; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.event.SimpleApplicationEventMulticaster; +import org.springframework.context.test.fixtures.AbstractApplicationContextTests; +import org.springframework.context.test.fixtures.beans.ACATester; +import org.springframework.context.test.fixtures.beans.BeanThatListens; import org.springframework.core.ResolvableType; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.core.io.support.EncodedResource; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java index 5a525c90fc7d..16562fec9a4d 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java @@ -24,12 +24,12 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; -import org.springframework.context.ACATester; -import org.springframework.context.AbstractApplicationContextTests; -import org.springframework.context.BeanThatListens; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.test.fixtures.AbstractApplicationContextTests; +import org.springframework.context.test.fixtures.beans.ACATester; +import org.springframework.context.test.fixtures.beans.BeanThatListens; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.sample.beans.TestBean; /** * Tests for static application context. diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java index ca5b1bf675a6..d002ff505199 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java @@ -26,12 +26,12 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; -import org.springframework.context.ACATester; -import org.springframework.context.AbstractApplicationContextTests; -import org.springframework.context.BeanThatListens; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.MessageSourceResolvable; import org.springframework.context.NoSuchMessageException; +import org.springframework.context.test.fixtures.AbstractApplicationContextTests; +import org.springframework.context.test.fixtures.beans.ACATester; +import org.springframework.context.test.fixtures.beans.BeanThatListens; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; @@ -182,9 +182,9 @@ protected ConfigurableApplicationContext createContext() throws Exception { Map m = new HashMap<>(); m.put("name", "Roderick"); - parent.registerPrototype("rod", org.springframework.tests.sample.beans.TestBean.class, new MutablePropertyValues(m)); + parent.registerPrototype("rod", org.springframework.beans.test.fixtures.beans.TestBean.class, new MutablePropertyValues(m)); m.put("name", "Albert"); - parent.registerPrototype("father", org.springframework.tests.sample.beans.TestBean.class, new MutablePropertyValues(m)); + parent.registerPrototype("father", org.springframework.beans.test.fixtures.beans.TestBean.class, new MutablePropertyValues(m)); parent.refresh(); parent.addApplicationListener(parentListener); diff --git a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java index 750ba2749681..214f1b531631 100644 --- a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java @@ -23,8 +23,8 @@ import org.springframework.beans.factory.parsing.ComponentDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.beans.CollectingReaderEventListener; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java index 0922393a8cee..ac91f812a0e2 100644 --- a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java @@ -23,12 +23,12 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean; import org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean; import org.springframework.jndi.JndiObjectFactoryBean; -import org.springframework.tests.sample.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; @@ -126,7 +126,7 @@ public void testComplexRemoteSlsb() throws Exception { assertPropertyValue(beanDefinition, "lookupHomeOnStartup", "true"); assertPropertyValue(beanDefinition, "resourceRef", "true"); assertPropertyValue(beanDefinition, "jndiEnvironment", "foo=bar"); - assertPropertyValue(beanDefinition, "homeInterface", "org.springframework.tests.sample.beans.ITestBean"); + assertPropertyValue(beanDefinition, "homeInterface", "org.springframework.beans.test.fixtures.beans.ITestBean"); assertPropertyValue(beanDefinition, "refreshHomeOnConnectFailure", "true"); assertPropertyValue(beanDefinition, "cacheSessionBean", "true"); } diff --git a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java index bca575d460e4..c743b5d7f71a 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java @@ -42,6 +42,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.jmx.AbstractMBeanServerTests; @@ -54,7 +55,6 @@ import org.springframework.jmx.support.ObjectNameManager; import org.springframework.jmx.support.RegistrationPolicy; import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java index 0483dd68243f..368b7b68ac7d 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java @@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.tests.mock.jndi.ExpectedLookupTemplate; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -365,7 +365,7 @@ public void testLookupWithProxyInterfaceAndExpectedTypeAndNoMatch() { jof.setProxyInterface(ITestBean.class); assertThatExceptionOfType(NamingException.class).isThrownBy( jof::afterPropertiesSet) - .withMessageContaining("org.springframework.tests.sample.beans.DerivedTestBean"); + .withMessageContaining("org.springframework.beans.test.fixtures.beans.DerivedTestBean"); } @Test diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java index 9ea45ecefcee..e2e55593ba58 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.mock.jndi.SimpleNamingContext; +import org.springframework.context.test.fixtures.jndi.SimpleNamingContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/scripting/ContextScriptBean.java b/spring-context/src/test/java/org/springframework/scripting/ContextScriptBean.java index 19fbabcdf582..b811e3a82938 100644 --- a/spring-context/src/test/java/org/springframework/scripting/ContextScriptBean.java +++ b/spring-context/src/test/java/org/springframework/scripting/ContextScriptBean.java @@ -16,8 +16,8 @@ package org.springframework.scripting; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; -import org.springframework.tests.sample.beans.TestBean; /** * @author Juergen Hoeller diff --git a/spring-context/src/test/java/org/springframework/scripting/TestBeanAwareMessenger.java b/spring-context/src/test/java/org/springframework/scripting/TestBeanAwareMessenger.java index f5298f8ae715..94a5492a9da6 100644 --- a/spring-context/src/test/java/org/springframework/scripting/TestBeanAwareMessenger.java +++ b/spring-context/src/test/java/org/springframework/scripting/TestBeanAwareMessenger.java @@ -16,7 +16,7 @@ package org.springframework.scripting; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; /** * @author Juergen Hoeller diff --git a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java index 108db8c817ef..088c1b55399f 100644 --- a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java @@ -24,6 +24,7 @@ import org.springframework.aop.support.AopUtils; import org.springframework.aop.target.dynamic.Refreshable; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -35,7 +36,6 @@ import org.springframework.scripting.ScriptSource; import org.springframework.scripting.TestBeanAwareMessenger; import org.springframework.scripting.support.ScriptFactoryPostProcessor; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java index 6f2df78bdd5c..66e18acce54a 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java @@ -29,6 +29,7 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.NestedRuntimeException; @@ -42,7 +43,6 @@ import org.springframework.scripting.ScriptSource; import org.springframework.scripting.support.ScriptFactoryPostProcessor; import org.springframework.stereotype.Component; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ObjectUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/tests/context/TestMethodInvokingTask.java b/spring-context/src/test/java/org/springframework/tests/context/TestMethodInvokingTask.java deleted file mode 100644 index f5c8085d93b7..000000000000 --- a/spring-context/src/test/java/org/springframework/tests/context/TestMethodInvokingTask.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2002-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.tests.context; - -/** - * @author Juergen Hoeller - * @since 09.10.2004 - */ -public class TestMethodInvokingTask { - - public int counter = 0; - - private Object lock = new Object(); - - public void doSomething() { - this.counter++; - } - - public void doWait() { - this.counter++; - // wait until stop is called - synchronized (this.lock) { - try { - this.lock.wait(); - } - catch (InterruptedException e) { - // fall through - } - } - } - - public void stop() { - synchronized(this.lock) { - this.lock.notify(); - } - } - -} diff --git a/spring-context/src/test/java/org/springframework/tests/mock/jndi/package-info.java b/spring-context/src/test/java/org/springframework/tests/mock/jndi/package-info.java deleted file mode 100644 index baff7e5567d1..000000000000 --- a/spring-context/src/test/java/org/springframework/tests/mock/jndi/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * The simplest implementation of the JNDI SPI that could possibly work. - * - *

    Useful for setting up a simple JNDI environment for test suites - * or standalone applications. If e.g. JDBC DataSources get bound to the - * same JNDI names as within a Java EE container, both application code and - * configuration can me reused without changes. - */ -package org.springframework.tests.mock.jndi; diff --git a/spring-context/src/test/java/org/springframework/tests/sample/beans/FieldAccessBean.java b/spring-context/src/test/java/org/springframework/tests/sample/beans/FieldAccessBean.java index c58a84568490..c1453a0d0451 100644 --- a/spring-context/src/test/java/org/springframework/tests/sample/beans/FieldAccessBean.java +++ b/spring-context/src/test/java/org/springframework/tests/sample/beans/FieldAccessBean.java @@ -16,6 +16,8 @@ package org.springframework.tests.sample.beans; +import org.springframework.beans.test.fixtures.beans.TestBean; + /** * @author Juergen Hoeller * @since 07.03.2006 diff --git a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java index afa9fee847c5..cee193825b8a 100644 --- a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java +++ b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java index 4603386af366..4f1a60ad6759 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java @@ -25,8 +25,8 @@ import org.springframework.beans.NotWritablePropertyException; import org.springframework.beans.NullValueInNestedPathException; import org.springframework.beans.PropertyValue; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.tests.sample.beans.FieldAccessBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java index bccedfdb40a3..0c6b8ba82e94 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java @@ -48,6 +48,11 @@ import org.springframework.beans.propertyeditors.CustomCollectionEditor; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.beans.propertyeditors.StringTrimmerEditor; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.SerializablePerson; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.support.ResourceBundleMessageSource; import org.springframework.context.support.StaticMessageSource; @@ -59,11 +64,6 @@ import org.springframework.format.support.FormattingConversionService; import org.springframework.lang.Nullable; import org.springframework.tests.sample.beans.BeanWithObjectProperty; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.IndexedTestBean; -import org.springframework.tests.sample.beans.SerializablePerson; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; @@ -1578,7 +1578,7 @@ public String getAsText() { assertThat(errors.getFieldError("array[0]").getCodes()[1]).isEqualTo("NOT_ROD.tb.array"); assertThat(errors.getFieldError("array[0]").getCodes()[2]).isEqualTo("NOT_ROD.array[0]"); assertThat(errors.getFieldError("array[0]").getCodes()[3]).isEqualTo("NOT_ROD.array"); - assertThat(errors.getFieldError("array[0]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.tests.sample.beans.DerivedTestBean"); + assertThat(errors.getFieldError("array[0]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.beans.test.fixtures.beans.DerivedTestBean"); assertThat(errors.getFieldError("array[0]").getCodes()[5]).isEqualTo("NOT_ROD"); assertThat(errors.getFieldValue("array[0]")).isEqualTo("arraya"); @@ -1588,7 +1588,7 @@ public String getAsText() { assertThat(errors.getFieldError("map[key1]").getCodes()[1]).isEqualTo("NOT_ROD.tb.map"); assertThat(errors.getFieldError("map[key1]").getCodes()[2]).isEqualTo("NOT_ROD.map[key1]"); assertThat(errors.getFieldError("map[key1]").getCodes()[3]).isEqualTo("NOT_ROD.map"); - assertThat(errors.getFieldError("map[key1]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.tests.sample.beans.TestBean"); + assertThat(errors.getFieldError("map[key1]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.beans.test.fixtures.beans.TestBean"); assertThat(errors.getFieldError("map[key1]").getCodes()[5]).isEqualTo("NOT_ROD"); assertThat(errors.getFieldErrorCount("map[key0]")).isEqualTo(1); @@ -1627,7 +1627,7 @@ public String getAsText() { assertThat(errors.getFieldError("map[key0]").getCodes()[3]).isEqualTo("NOT_NULL.map"); // This next code is only generated because of the registered editor, using the // registered type of the editor as guess for the content type of the collection. - assertThat(errors.getFieldError("map[key0]").getCodes()[4]).isEqualTo("NOT_NULL.org.springframework.tests.sample.beans.TestBean"); + assertThat(errors.getFieldError("map[key0]").getCodes()[4]).isEqualTo("NOT_NULL.org.springframework.beans.test.fixtures.beans.TestBean"); assertThat(errors.getFieldError("map[key0]").getCodes()[5]).isEqualTo("NOT_NULL"); } @@ -1658,7 +1658,7 @@ public String getAsText() { assertThat(errors.getFieldError("map[key0]").getCodes()[3]).isEqualTo("NOT_NULL.map"); // This next code is only generated because of the registered editor, using the // registered type of the editor as guess for the content type of the collection. - assertThat(errors.getFieldError("map[key0]").getCodes()[4]).isEqualTo("NOT_NULL.org.springframework.tests.sample.beans.TestBean"); + assertThat(errors.getFieldError("map[key0]").getCodes()[4]).isEqualTo("NOT_NULL.org.springframework.beans.test.fixtures.beans.TestBean"); assertThat(errors.getFieldError("map[key0]").getCodes()[5]).isEqualTo("NOT_NULL"); } @@ -1691,7 +1691,7 @@ public String getAsText() { assertThat(errors.getFieldError("array[0]").getCodes()[1]).isEqualTo("NOT_ROD.tb.array"); assertThat(errors.getFieldError("array[0]").getCodes()[2]).isEqualTo("NOT_ROD.array[0]"); assertThat(errors.getFieldError("array[0]").getCodes()[3]).isEqualTo("NOT_ROD.array"); - assertThat(errors.getFieldError("array[0]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.tests.sample.beans.DerivedTestBean"); + assertThat(errors.getFieldError("array[0]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.beans.test.fixtures.beans.DerivedTestBean"); assertThat(errors.getFieldError("array[0]").getCodes()[5]).isEqualTo("NOT_ROD"); assertThat(errors.getFieldValue("array[0]")).isEqualTo("arraya"); } diff --git a/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java b/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java index a2861ea039bd..91b1e9935752 100644 --- a/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java @@ -18,14 +18,11 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.validation.DefaultMessageCodesResolver.Format; import static org.assertj.core.api.Assertions.assertThat; - - - /** * Tests for {@link DefaultMessageCodesResolver}. * @@ -50,7 +47,7 @@ public void shouldResolveFieldMessageCode() throws Exception { assertThat(codes).containsExactly( "errorCode.objectName.field", "errorCode.field", - "errorCode.org.springframework.tests.sample.beans.TestBean", + "errorCode.org.springframework.beans.test.fixtures.beans.TestBean", "errorCode"); } @@ -66,7 +63,7 @@ public void shouldResolveIndexedFieldMessageCode() throws Exception { "errorCode.a.b[3].c.d", "errorCode.a.b.c.d", "errorCode.d", - "errorCode.org.springframework.tests.sample.beans.TestBean", + "errorCode.org.springframework.beans.test.fixtures.beans.TestBean", "errorCode"); } @@ -87,7 +84,7 @@ public void shouldResolveFieldMessageCodeWithPrefix() throws Exception { assertThat(codes).containsExactly( "prefix.errorCode.objectName.field", "prefix.errorCode.field", - "prefix.errorCode.org.springframework.tests.sample.beans.TestBean", + "prefix.errorCode.org.springframework.beans.test.fixtures.beans.TestBean", "prefix.errorCode"); } @@ -99,7 +96,7 @@ public void shouldSupportNullPrefix() throws Exception { assertThat(codes).containsExactly( "errorCode.objectName.field", "errorCode.field", - "errorCode.org.springframework.tests.sample.beans.TestBean", + "errorCode.org.springframework.beans.test.fixtures.beans.TestBean", "errorCode"); } @@ -110,7 +107,7 @@ public void shouldSupportMalformedIndexField() throws Exception { assertThat(codes).containsExactly( "errorCode.objectName.field[", "errorCode.field[", - "errorCode.org.springframework.tests.sample.beans.TestBean", + "errorCode.org.springframework.beans.test.fixtures.beans.TestBean", "errorCode"); } @@ -141,7 +138,7 @@ public void shouldSupportFieldPostfixFormat() throws Exception { assertThat(codes).containsExactly( "objectName.field.errorCode", "field.errorCode", - "org.springframework.tests.sample.beans.TestBean.errorCode", + "org.springframework.beans.test.fixtures.beans.TestBean.errorCode", "errorCode"); } diff --git a/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java b/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java index 50cb35484fe8..b7cf77ba6202 100644 --- a/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java +++ b/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java @@ -18,8 +18,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java index b2828f40b10a..575563881585 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java @@ -25,11 +25,11 @@ import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor; import org.springframework.context.support.GenericApplicationContext; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncAnnotationAdvisor; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/test/aspect/TwoAdviceAspect.java b/spring-context/src/test/java/test/aspect/TwoAdviceAspect.java index 5fc892938e68..a1426d6aafb9 100644 --- a/spring-context/src/test/java/test/aspect/TwoAdviceAspect.java +++ b/spring-context/src/test/java/test/aspect/TwoAdviceAspect.java @@ -26,12 +26,12 @@ public class TwoAdviceAspect { private int totalCalls; - @Around("execution(* org.springframework.tests.sample.beans.ITestBean.age())") + @Around("execution(* org.springframework.beans.test.fixtures.beans.ITestBean.age())") public int returnCallCount(ProceedingJoinPoint pjp) throws Exception { return totalCalls; } - @Before("execution(* org.springframework.tests.sample.beans.ITestBean.setAge(int)) && args(newAge)") + @Before("execution(* org.springframework.beans.test.fixtures.beans.ITestBean.setAge(int)) && args(newAge)") public void countSet(int newAge) throws Exception { ++totalCalls; } diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterAdviceBindingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterAdviceBindingTests.xml index a3616c2df337..5ecde6ca491e 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterAdviceBindingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterAdviceBindingTests.xml @@ -19,6 +19,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.xml index 214013f01afc..5cc51680df52 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.xml @@ -18,7 +18,7 @@ + pointcut="execution(org.springframework.beans.test.fixtures.beans.ITestBean[] *(..))"/> @@ -30,6 +30,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.xml index ad8a252f2b88..e665e0352503 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.xml @@ -37,6 +37,6 @@ - + \ No newline at end of file diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceBindingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceBindingTests.xml index 20a1703e8692..8e68af9d1416 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceBindingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceBindingTests.xml @@ -17,6 +17,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceCircularTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceCircularTests.xml index 8ba7742ffa8d..f410271d7b34 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceCircularTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceCircularTests.xml @@ -17,11 +17,11 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.xml index bb299a67b4b4..1b140f9632a7 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.xml @@ -85,6 +85,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.xml index 2c97c864362a..baad9c68b561 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.xml @@ -5,11 +5,11 @@ - + + value="execution(org.springframework.beans.test.fixtures.beans.ITestBean[] org.springframework.beans.test.fixtures.beans.ITestBean.*(..))"/> diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.xml index 4d6537107f7f..2cfba0956be8 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.xml @@ -7,9 +7,9 @@ - - - + + + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutTests.xml index 0e653ebde601..9f41524e6d30 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutTests.xml @@ -21,15 +21,15 @@ - + - + - + - + @@ -55,9 +55,9 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeforeAdviceBindingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeforeAdviceBindingTests.xml index 626fa5d4d167..19c4ce3bc8f9 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeforeAdviceBindingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeforeAdviceBindingTests.xml @@ -26,7 +26,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml index c4c2e40b1a75..7f74e47c7cfd 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml @@ -8,7 +8,7 @@ @@ -22,6 +22,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.xml index 8c88ac24548d..7c46bcce08eb 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingTests.xml index 32c1882cd452..ac9665408379 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingTests.xml @@ -8,12 +8,12 @@ + expression="execution(* org.springframework.beans.test.fixtures.beans.TestBean.*(..)) and this(bean) and args(argument)"/> - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests-ambiguous.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests-ambiguous.xml index b23236c90c25..0b5aa6944ccf 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests-ambiguous.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests-ambiguous.xml @@ -15,6 +15,6 @@ - + \ No newline at end of file diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests.xml index 9cc3ab152da5..13e4f86a9833 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests.xml @@ -16,6 +16,6 @@ - + \ No newline at end of file diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests-context.xml index dd92fa2bb0ff..002466ec29a9 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests-context.xml @@ -13,7 +13,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspects.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspects.xml index 7f371a008c05..c6a0ff0a777b 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspects.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspects.xml @@ -23,11 +23,11 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsPlusAdvisor.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsPlusAdvisor.xml index ed1fb59f5fa7..ecd344e78e94 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsPlusAdvisor.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsPlusAdvisor.xml @@ -9,17 +9,17 @@ - + - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithAbstractBean.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithAbstractBean.xml index 7977bcbb436c..be0cb20777aa 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithAbstractBean.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithAbstractBean.xml @@ -19,7 +19,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithOrdering.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithOrdering.xml index 72a43eda6ff4..e29fb7e28542 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithOrdering.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithOrdering.xml @@ -17,7 +17,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-pertarget.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-pertarget.xml index 3faa981e4f4f..dc1f1bb0787b 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-pertarget.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-pertarget.xml @@ -10,12 +10,12 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml index 55e1b88daafd..eb7eed64d402 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml @@ -7,7 +7,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml index 29ee403b6bb8..f113cfe7169b 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml @@ -9,7 +9,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml index 096c69852ee0..d2064c698633 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml @@ -7,7 +7,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml index 11f5a3d99fa3..9df7f552b09b 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml @@ -7,7 +7,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesInclude.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesInclude.xml index fe8a05b633d2..5d804f663a07 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesInclude.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesInclude.xml @@ -18,7 +18,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesJoinPointAspect.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesJoinPointAspect.xml index 0acc4a49ab4f..9b3669425e5a 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesJoinPointAspect.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesJoinPointAspect.xml @@ -7,7 +7,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests-context.xml index 2a557ee717b5..50415ee73774 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests-context.xml @@ -5,7 +5,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-aspectj.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-aspectj.xml index 47cdc5856d73..231c290f60ed 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-aspectj.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-aspectj.xml @@ -22,7 +22,7 @@ class="org.springframework.aop.aspectj.autoproxy.benchmark.TraceAspect" > - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-springAop.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-springAop.xml index de10c8c7731e..486d65bfc52e 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-springAop.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-springAop.xml @@ -31,7 +31,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-error.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-error.xml index 15ec7150b402..c3358ad7bfbb 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-error.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-error.xml @@ -19,7 +19,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-ok.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-ok.xml index 6865c0d4611b..b9f74dac0c9c 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-ok.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-ok.xml @@ -20,7 +20,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-error.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-error.xml index d2feb4cd1b0d..dcbc2f7e1815 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-error.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-error.xml @@ -16,7 +16,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-ok.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-ok.xml index a165115b462e..b6fbab330c95 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-ok.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-ok.xml @@ -16,7 +16,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests-context.xml index ef6dab39ecb1..83a496efa5b8 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests-context.xml @@ -23,7 +23,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-error.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-error.xml index 47a168f1aa7c..aff7923afb0b 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-error.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-error.xml @@ -15,7 +15,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-ok.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-ok.xml index 48c4ef100aca..1d16230fdf85 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-ok.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-ok.xml @@ -15,7 +15,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerTests-context.xml index bfb326cd7312..0757bdc261ef 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerTests-context.xml @@ -23,7 +23,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-error.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-error.xml index c66b4ce4f7f2..19151e25d9be 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-error.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-error.xml @@ -15,7 +15,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-ok.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-ok.xml index 3f858a725660..69bda253a19f 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-ok.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-ok.xml @@ -15,7 +15,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml index fa1dd7144915..31327e7da584 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml @@ -5,13 +5,13 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - + - + - + @@ -20,7 +20,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-autowiring.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-autowiring.xml index fd417d62620a..ff14f489b7d4 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-autowiring.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-autowiring.xml @@ -8,7 +8,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml index 44820ac9a6a2..edd3e72571fc 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml @@ -4,7 +4,7 @@ - + custom 666 @@ -12,7 +12,7 @@ - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean debugInterceptor @@ -27,7 +27,7 @@ Aspect interfaces don't need to be included here. They may, for example, be added by global interceptors. --> - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean countingBeforeAdvice,adamTargetSource @@ -42,7 +42,7 @@ - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean adam diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-frozen.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-frozen.xml index 2d6a5dea29e6..e365c73fd9db 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-frozen.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-frozen.xml @@ -4,7 +4,7 @@ - + custom 666 @@ -16,7 +16,7 @@ - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean debugInterceptor diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-inner-bean-target.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-inner-bean-target.xml index 4318d669f787..67345999ad25 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-inner-bean-target.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-inner-bean-target.xml @@ -16,7 +16,7 @@ class="org.springframework.aop.framework.ProxyFactoryBean" > - + innerBeanTarget diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-invalid.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-invalid.xml index 6f0de72edf98..ed2ba7dc1cb8 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-invalid.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-invalid.xml @@ -5,7 +5,7 @@ - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean @@ -14,7 +14,7 @@ Must have target after *. --> - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean global* diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-notlast-targetsource.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-notlast-targetsource.xml index 09e433e70441..3141c7ffc83f 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-notlast-targetsource.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-notlast-targetsource.xml @@ -9,7 +9,7 @@ - + Adam @@ -23,7 +23,7 @@ --> - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean adam,countingBeforeAdvice diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-prototype.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-prototype.xml index afd64d239db2..fa09e6b416c3 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-prototype.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-prototype.xml @@ -7,11 +7,11 @@ - + 10 - + 10 diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-serialization.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-serialization.xml index 1895bb31084d..86933697ba84 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-serialization.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-serialization.xml @@ -12,28 +12,28 @@ serializableNopInterceptor - org.springframework.tests.sample.beans.Person + org.springframework.beans.test.fixtures.beans.Person - + serializableSingleton - + serializablePrototype serializableNopInterceptor,prototypeTarget - org.springframework.tests.sample.beans.Person + org.springframework.beans.test.fixtures.beans.Person false nopInterceptor - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml index c502a911a548..e4df8653c776 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml @@ -8,7 +8,7 @@ - + Adam @@ -49,7 +49,7 @@ --> - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean nopInterceptor,unsupportedInterceptor diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-with-bpp.xml b/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-with-bpp.xml index 9d65bfc4c26e..7d66aec58476 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-with-bpp.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-with-bpp.xml @@ -3,7 +3,7 @@ - + @@ -12,7 +12,7 @@ - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean simpleBeforeAdviceAdvisor,testBeanTarget diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-without-bpp.xml b/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-without-bpp.xml index d761c43b7fe3..a6b51baf38b1 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-without-bpp.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-without-bpp.xml @@ -3,7 +3,7 @@ - + @@ -12,7 +12,7 @@ - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean simpleBeforeAdviceAdvisor,testBeanTarget diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml index f099a217a336..2a06a46d7d2c 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml @@ -33,11 +33,11 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-custom-targetsource.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-custom-targetsource.xml index 7a88be86df06..ddabde322af7 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-custom-targetsource.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-custom-targetsource.xml @@ -12,22 +12,22 @@ - + Rod - + Rod - + Rod - + Kerry diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml index 1c5a1569d23a..8c2df4bcb022 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml @@ -3,7 +3,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-quick-targetsource.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-quick-targetsource.xml index 19455a0b078b..8294fff16bea 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-quick-targetsource.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-quick-targetsource.xml @@ -14,29 +14,29 @@ - + Rod - + Kerry - + Rod - + Rod - + Rod diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests-context.xml index cce28c6965f1..c5a497646f08 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests-context.xml @@ -24,6 +24,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml index 2c390607f29f..9b9c9bd2e9eb 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml @@ -73,11 +73,11 @@ - + introductionUsingJdk - + second-introductionUsingJdk @@ -88,29 +88,29 @@ lazy-init="true"> - + jdk1 - + - + cglib1 - + onlyJdk - + doubleJdk - + noproxy diff --git a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-list.xml b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-list.xml index 6794fd8ba28b..72c913aad664 100644 --- a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-list.xml +++ b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-list.xml @@ -9,7 +9,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml index a432352d34c1..ac7df01af81f 100644 --- a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml +++ b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> - + diff --git a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-testbean.xml b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-testbean.xml index 75888861a0a8..c580a34580b3 100644 --- a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-testbean.xml +++ b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-testbean.xml @@ -3,7 +3,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceTests-context.xml index 989b1b11a9f2..95922d4e0337 100644 --- a/spring-context/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceTests-context.xml @@ -3,7 +3,7 @@ - + 10 @@ -42,7 +42,7 @@ - + prototypePerson diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests-context.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests-context.xml index 2f2eb5ce1757..2d780083d690 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests-context.xml @@ -22,7 +22,7 @@ interceptor - + Jenny 30 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-autowire.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-autowire.xml index c5f0194a199d..27c17dbce59c 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-autowire.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-autowire.xml @@ -3,19 +3,19 @@ - + - + - + - + @@ -31,12 +31,12 @@ - - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-child.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-child.xml index 29adf6023be4..2010652c0460 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-child.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-child.xml @@ -8,13 +8,13 @@ - override - override @@ -42,7 +42,7 @@ - + myname diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-collections.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-collections.xml index 5e422bbae295..468e027e5e62 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-collections.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-collections.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - + Jenny 30 @@ -12,7 +12,7 @@ - + Simple bean, without any collections. @@ -23,7 +23,7 @@ 27 - + Rod 32 @@ -35,7 +35,7 @@ - + Jenny 30 @@ -44,12 +44,12 @@ - + David 27 - + Rod 32 @@ -63,7 +63,7 @@ - + loner 26 @@ -97,26 +97,26 @@ - + verbose - + - + - + - + @@ -126,7 +126,7 @@ - + @@ -158,7 +158,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -199,7 +199,7 @@ - + @@ -207,7 +207,7 @@ - + bar @@ -217,7 +217,7 @@ - + @@ -225,7 +225,7 @@ - + bar @@ -234,7 +234,7 @@ - + @@ -243,7 +243,7 @@ - + one @@ -252,7 +252,7 @@ - + java.lang.String @@ -261,7 +261,7 @@ - + 0 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-complexFactoryCircle.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-complexFactoryCircle.xml index 840e640fc87c..5b2b7da536dc 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-complexFactoryCircle.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-complexFactoryCircle.xml @@ -11,16 +11,16 @@ - + - + - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorArg.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorArg.xml index f2ef16d76e3c..f9b1f979dbc5 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorArg.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorArg.xml @@ -13,7 +13,7 @@ - + @@ -117,7 +117,7 @@ - + Kerry1 @@ -126,7 +126,7 @@ - + Kerry2 @@ -135,7 +135,7 @@ - + /test @@ -187,13 +187,13 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml index d91e025fa346..7fcdaa785e85 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml @@ -18,7 +18,7 @@ - Jenny 30 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultAutowire.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultAutowire.xml index 0c2406f9e14b..10357e8ae7c5 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultAutowire.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultAutowire.xml @@ -3,19 +3,19 @@ - + - + - + - + Kerry diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultLazyInit.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultLazyInit.xml index fc927edbafed..eccba590a25b 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultLazyInit.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultLazyInit.xml @@ -15,6 +15,6 @@ destroy-method="customDestroy" /> - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml index 157562d49ae6..f5a896a8a396 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml @@ -58,7 +58,7 @@ - Jenny 30 @@ -68,7 +68,7 @@ - Simple bean, without any collections. diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-factoryCircle.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-factoryCircle.xml index de5f2b4dbda6..d7b39e4d7572 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-factoryCircle.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-factoryCircle.xml @@ -3,7 +3,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-initializers.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-initializers.xml index fb146c2171f1..b082cb757d6b 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-initializers.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-initializers.xml @@ -11,7 +11,7 @@ - - + Jenny 30 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml index 23c89744c96c..d4940de54e80 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml @@ -11,7 +11,7 @@ - + Jenny 30 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-localCollectionsUsingXsd.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-localCollectionsUsingXsd.xml index 31ca350d3cf2..e34567d283d3 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-localCollectionsUsingXsd.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-localCollectionsUsingXsd.xml @@ -12,7 +12,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-overrides.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-overrides.xml index 6e61f9bcaa1b..96decab1c688 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-overrides.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-overrides.xml @@ -35,32 +35,32 @@ - + Jenny 30 - + - + Jenny 30 - + - + - + Simple bean, without any collections. @@ -71,12 +71,12 @@ 27 - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-parent.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-parent.xml index 8903bb169d65..7b4a0a00d720 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-parent.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-parent.xml @@ -3,7 +3,7 @@ - + parent 1 @@ -13,11 +13,11 @@ 1 - + parent 2 - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml index 075f8b48ed79..9497d2622661 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml @@ -1,121 +1,121 @@ - + Jenny 30 - + - + - + - + - + - + - + - + Andrew 36 - + - + Georgia 33 - + - + - + - + - + - + - + - + - + - + outer 0 - + hasInner 5 - + inner1 6 - + inner2 7 - - + + inner5 6 @@ -124,7 +124,7 @@ - + inner3 8 @@ -139,41 +139,41 @@ - + - + inner1 6 - + - + inner1 6 - + hasInner 5 - + inner1 6 - + inner2 7 - - + + inner5 6 @@ -181,11 +181,11 @@ - + - + inner3 8 @@ -201,9 +201,9 @@ - + - + inner1 6 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNameInAlias.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNameInAlias.xml index 7cf4c96afb08..843f46bf064c 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNameInAlias.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNameInAlias.xml @@ -3,8 +3,8 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNames.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNames.xml index 45463198c7c2..996faed7f3a5 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNames.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNames.xml @@ -3,8 +3,8 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerWithExpressionLanguageTests.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerWithExpressionLanguageTests.xml index 5af5cddf68bc..081c8b20f893 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerWithExpressionLanguageTests.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerWithExpressionLanguageTests.xml @@ -4,8 +4,8 @@ xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests-context.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests-context.xml index 46f6111b934c..eccc3bfd0eff 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests-context.xml @@ -10,11 +10,11 @@ - + - + @@ -24,14 +24,14 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml b/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml index 3df5e41c2315..430783e5993e 100644 --- a/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml +++ b/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml @@ -36,13 +36,13 @@ - + - + - + - + diff --git a/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml b/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml index 6e52ae6f704a..0b914d6a989a 100644 --- a/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml +++ b/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml @@ -26,15 +26,15 @@ - + - + - + - + diff --git a/spring-context/src/test/resources/org/springframework/cache/config/cache-advice.xml b/spring-context/src/test/resources/org/springframework/cache/config/cache-advice.xml index 2c57ad3f8227..dc68f1adfcf0 100644 --- a/spring-context/src/test/resources/org/springframework/cache/config/cache-advice.xml +++ b/spring-context/src/test/resources/org/springframework/cache/config/cache-advice.xml @@ -112,9 +112,9 @@ - + - + @@ -126,7 +126,7 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-collections.xml b/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-collections.xml index 28563204976a..7077cad2d41e 100644 --- a/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-collections.xml +++ b/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-collections.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - + Jenny 30 @@ -12,7 +12,7 @@ - + Simple bean, without any collections. @@ -23,7 +23,7 @@ 27 - + Rod 32 @@ -35,7 +35,7 @@ - + Jenny 30 @@ -44,12 +44,12 @@ - + David 27 - + Rod 32 @@ -63,7 +63,7 @@ - + loner 26 @@ -97,26 +97,26 @@ - + verbose - + - + - + - + @@ -126,7 +126,7 @@ - + @@ -158,7 +158,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -199,7 +199,7 @@ - + @@ -207,7 +207,7 @@ - + bar @@ -217,7 +217,7 @@ - + @@ -225,7 +225,7 @@ - + bar @@ -234,7 +234,7 @@ - + @@ -243,7 +243,7 @@ - + one @@ -252,7 +252,7 @@ - + java.lang.String @@ -261,7 +261,7 @@ - + 0 diff --git a/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-parent.xml b/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-parent.xml index da5e835b8d23..5fc26275c136 100644 --- a/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-parent.xml +++ b/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-parent.xml @@ -3,7 +3,7 @@ - + parent 1 @@ -13,11 +13,11 @@ 1 - + parent 2 - + diff --git a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties index 59146595c2a4..3184784ef563 100644 --- a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties +++ b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties @@ -1 +1 @@ -propertiesDeclaredBean.(class)=org.springframework.tests.sample.beans.TestBean \ No newline at end of file +propertiesDeclaredBean.(class)=org.springframework.beans.test.fixtures.beans.TestBean \ No newline at end of file diff --git a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml index 34b253a6529f..1fcb8662b2bf 100644 --- a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml +++ b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlWithAopNamespace-context.xml b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlWithAopNamespace-context.xml index ce24687bd2fb..d81a474dd281 100644 --- a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlWithAopNamespace-context.xml +++ b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlWithAopNamespace-context.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-context/src/test/resources/org/springframework/context/support/simpleThreadScopeTests.xml b/spring-context/src/test/resources/org/springframework/context/support/simpleThreadScopeTests.xml index 54cb8595af22..62d21b908f9a 100644 --- a/spring-context/src/test/resources/org/springframework/context/support/simpleThreadScopeTests.xml +++ b/spring-context/src/test/resources/org/springframework/context/support/simpleThreadScopeTests.xml @@ -14,34 +14,34 @@ - + + business-interface="org.springframework.beans.test.fixtures.beans.ITestBean"/> @@ -54,15 +54,15 @@ + business-interface="org.springframework.beans.test.fixtures.beans.ITestBean"/> foo=bar @@ -71,8 +71,8 @@ + business-interface="org.springframework.beans.test.fixtures.beans.ITestBean" lazy-init="true" /> + business-interface="org.springframework.beans.test.fixtures.beans.ITestBean" lazy-init="true" /> diff --git a/spring-context/src/test/resources/org/springframework/jmx/export/propertyPlaceholderConfigurer.xml b/spring-context/src/test/resources/org/springframework/jmx/export/propertyPlaceholderConfigurer.xml index 3f91e5d3059d..39e7db19653b 100644 --- a/spring-context/src/test/resources/org/springframework/jmx/export/propertyPlaceholderConfigurer.xml +++ b/spring-context/src/test/resources/org/springframework/jmx/export/propertyPlaceholderConfigurer.xml @@ -17,7 +17,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/scripting/bsh/MessengerImpl.bsh b/spring-context/src/test/resources/org/springframework/scripting/bsh/MessengerImpl.bsh index 72a1e6a39c40..7129a63d5440 100644 --- a/spring-context/src/test/resources/org/springframework/scripting/bsh/MessengerImpl.bsh +++ b/spring-context/src/test/resources/org/springframework/scripting/bsh/MessengerImpl.bsh @@ -1,4 +1,4 @@ -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.scripting.TestBeanAwareMessenger; public class MyMessenger implements TestBeanAwareMessenger { diff --git a/spring-context/src/test/resources/org/springframework/scripting/bsh/bsh-with-xsd.xml b/spring-context/src/test/resources/org/springframework/scripting/bsh/bsh-with-xsd.xml index 4e10b82ecc77..5c45b921de8b 100644 --- a/spring-context/src/test/resources/org/springframework/scripting/bsh/bsh-with-xsd.xml +++ b/spring-context/src/test/resources/org/springframework/scripting/bsh/bsh-with-xsd.xml @@ -35,7 +35,7 @@ autowire="byName" init-method="init" destroy-method="destroy"> - + diff --git a/spring-context/src/test/resources/org/springframework/scripting/groovy/ScriptBean.groovy b/spring-context/src/test/resources/org/springframework/scripting/groovy/ScriptBean.groovy index 718afab987a7..d65f08fe37be 100644 --- a/spring-context/src/test/resources/org/springframework/scripting/groovy/ScriptBean.groovy +++ b/spring-context/src/test/resources/org/springframework/scripting/groovy/ScriptBean.groovy @@ -1,9 +1,9 @@ package org.springframework.scripting.groovy; +import org.springframework.beans.test.fixtures.beans.TestBean import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware import org.springframework.scripting.ContextScriptBean -import org.springframework.tests.sample.beans.TestBean class GroovyScriptBean implements ContextScriptBean, ApplicationContextAware { diff --git a/spring-context/src/test/resources/org/springframework/scripting/groovy/groovy-multiple-properties.xml b/spring-context/src/test/resources/org/springframework/scripting/groovy/groovy-multiple-properties.xml index 15082d9fa64c..26760d2997ef 100644 --- a/spring-context/src/test/resources/org/springframework/scripting/groovy/groovy-multiple-properties.xml +++ b/spring-context/src/test/resources/org/springframework/scripting/groovy/groovy-multiple-properties.xml @@ -19,6 +19,6 @@ - + diff --git a/spring-context/src/test/java/org/springframework/context/AbstractApplicationContextTests.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/AbstractApplicationContextTests.java similarity index 87% rename from spring-context/src/test/java/org/springframework/context/AbstractApplicationContextTests.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/AbstractApplicationContextTests.java index ac18e6d85a50..dd7baafac3c1 100644 --- a/spring-context/src/test/java/org/springframework/context/AbstractApplicationContextTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/AbstractApplicationContextTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context; +package org.springframework.context.test.fixtures; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -26,9 +26,16 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.xml.AbstractListableBeanFactoryTests; -import org.springframework.tests.sample.beans.LifecycleBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.LifecycleBean; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.factory.xml.AbstractListableBeanFactoryTests; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationEvent; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.NoSuchMessageException; +import org.springframework.context.test.fixtures.beans.ACATester; +import org.springframework.context.test.fixtures.beans.BeanThatListens; +import org.springframework.context.test.fixtures.beans.TestApplicationListener; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -46,9 +53,9 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe protected ConfigurableApplicationContext applicationContext; /** Subclass must register this */ - protected TestListener listener = new TestListener(); + protected TestApplicationListener listener = new TestApplicationListener(); - protected TestListener parentListener = new TestListener(); + protected TestApplicationListener parentListener = new TestApplicationListener(); @BeforeEach public void setUp() throws Exception { @@ -162,7 +169,7 @@ public void eventsWithNoSource() throws Exception { doTestEvents(this.listener, this.parentListener, event); } - protected void doTestEvents(TestListener listener, TestListener parentListener, + protected void doTestEvents(TestApplicationListener listener, TestApplicationListener parentListener, MyEvent event) { listener.zeroCounter(); parentListener.zeroCounter(); diff --git a/spring-context/src/test/java/org/springframework/tests/context/SimpleMapScope.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/SimpleMapScope.java similarity index 97% rename from spring-context/src/test/java/org/springframework/tests/context/SimpleMapScope.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/SimpleMapScope.java index ceb8d1a56a48..089c75932fd9 100644 --- a/spring-context/src/test/java/org/springframework/tests/context/SimpleMapScope.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/SimpleMapScope.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.context; +package org.springframework.context.test.fixtures; import java.io.Serializable; import java.util.HashMap; diff --git a/spring-context/src/test/java/org/springframework/context/ACATester.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/ACATester.java similarity index 75% rename from spring-context/src/test/java/org/springframework/context/ACATester.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/ACATester.java index fb179bfe58e8..995b84b6a8da 100644 --- a/spring-context/src/test/java/org/springframework/context/ACATester.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/ACATester.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2019 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. @@ -14,17 +14,22 @@ * limitations under the License. */ -package org.springframework.context; +package org.springframework.context.test.fixtures.beans; import java.util.Locale; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.ApplicationContextException; +import org.springframework.context.NoSuchMessageException; + public class ACATester implements ApplicationContextAware { private ApplicationContext ac; @Override public void setApplicationContext(ApplicationContext ctx) throws ApplicationContextException { - // check reinitialization + // check re-initialization if (this.ac != null) { throw new IllegalStateException("Already initialized"); } diff --git a/spring-webmvc/src/test/java/org/springframework/context/BeanThatBroadcasts.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatBroadcasts.java similarity index 81% rename from spring-webmvc/src/test/java/org/springframework/context/BeanThatBroadcasts.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatBroadcasts.java index d452c8123a37..3a50975f33e9 100644 --- a/spring-webmvc/src/test/java/org/springframework/context/BeanThatBroadcasts.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatBroadcasts.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2019 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. @@ -14,7 +14,10 @@ * limitations under the License. */ -package org.springframework.context; +package org.springframework.context.test.fixtures.beans; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; /** * @author Juergen Hoeller diff --git a/spring-context/src/test/java/org/springframework/context/BeanThatListens.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatListens.java similarity index 87% rename from spring-context/src/test/java/org/springframework/context/BeanThatListens.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatListens.java index 69bd1466b044..c7079188f9d0 100644 --- a/spring-context/src/test/java/org/springframework/context/BeanThatListens.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatListens.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2019 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. @@ -14,10 +14,13 @@ * limitations under the License. */ -package org.springframework.context; +package org.springframework.context.test.fixtures.beans; import java.util.Map; +import org.springframework.context.ApplicationEvent; +import org.springframework.context.ApplicationListener; + /** * A stub {@link ApplicationListener}. * diff --git a/spring-webmvc/src/test/java/org/springframework/context/TestListener.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/TestApplicationListener.java similarity index 78% rename from spring-webmvc/src/test/java/org/springframework/context/TestListener.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/TestApplicationListener.java index 242d60ac6356..a43e534ddec6 100644 --- a/spring-webmvc/src/test/java/org/springframework/context/TestListener.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/TestApplicationListener.java @@ -14,7 +14,10 @@ * limitations under the License. */ -package org.springframework.context; +package org.springframework.context.test.fixtures.beans; + +import org.springframework.context.ApplicationEvent; +import org.springframework.context.ApplicationListener; /** * Listener that maintains a global count of events. @@ -22,7 +25,7 @@ * @author Rod Johnson * @since January 21, 2001 */ -public class TestListener implements ApplicationListener { +public class TestApplicationListener implements ApplicationListener { private int eventCount; diff --git a/spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheAnnotationTests.java similarity index 97% rename from spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheAnnotationTests.java index 55234006aaae..d94cacb17a2a 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheAnnotationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.config; +package org.springframework.context.test.fixtures.cache; import java.util.Collection; import java.util.UUID; @@ -28,6 +28,9 @@ import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.test.fixtures.cache.beans.AnnotatedClassCacheableService; +import org.springframework.context.test.fixtures.cache.beans.CacheableService; +import org.springframework.context.test.fixtures.cache.beans.TestEntity; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -66,9 +69,7 @@ public void setup() { this.cm = ctx.getBean("cacheManager", CacheManager.class); Collection cn = this.cm.getCacheNames(); - assertThat(cn.contains("testCache")).isTrue(); - assertThat(cn.contains("secondary")).isTrue(); - assertThat(cn.contains("primary")).isTrue(); + assertThat(cn).containsOnly("testCache", "secondary", "primary"); } @AfterEach @@ -101,6 +102,8 @@ protected void testCacheableNull(CacheableService service) { assertThat(r2).isSameAs(r1); assertThat(r3).isSameAs(r1); + assertThat(this.cm.getCache("testCache")).as("testCache").isNotNull(); + assertThat(this.cm.getCache("testCache").get(o1)).as("cached object").isNotNull(); assertThat(this.cm.getCache("testCache").get(o1).get()).isEqualTo(r3); assertThat(r3).as("Cached value should be null").isNull(); } diff --git a/spring-context/src/test/java/org/springframework/cache/AbstractCacheTests.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheTests.java similarity index 98% rename from spring-context/src/test/java/org/springframework/cache/AbstractCacheTests.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheTests.java index 8fa63456e91d..ab8490bd5361 100644 --- a/spring-context/src/test/java/org/springframework/cache/AbstractCacheTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache; +package org.springframework.context.test.fixtures.cache; import java.util.List; import java.util.UUID; @@ -24,6 +24,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.cache.Cache; + import static org.assertj.core.api.Assertions.assertThat; /** diff --git a/spring-context/src/test/java/org/springframework/cache/AbstractValueAdaptingCacheTests.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractValueAdaptingCacheTests.java similarity index 96% rename from spring-context/src/test/java/org/springframework/cache/AbstractValueAdaptingCacheTests.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractValueAdaptingCacheTests.java index 0a6889e6e38a..ccaa6ffe8e78 100644 --- a/spring-context/src/test/java/org/springframework/cache/AbstractValueAdaptingCacheTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractValueAdaptingCacheTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache; +package org.springframework.context.test.fixtures.cache; import org.junit.jupiter.api.Test; diff --git a/spring-context/src/test/java/org/springframework/cache/CacheTestUtils.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/CacheTestUtils.java similarity index 93% rename from spring-context/src/test/java/org/springframework/cache/CacheTestUtils.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/CacheTestUtils.java index c69f2aa95143..1150a45a8f91 100644 --- a/spring-context/src/test/java/org/springframework/cache/CacheTestUtils.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/CacheTestUtils.java @@ -14,11 +14,13 @@ * limitations under the License. */ -package org.springframework.cache; +package org.springframework.context.test.fixtures.cache; import java.util.ArrayList; import java.util.List; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; import org.springframework.cache.concurrent.ConcurrentMapCache; import org.springframework.cache.support.SimpleCacheManager; diff --git a/spring-aspects/src/test/java/org/springframework/cache/config/SomeCustomKeyGenerator.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeCustomKeyGenerator.java similarity index 88% rename from spring-aspects/src/test/java/org/springframework/cache/config/SomeCustomKeyGenerator.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeCustomKeyGenerator.java index 9a60d09982e1..296e3cd3a2cd 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/config/SomeCustomKeyGenerator.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeCustomKeyGenerator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.config; +package org.springframework.context.test.fixtures.cache; import java.lang.reflect.Method; @@ -22,7 +22,7 @@ /** * A custom {@link KeyGenerator} that exposes the algorithm used to compute the key - * for convenience in tests scenario. + * for convenience in test scenarios. * * @author Stephane Nicoll */ @@ -36,7 +36,7 @@ public Object generate(Object target, Method method, Object... params) { /** * @see #generate(Object, java.lang.reflect.Method, Object...) */ - static Object generateKey(String methodName, Object... params) { + public static Object generateKey(String methodName, Object... params) { final StringBuilder sb = new StringBuilder(methodName); for (Object param : params) { sb.append(param); diff --git a/spring-context/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeKeyGenerator.java similarity index 92% rename from spring-context/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeKeyGenerator.java index 11e757b062fd..b4555262675b 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeKeyGenerator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.config; +package org.springframework.context.test.fixtures.cache; import org.springframework.cache.interceptor.SimpleKeyGenerator; diff --git a/spring-context/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/AnnotatedClassCacheableService.java similarity index 99% rename from spring-context/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/AnnotatedClassCacheableService.java index 5872dffc7808..8441ed9baa15 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/AnnotatedClassCacheableService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.config; +package org.springframework.context.test.fixtures.cache.beans; import java.io.IOException; import java.util.concurrent.atomic.AtomicLong; diff --git a/spring-context/src/test/java/org/springframework/cache/config/CacheableService.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/CacheableService.java similarity index 96% rename from spring-context/src/test/java/org/springframework/cache/config/CacheableService.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/CacheableService.java index e5ab4a5f94cc..fbbb1fc572e1 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/CacheableService.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/CacheableService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.config; +package org.springframework.context.test.fixtures.cache.beans; /** * Basic service interface for caching tests. diff --git a/spring-context/src/test/java/org/springframework/cache/config/DefaultCacheableService.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/DefaultCacheableService.java similarity index 99% rename from spring-context/src/test/java/org/springframework/cache/config/DefaultCacheableService.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/DefaultCacheableService.java index 7df2bb4ea27d..3c5a5d666546 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/DefaultCacheableService.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/DefaultCacheableService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.config; +package org.springframework.context.test.fixtures.cache.beans; import java.io.IOException; import java.util.concurrent.atomic.AtomicLong; diff --git a/spring-context/src/test/java/org/springframework/cache/config/TestEntity.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/TestEntity.java similarity index 95% rename from spring-context/src/test/java/org/springframework/cache/config/TestEntity.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/TestEntity.java index 02a9191f4b27..db221313732c 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/TestEntity.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/TestEntity.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.config; +package org.springframework.context.test.fixtures.cache.beans; import org.springframework.util.ObjectUtils; diff --git a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsTestClassLoader.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/index/CandidateComponentsTestClassLoader.java similarity index 91% rename from spring-context/src/test/java/org/springframework/context/index/CandidateComponentsTestClassLoader.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/index/CandidateComponentsTestClassLoader.java index fa28be77c270..02c91ed3d2bf 100644 --- a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsTestClassLoader.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/index/CandidateComponentsTestClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.index; +package org.springframework.context.test.fixtures.index; import java.io.IOException; import java.net.URL; @@ -23,10 +23,11 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.springframework.context.index.CandidateComponentsIndexLoader; import org.springframework.core.io.Resource; /** - * A test {@link ClassLoader} that can be used in testing context to control the + * A test {@link ClassLoader} that can be used in a testing context to control the * {@code spring.components} resource that should be loaded. Can also simulate a failure * by throwing a configurable {@link IOException}. * diff --git a/spring-context/src/test/java/org/springframework/tests/mock/jndi/ExpectedLookupTemplate.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/ExpectedLookupTemplate.java similarity index 87% rename from spring-context/src/test/java/org/springframework/tests/mock/jndi/ExpectedLookupTemplate.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/ExpectedLookupTemplate.java index 709672130625..c5e575d22c9c 100644 --- a/spring-context/src/test/java/org/springframework/tests/mock/jndi/ExpectedLookupTemplate.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/ExpectedLookupTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.mock.jndi; +package org.springframework.context.test.fixtures.jndi; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -24,7 +24,10 @@ import org.springframework.jndi.JndiTemplate; /** - * Simple extension of the JndiTemplate class that always returns a given object. + * Copy of the standard {@link org.springframework.context.test.fixtures.jndi.jndi.ExpectedLookupTemplate} + * for testing purposes. + * + *

    Simple extension of the JndiTemplate class that always returns a given object. * *

    Very useful for testing. Effectively a mock object. * diff --git a/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContext.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContext.java similarity index 96% rename from spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContext.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContext.java index d771a8b4ef67..f2f5450c84ba 100644 --- a/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContext.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.mock.jndi; +package org.springframework.context.test.fixtures.jndi; import java.util.HashMap; import java.util.Hashtable; @@ -38,7 +38,10 @@ import org.springframework.util.StringUtils; /** - * Simple implementation of a JNDI naming context. + * Copy of the standard {@link org.springframework.mock.jndi.SimpleNamingContext} + * for testing purposes. + * + *

    Simple implementation of a JNDI naming context. * Only supports binding plain Objects to String names. * Mainly for test environments, but also usable for standalone applications. * @@ -153,7 +156,7 @@ public Object lookupLink(String name) throws NameNotFoundException { * Note: Not intended for direct use by applications * if setting up a JVM-level JNDI environment. * Use SimpleNamingContextBuilder to set up JNDI bindings then. - * @see org.springframework.tests.mock.jndi.SimpleNamingContextBuilder#bind + * @see org.springframework.context.test.fixtures.jndi.SimpleNamingContextBuilder#bind */ @Override public void bind(String name, Object obj) { diff --git a/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContextBuilder.java similarity index 96% rename from spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java rename to spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContextBuilder.java index 0839e436a732..08deabe11055 100644 --- a/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContextBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.mock.jndi; +package org.springframework.context.test.fixtures.jndi; import java.util.Hashtable; @@ -33,7 +33,10 @@ import org.springframework.util.ReflectionUtils; /** - * Simple implementation of a JNDI naming context builder. + * Copy of the standard {@link org.springframework.mock.jndi.SimpleNamingContextBuilder} + * for testing purposes. + * + *

    Simple implementation of a JNDI naming context builder. * *

    Mainly targeted at test environments, where each test case can * configure JNDI appropriately, so that {@code new InitialContext()} diff --git a/spring-jdbc/spring-jdbc.gradle b/spring-jdbc/spring-jdbc.gradle index 3dc083492fc9..e0737be91f53 100644 --- a/spring-jdbc/spring-jdbc.gradle +++ b/spring-jdbc/spring-jdbc.gradle @@ -14,5 +14,6 @@ dependencies { optional("org.apache.derby:derbyclient") optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") + testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-core"))) } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java index a8edb68e3b47..2031d4acf8b8 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java @@ -28,9 +28,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.jdbc.datasource.SingleConnectionDataSource; import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyString; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java index cb1891d8c3f4..b95761476f64 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java index c2a14f0f0e49..da9652683479 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; @@ -49,7 +49,7 @@ public void testValid() throws Exception { given(resultSet.next()).willReturn(true, true, false); given(resultSet.getString(1)).willReturn("one", "one"); given(resultSet.getString(2)).willReturn("(class)", "age"); - given(resultSet.getString(3)).willReturn("org.springframework.tests.sample.beans.TestBean", "53"); + given(resultSet.getString(3)).willReturn("org.springframework.beans.test.fixtures.beans.TestBean", "53"); Statement statement = mock(Statement.class); given(statement.executeQuery(sql)).willReturn(resultSet); @@ -66,4 +66,5 @@ public void testValid() throws Exception { verify(resultSet).close(); verify(statement).close(); } + } diff --git a/spring-jms/spring-jms.gradle b/spring-jms/spring-jms.gradle index 23cae3cf57d7..e47e9458ce5a 100644 --- a/spring-jms/spring-jms.gradle +++ b/spring-jms/spring-jms.gradle @@ -12,5 +12,6 @@ dependencies { optional("javax.resource:javax.resource-api") optional("javax.transaction:javax.transaction-api") optional("com.fasterxml.jackson.core:jackson-databind") + testCompile(testFixtures(project(":spring-beans"))) testImplementation("javax.jms:javax.jms-api") } diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java index 9627ee22044d..86920c2c52b2 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java @@ -38,13 +38,13 @@ import org.springframework.beans.factory.parsing.PassThroughSourceExtractor; import org.springframework.beans.factory.parsing.ReaderEventListener; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.Phased; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.jca.endpoint.GenericMessageEndpointManager; import org.springframework.jms.listener.DefaultMessageListenerContainer; import org.springframework.jms.listener.adapter.MessageListenerAdapter; import org.springframework.jms.listener.endpoint.JmsMessageEndpointManager; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ErrorHandler; import org.springframework.util.backoff.BackOff; import org.springframework.util.backoff.FixedBackOff; diff --git a/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java b/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java index da4c7df35d32..e85f771cb89b 100644 --- a/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java @@ -35,11 +35,11 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.jms.support.converter.MessageConversionException; import org.springframework.jms.support.converter.SimpleMessageConverter; import org.springframework.remoting.RemoteTimeoutException; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml b/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml index 464b9a917c7d..79711ceb07fa 100644 --- a/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml +++ b/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml @@ -76,9 +76,9 @@ - + - + diff --git a/spring-orm/spring-orm.gradle b/spring-orm/spring-orm.gradle index 7c213fbbc7b2..06686d31d2c7 100644 --- a/spring-orm/spring-orm.gradle +++ b/spring-orm/spring-orm.gradle @@ -11,6 +11,8 @@ dependencies { optional("org.eclipse.persistence:org.eclipse.persistence.jpa") optional("org.hibernate:hibernate-core") optional("javax.servlet:javax.servlet-api:3.1.0") + testCompile(testFixtures(project(":spring-beans"))) + testCompile(testFixtures(project(":spring-context"))) testCompile(testFixtures(project(":spring-core"))) testCompile("org.aspectj:aspectjweaver") testCompile("org.hsqldb:hsqldb") diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/domain/Person.java b/spring-orm/src/test/java/org/springframework/orm/jpa/domain/Person.java index 3cba5344cfbf..df2e48fdc103 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/domain/Person.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/domain/Person.java @@ -27,8 +27,8 @@ import javax.persistence.JoinColumn; import javax.persistence.OneToOne; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; -import org.springframework.tests.sample.beans.TestBean; /** * Simple JavaBean domain object representing an person. diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java index 149a28ad557e..2dac01aab891 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.context.index.CandidateComponentsTestClassLoader; +import org.springframework.context.test.fixtures.index.CandidateComponentsTestClassLoader; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.orm.jpa.domain.Person; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java index 781027af2288..3e3da8b68d62 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.springframework.context.test.fixtures.jndi.SimpleNamingContextBuilder; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.core.io.UrlResource; @@ -35,7 +36,6 @@ import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; import org.springframework.jdbc.datasource.lookup.MapDataSourceLookup; -import org.springframework.tests.mock.jndi.SimpleNamingContextBuilder; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java index 3be9625da31d..885e22d77c3e 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java @@ -37,6 +37,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.support.GenericApplicationContext; +import org.springframework.context.test.fixtures.SimpleMapScope; +import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.orm.jpa.AbstractEntityManagerFactoryBeanTests; @@ -44,8 +46,6 @@ import org.springframework.orm.jpa.EntityManagerFactoryInfo; import org.springframework.orm.jpa.EntityManagerHolder; import org.springframework.stereotype.Repository; -import org.springframework.tests.context.SimpleMapScope; -import org.springframework.tests.mock.jndi.ExpectedLookupTemplate; import org.springframework.transaction.support.TransactionSynchronizationManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-orm/src/test/resources/org/springframework/orm/jpa/domain/persistence-multi.xml b/spring-orm/src/test/resources/org/springframework/orm/jpa/domain/persistence-multi.xml index e729dfeabc3a..082a1b1932a8 100644 --- a/spring-orm/src/test/resources/org/springframework/orm/jpa/domain/persistence-multi.xml +++ b/spring-orm/src/test/resources/org/springframework/orm/jpa/domain/persistence-multi.xml @@ -9,7 +9,7 @@ - org.springframework.tests.sample.beans.TestBean + org.springframework.beans.test.fixtures.beans.TestBean diff --git a/spring-test/spring-test.gradle b/spring-test/spring-test.gradle index 0b66f51e2779..053ab77e3bdf 100644 --- a/spring-test/spring-test.gradle +++ b/spring-test/spring-test.gradle @@ -42,6 +42,8 @@ dependencies { optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") testCompile(project(":spring-context-support")) testCompile(project(":spring-oxm")) + testCompile(testFixtures(project(":spring-beans"))) + testCompile(testFixtures(project(":spring-context"))) testCompile(testFixtures(project(":spring-core"))) testCompile("javax.annotation:javax.annotation-api") testCompile("javax.cache:cache-api") diff --git a/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java b/spring-test/src/test/java/org/springframework/mock/jndi/SimpleNamingContextTests.java similarity index 96% rename from spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java rename to spring-test/src/test/java/org/springframework/mock/jndi/SimpleNamingContextTests.java index 9e3d5bed8c76..9ccab9ec3cb8 100644 --- a/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java +++ b/spring-test/src/test/java/org/springframework/mock/jndi/SimpleNamingContextTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.jndi; +package org.springframework.mock.jndi; import java.io.PrintWriter; import java.sql.Connection; @@ -36,20 +36,20 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.mock.jndi.SimpleNamingContext; -import org.springframework.tests.mock.jndi.SimpleNamingContextBuilder; - import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** + * Tests for {@link SimpleNamingContextBuilder} and {@link SimpleNamingContext}. + * * @author Juergen Hoeller * @author Chris Beams */ -public class SimpleNamingContextTests { +@SuppressWarnings("deprecation") +class SimpleNamingContextTests { @Test - public void testNamingContextBuilder() throws NamingException { + void namingContextBuilder() throws NamingException { SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder(); InitialContextFactory factory = builder.createInitialContextFactory(null); @@ -168,7 +168,7 @@ public void testNamingContextBuilder() throws NamingException { * used repeatedly, and how it affects creating a new InitialContext() */ @Test - public void testCreateInitialContext() throws Exception { + void createInitialContext() throws Exception { SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder(); String name = "foo"; Object o = new Object(); diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests.java index b8f378ce980f..793ae833f225 100644 --- a/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests.java @@ -19,10 +19,10 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextLoader; import org.springframework.test.context.junit4.PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests.java b/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests.java index 627c812f0e40..8faf721a1dfd 100644 --- a/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests.java @@ -19,11 +19,11 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextLoader; import org.springframework.test.context.junit4.PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests; import org.springframework.test.context.support.GenericPropertiesContextLoader; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ActiveProfilesInterfaceTests.java b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ActiveProfilesInterfaceTests.java index 3a6d264e0b2f..e12e08f6215a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ActiveProfilesInterfaceTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ActiveProfilesInterfaceTests.java @@ -20,11 +20,11 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.tests.sample.beans.Employee; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationInterfaceTests.java b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationInterfaceTests.java index 8f302fd42323..f1fdd2530d23 100644 --- a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationInterfaceTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationInterfaceTests.java @@ -20,8 +20,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.tests.sample.beans.Employee; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationTestInterface.java b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationTestInterface.java index d3f8da405534..2032969f925a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationTestInterface.java +++ b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationTestInterface.java @@ -16,10 +16,10 @@ package org.springframework.test.context.configuration.interfaces; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.configuration.interfaces.ContextConfigurationTestInterface.Config; -import org.springframework.tests.sample.beans.Employee; /** * @author Sam Brannen diff --git a/spring-test/src/test/java/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTests.java index 038dc5200e28..ad183ac27b90 100644 --- a/spring-test/src/test/java/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTests.java @@ -19,9 +19,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java b/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java index db5995a1d5f3..62bc6b646bbf 100644 --- a/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java @@ -18,10 +18,10 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.context.support.GenericGroovyApplicationContext; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/groovy/GroovySpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/groovy/GroovySpringContextTests.java index 0bfd5900a903..69b6398b51aa 100644 --- a/spring-test/src/test/java/org/springframework/test/context/groovy/GroovySpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/groovy/GroovySpringContextTests.java @@ -24,11 +24,11 @@ import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/groovy/MixedXmlAndGroovySpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/groovy/MixedXmlAndGroovySpringContextTests.java index 7d2ecdfe057c..a6f9da717483 100644 --- a/spring-test/src/test/java/org/springframework/test/context/groovy/MixedXmlAndGroovySpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/groovy/MixedXmlAndGroovySpringContextTests.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java index 1a1df45c1724..1c0a5ebec49c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java @@ -25,11 +25,11 @@ import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/CustomDefaultContextLoaderClassSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/CustomDefaultContextLoaderClassSpringRunnerTests.java index 34a6bd298c03..44630b7c30ac 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/CustomDefaultContextLoaderClassSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/CustomDefaultContextLoaderClassSpringRunnerTests.java @@ -20,12 +20,12 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.BootstrapWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextLoader; import org.springframework.test.context.support.DefaultTestContextBootstrapper; import org.springframework.test.context.support.GenericPropertiesContextLoader; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java index 52465a735900..6bb02c2bb383 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java @@ -28,13 +28,13 @@ import org.junit.runners.Parameterized.Parameters; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestContextManager; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests.java index 536f4123b9de..d857b3efba0e 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests.java @@ -22,10 +22,10 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.support.GenericPropertiesContextLoader; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java index c5af71596e56..4b9a30782cd6 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java @@ -28,14 +28,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.test.context.support.GenericXmlContextLoader; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/BeanOverridingDefaultConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/BeanOverridingDefaultConfigClassesInheritedTests.java index 2c4814685246..76e976a4d8ef 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/BeanOverridingDefaultConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/BeanOverridingDefaultConfigClassesInheritedTests.java @@ -18,10 +18,10 @@ import org.junit.Test; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; -import org.springframework.tests.sample.beans.Employee; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesBaseTests.java index 364a4b8d898f..3379b6dac9db 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesBaseTests.java @@ -20,12 +20,12 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import org.springframework.tests.sample.beans.Employee; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesInheritedTests.java index 8b04b99baa33..94a39e042711 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesInheritedTests.java @@ -19,10 +19,10 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderBeanOverridingDefaultConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderBeanOverridingDefaultConfigClassesInheritedTests.java index 70f22f16b668..af2e2fbd4fb7 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderBeanOverridingDefaultConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderBeanOverridingDefaultConfigClassesInheritedTests.java @@ -18,11 +18,11 @@ import org.junit.Test; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.support.DelegatingSmartContextLoader; -import org.springframework.tests.sample.beans.Employee; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesBaseTests.java index 487b23239eb0..5a83e9743aa5 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesBaseTests.java @@ -20,12 +20,12 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DelegatingSmartContextLoader; -import org.springframework.tests.sample.beans.Employee; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesInheritedTests.java index 9781667959b0..6b8ef56dc2c4 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesInheritedTests.java @@ -19,11 +19,11 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.support.DelegatingSmartContextLoader; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesBaseTests.java index 551a055ec6dc..be882d7fe112 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesBaseTests.java @@ -20,10 +20,10 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DelegatingSmartContextLoader; -import org.springframework.tests.sample.beans.Employee; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesInheritedTests.java index d81e7a9fd7bb..1c8534d762e7 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesInheritedTests.java @@ -20,10 +20,10 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DelegatingSmartContextLoader; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesBaseTests.java index 0ebdc22ef9ab..fb84053a80cc 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesBaseTests.java @@ -20,10 +20,10 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import org.springframework.tests.sample.beans.Employee; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesInheritedTests.java index 53397d5ffc95..db8f9dceeeb1 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesInheritedTests.java @@ -20,10 +20,10 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/PojoAndStringConfig.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/PojoAndStringConfig.java index fab6e51dbf47..35f923e33f63 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/PojoAndStringConfig.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/PojoAndStringConfig.java @@ -16,10 +16,10 @@ package org.springframework.test.context.junit4.annotation; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; /** * ApplicationContext configuration class for various integration tests. diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/meta/ConfigClassesAndProfilesWithCustomDefaultsMetaConfigWithOverridesTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/meta/ConfigClassesAndProfilesWithCustomDefaultsMetaConfigWithOverridesTests.java index e3cbf9cbeef6..2e55003a3596 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/meta/ConfigClassesAndProfilesWithCustomDefaultsMetaConfigWithOverridesTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/meta/ConfigClassesAndProfilesWithCustomDefaultsMetaConfigWithOverridesTests.java @@ -20,10 +20,10 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.annotation.PojoAndStringConfig; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileAnnotationConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileAnnotationConfigTests.java index e9696e7b921f..d55bd479d952 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileAnnotationConfigTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileAnnotationConfigTests.java @@ -20,11 +20,11 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileConfig.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileConfig.java index 9f23e674e3a9..3fc8d23c5b8d 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileConfig.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileConfig.java @@ -16,9 +16,9 @@ package org.springframework.test.context.junit4.profile.annotation; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.tests.sample.beans.Pet; /** * @author Sam Brannen diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileConfig.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileConfig.java index d1a3d05aef44..c0a1bcf87b1c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileConfig.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileConfig.java @@ -16,10 +16,10 @@ package org.springframework.test.context.junit4.profile.annotation; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -import org.springframework.tests.sample.beans.Employee; /** * @author Sam Brannen diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileAnnotationConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileAnnotationConfigTests.java index 9260774a9765..4492b9edca75 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileAnnotationConfigTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileAnnotationConfigTests.java @@ -20,10 +20,10 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileConfig.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileConfig.java index afcfc8722b0f..a37a9172a554 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileConfig.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileConfig.java @@ -16,10 +16,10 @@ package org.springframework.test.context.junit4.profile.importresource; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; -import org.springframework.tests.sample.beans.Pet; /** * @author Juergen Hoeller diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests.java index 2e4bde736034..8663a2fb3c5a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests.java @@ -20,10 +20,10 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/rules/ParameterizedSpringRuleTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/rules/ParameterizedSpringRuleTests.java index 1a361193f191..0b36a0aaeaf7 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/rules/ParameterizedSpringRuleTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/rules/ParameterizedSpringRuleTests.java @@ -29,10 +29,10 @@ import org.junit.runners.Parameterized.Parameters; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests.java index bb7d1830fb54..5d9cc7397575 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests.java @@ -20,9 +20,9 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.tests.sample.beans.Employee; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests.java index 8152d1c52a5c..10b0a0f8b31c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests.java @@ -19,8 +19,8 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsBaseTests.java index 3d3e8cc20a52..0ef3e0837197 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsBaseTests.java @@ -20,9 +20,9 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.tests.sample.beans.Employee; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsInheritedTests.java index bcef27f2c882..5471e91fea7b 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsInheritedTests.java @@ -19,8 +19,8 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java index 116674b3ed84..6c53bf67946b 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java @@ -24,6 +24,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.test.annotation.DirtiesContext; @@ -31,7 +32,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; -import org.springframework.tests.sample.beans.Employee; import org.springframework.transaction.annotation.Transactional; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java index 6ed5f85359ec..d549cadee217 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java @@ -20,12 +20,12 @@ import org.junit.Before; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.test.context.ContextConfiguration; -import org.springframework.tests.sample.beans.Employee; import org.springframework.transaction.PlatformTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java index 2b6b6d575b20..013073531f69 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java @@ -20,6 +20,7 @@ import org.junit.Before; +import org.springframework.beans.test.fixtures.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.core.JdbcTemplate; @@ -28,7 +29,6 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.TransactionalTestExecutionListener; -import org.springframework.tests.sample.beans.Employee; import org.springframework.transaction.PlatformTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.java index a8fa8037cbcb..5cbbcc10e18c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.java @@ -19,11 +19,11 @@ import org.testng.annotations.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java index 2b46ec5b8797..76b8df9b0aa8 100644 --- a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java @@ -25,6 +25,8 @@ import org.testng.annotations.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.DataSourceTransactionManager; @@ -32,8 +34,6 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java index 512650288a9c..d4ec8757dbfe 100644 --- a/spring-test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java @@ -27,11 +27,11 @@ import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.test.fixtures.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; -import org.springframework.tests.sample.beans.Employee; -import org.springframework.tests.sample.beans.Pet; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java b/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java index ea37de37fd81..6ef0062c2503 100644 --- a/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java @@ -19,10 +19,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpSession; import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.web.context.WebApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests-context.properties b/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests-context.properties index 45d36076bba4..ffd5b893819c 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests-context.properties +++ b/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests-context.properties @@ -1,4 +1,4 @@ -dog.(class)=org.springframework.tests.sample.beans.Pet +dog.(class)=org.springframework.beans.test.fixtures.beans.Pet dog.$0=Fido testString2.(class)=java.lang.String diff --git a/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests-context.properties b/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests-context.properties index 45d36076bba4..ffd5b893819c 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests-context.properties +++ b/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests-context.properties @@ -1,4 +1,4 @@ -dog.(class)=org.springframework.tests.sample.beans.Pet +dog.(class)=org.springframework.beans.test.fixtures.beans.Pet dog.$0=Fido testString2.(class)=java.lang.String diff --git a/spring-test/src/test/resources/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTestsContext.groovy b/spring-test/src/test/resources/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTestsContext.groovy index f8318a7a6fa9..a74895df75f4 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTestsContext.groovy +++ b/spring-test/src/test/resources/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTestsContext.groovy @@ -16,8 +16,8 @@ package org.springframework.test.context.groovy -import org.springframework.tests.sample.beans.Employee -import org.springframework.tests.sample.beans.Pet +import org.springframework.beans.test.fixtures.beans.Employee +import org.springframework.beans.test.fixtures.beans.Pet /** * Groovy script for defining Spring beans for integration tests. diff --git a/spring-test/src/test/resources/org/springframework/test/context/groovy/context.groovy b/spring-test/src/test/resources/org/springframework/test/context/groovy/context.groovy index f8318a7a6fa9..a74895df75f4 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/groovy/context.groovy +++ b/spring-test/src/test/resources/org/springframework/test/context/groovy/context.groovy @@ -16,8 +16,8 @@ package org.springframework.test.context.groovy -import org.springframework.tests.sample.beans.Employee -import org.springframework.tests.sample.beans.Pet +import org.springframework.beans.test.fixtures.beans.Employee +import org.springframework.beans.test.fixtures.beans.Pet /** * Groovy script for defining Spring beans for integration tests. diff --git a/spring-test/src/test/resources/org/springframework/test/context/groovy/contextB.xml b/spring-test/src/test/resources/org/springframework/test/context/groovy/contextB.xml index 103412b82f50..aedba0f9a28c 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/groovy/contextB.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/groovy/contextB.xml @@ -2,13 +2,13 @@ - + - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests-context.xml index 7a130ccbe1c4..2fc9fd86f63a 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests-context.xml @@ -10,13 +10,13 @@ - + - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context1.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context1.xml index f7ade734d149..ab039802a106 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context1.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context1.xml @@ -2,7 +2,7 @@ - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context2.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context2.xml index 949d90c1867e..9a6cc4f6ffea 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context2.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context2.xml @@ -2,7 +2,7 @@ - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests-context.xml index 6df0e2936883..8f84022054da 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests-context.xml @@ -2,19 +2,19 @@ - + - + - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests-context.properties b/spring-test/src/test/resources/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests-context.properties index 6df81585fb43..064e834d125b 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests-context.properties +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests-context.properties @@ -1,4 +1,4 @@ -cat.(class)=org.springframework.tests.sample.beans.Pet +cat.(class)=org.springframework.beans.test.fixtures.beans.Pet cat.$0=Garfield testString.(class)=java.lang.String diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml index 27d136cda9a8..79c065761763 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml @@ -2,13 +2,13 @@ - + - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/importresource/import.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/importresource/import.xml index c57db6e1fa44..76ae2046a3ba 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/importresource/import.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/importresource/import.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests-context.xml index 872e9434e4b4..c1d81ead0116 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests-context.xml @@ -2,12 +2,12 @@ - + - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests-context.xml index 960a6cd0db29..dcbba34d81be 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests-context.xml @@ -2,7 +2,7 @@ - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests-context.xml index f7ade734d149..ab039802a106 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests-context.xml @@ -2,7 +2,7 @@ - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests-context.xml index 949d90c1867e..9a6cc4f6ffea 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests-context.xml @@ -2,7 +2,7 @@ - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests-context.xml index 7bb8f2cd02a1..6888e059d76d 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests-context.xml @@ -5,10 +5,10 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/jdbc https://www.springframework.org/schema/jdbc/spring-jdbc.xsd"> - - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests-context.xml index a8412fa9308b..73ba0a7094d1 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests-context.xml @@ -2,10 +2,10 @@ - + - + diff --git a/spring-tx/spring-tx.gradle b/spring-tx/spring-tx.gradle index c026fb2991b5..99c829892646 100644 --- a/spring-tx/spring-tx.gradle +++ b/spring-tx/spring-tx.gradle @@ -19,6 +19,8 @@ dependencies { optional("org.jetbrains.kotlin:kotlin-stdlib") optional("org.jetbrains.kotlinx:kotlinx-coroutines-core") optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") + testCompile(testFixtures(project(":spring-beans"))) + testCompile(testFixtures(project(":spring-context"))) testCompile(testFixtures(project(":spring-core"))) testCompile("org.aspectj:aspectjweaver") testCompile("org.codehaus.groovy:groovy") diff --git a/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java b/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java index 4d83607cbcfc..fe6bc1d24567 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -import org.springframework.tests.mock.jndi.ExpectedLookupTemplate; +import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; import org.springframework.transaction.jta.JtaTransactionManager; import org.springframework.transaction.jta.UserTransactionAdapter; import org.springframework.transaction.support.TransactionCallbackWithoutResult; diff --git a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java index 84eefc1d4b28..5dab797e05a9 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java @@ -23,8 +23,8 @@ import org.springframework.beans.factory.parsing.ComponentDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; import org.springframework.core.io.ClassPathResource; -import org.springframework.tests.beans.CollectingReaderEventListener; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java index ac6b14e3b43a..e2eb6431db88 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java @@ -22,9 +22,9 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.interceptor.TransactionAttribute; import org.springframework.transaction.interceptor.TransactionAttributeSource; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java index 0db21fcde074..33394fa04b7f 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java @@ -21,9 +21,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.dao.OptimisticLockingFailureException; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.transaction.CannotCreateTransactionException; import org.springframework.transaction.MockCallbackPreferringTransactionManager; import org.springframework.transaction.NoTransactionException; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java index e47efb55f8f6..bbb8a99b5f55 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java @@ -31,11 +31,11 @@ import org.springframework.beans.FatalBeanException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.lang.Nullable; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java index fa6ddb98a156..d36b8d935268 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java @@ -16,7 +16,7 @@ package org.springframework.transaction.interceptor; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; /** * Test for CGLIB proxying that implements no interfaces diff --git a/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java b/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java index 54d263b18292..bc0599b7f969 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java @@ -25,8 +25,8 @@ import com.ibm.wsspi.uow.UOWManager; import org.junit.jupiter.api.Test; +import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; import org.springframework.dao.OptimisticLockingFailureException; -import org.springframework.tests.mock.jndi.ExpectedLookupTemplate; import org.springframework.transaction.IllegalTransactionStateException; import org.springframework.transaction.NestedTransactionNotSupportedException; import org.springframework.transaction.TransactionDefinition; diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java index 6e63dbbde83e..5b07c460bd6e 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.context.test.fixtures.jndi.SimpleNamingContextBuilder; import org.springframework.core.test.fixtures.io.SerializationTestUtils; -import org.springframework.tests.mock.jndi.SimpleNamingContextBuilder; import org.springframework.transaction.jta.JtaTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java index bab321b24546..7b28446f7ada 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java @@ -23,9 +23,9 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.GenericBeanDefinition; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.tests.transaction.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-tx/src/test/resources/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml b/spring-tx/src/test/resources/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml index 7c10400577de..7be655a7962f 100644 --- a/spring-tx/src/test/resources/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml +++ b/spring-tx/src/test/resources/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml @@ -4,7 +4,7 @@ - + custom 666 diff --git a/spring-tx/src/test/resources/org/springframework/transaction/interceptor/transactionalBeanFactory.xml b/spring-tx/src/test/resources/org/springframework/transaction/interceptor/transactionalBeanFactory.xml index 336045ef7a44..d932173756f4 100644 --- a/spring-tx/src/test/resources/org/springframework/transaction/interceptor/transactionalBeanFactory.xml +++ b/spring-tx/src/test/resources/org/springframework/transaction/interceptor/transactionalBeanFactory.xml @@ -3,12 +3,12 @@ - + dependency - + custom 666 @@ -22,16 +22,16 @@ - org.springframework.tests.sample.beans.ITestBean.s*=PROPAGATION_MANDATORY - org.springframework.tests.sample.beans.AgeHolder.setAg*=PROPAGATION_REQUIRED - org.springframework.tests.sample.beans.ITestBean.set*= PROPAGATION_SUPPORTS , readOnly + org.springframework.beans.test.fixtures.beans.ITestBean.s*=PROPAGATION_MANDATORY + org.springframework.beans.test.fixtures.beans.AgeHolder.setAg*=PROPAGATION_REQUIRED + org.springframework.beans.test.fixtures.beans.ITestBean.set*= PROPAGATION_SUPPORTS , readOnly - org.springframework.tests.sample.beans.ITestBean + org.springframework.beans.test.fixtures.beans.ITestBean diff --git a/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml b/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml index 2a2f922039af..414adf58af5d 100644 --- a/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml +++ b/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml @@ -28,6 +28,6 @@ - + diff --git a/spring-web/spring-web.gradle b/spring-web/spring-web.gradle index d8ee7176679f..bb86f10cc511 100644 --- a/spring-web/spring-web.gradle +++ b/spring-web/spring-web.gradle @@ -54,6 +54,8 @@ dependencies { optional("org.codehaus.groovy:groovy") optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") + testCompile(testFixtures(project(":spring-beans"))) + testCompile(testFixtures(project(":spring-context"))) testCompile(testFixtures(project(":spring-core"))) testCompile("io.projectreactor:reactor-test") testCompile("org.apache.taglibs:taglibs-standard-jstlel") diff --git a/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java b/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java index 5eafdf98ed26..6d1291e43359 100644 --- a/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java +++ b/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java @@ -24,9 +24,9 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.remoting.RemoteAccessException; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.SocketUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java index 4de848f05602..39625545d809 100644 --- a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java +++ b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java @@ -37,6 +37,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanClassLoaderAware; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.remoting.RemoteAccessException; @@ -44,8 +46,6 @@ import org.springframework.remoting.support.RemoteInvocation; import org.springframework.remoting.support.RemoteInvocationFactory; import org.springframework.remoting.support.RemoteInvocationResult; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java b/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java index d5d39bf0bb1a..91926d3f1612 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.validation.BindException; import org.springframework.validation.Errors; import org.springframework.validation.FieldError; diff --git a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java index 727790209325..b3cbcd011df4 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java @@ -25,9 +25,9 @@ import org.springframework.beans.PropertyValue; import org.springframework.beans.PropertyValues; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java index 1c60a62ab0d4..276696053f60 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java @@ -26,6 +26,8 @@ import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; @@ -35,8 +37,6 @@ import org.springframework.mock.http.client.reactive.test.MockClientHttpRequest; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.web.test.server.MockServerWebExchange; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.server.ServerWebExchange; diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java index de2efa993d24..74b534489809 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java @@ -27,11 +27,11 @@ import org.springframework.beans.PropertyValue; import org.springframework.beans.PropertyValues; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockMultipartFile; import org.springframework.mock.web.test.MockMultipartHttpServletRequest; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.web.bind.ServletRequestParameterPropertyValues; import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.multipart.support.StringMultipartFileEditor; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java index c3d0178a969d..182f152de290 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java @@ -22,8 +22,8 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.StaticWebApplicationContext; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java index 902475d381d6..ac6227ce96f3 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java @@ -25,11 +25,11 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.expression.StandardBeanExpressionResolver; import org.springframework.core.io.ClassPathResource; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java index f021e0be4c02..970064bc0bb2 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java @@ -24,12 +24,12 @@ import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.tests.sample.beans.factory.DummyFactory; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java index 25c0898ed875..a767bbd8d460 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java @@ -28,12 +28,12 @@ import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.test.fixtures.io.SerializationTestUtils; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpSession; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java index 255889c45268..28bd6d1a2c0f 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java @@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.GenericBeanDefinition; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockServletContext; -import org.springframework.tests.sample.beans.DerivedTestBean; import org.springframework.web.context.ContextCleanupListener; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.GenericWebApplicationContext; diff --git a/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java b/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java index 1ba05f1dd064..05be6033aa5e 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java @@ -21,10 +21,10 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigUtils; import org.springframework.mock.web.test.MockServletContext; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.web.context.WebApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java b/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java index 6b25e4aeb8a9..750cbf55817b 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java @@ -18,11 +18,11 @@ import org.junit.jupiter.api.Test; +import org.springframework.context.test.fixtures.jndi.SimpleNamingContextBuilder; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; import org.springframework.core.env.StandardEnvironment; -import org.springframework.tests.mock.jndi.SimpleNamingContextBuilder; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java index f536e8538d00..446eb39f12bc 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java @@ -23,10 +23,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.BindException; import org.springframework.validation.BindingResult; import org.springframework.validation.Errors; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java index 0c980da38f50..8a81bf01757e 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.bind.support.DefaultSessionAttributeStore; diff --git a/spring-web/src/test/resources/org/springframework/web/context/request/requestScopeTests.xml b/spring-web/src/test/resources/org/springframework/web/context/request/requestScopeTests.xml index 1b9769e7d1ca..cbc20b6107f6 100644 --- a/spring-web/src/test/resources/org/springframework/web/context/request/requestScopeTests.xml +++ b/spring-web/src/test/resources/org/springframework/web/context/request/requestScopeTests.xml @@ -4,35 +4,35 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> - + - + - + - + - + - + - + - + - + diff --git a/spring-web/src/test/resources/org/springframework/web/context/request/requestScopedProxyTests.xml b/spring-web/src/test/resources/org/springframework/web/context/request/requestScopedProxyTests.xml index d357806bddf7..e766b1f6f5b4 100644 --- a/spring-web/src/test/resources/org/springframework/web/context/request/requestScopedProxyTests.xml +++ b/spring-web/src/test/resources/org/springframework/web/context/request/requestScopedProxyTests.xml @@ -5,47 +5,47 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - + - + - + - + - + - + - + - + - + - + diff --git a/spring-web/src/test/resources/org/springframework/web/context/request/sessionScopeTests.xml b/spring-web/src/test/resources/org/springframework/web/context/request/sessionScopeTests.xml index a371316fd7aa..45f87fa263cf 100644 --- a/spring-web/src/test/resources/org/springframework/web/context/request/sessionScopeTests.xml +++ b/spring-web/src/test/resources/org/springframework/web/context/request/sessionScopeTests.xml @@ -3,8 +3,8 @@ - + - + diff --git a/spring-webflux/spring-webflux.gradle b/spring-webflux/spring-webflux.gradle index 900d53484b4b..3a3fe9487cb2 100644 --- a/spring-webflux/spring-webflux.gradle +++ b/spring-webflux/spring-webflux.gradle @@ -31,6 +31,7 @@ dependencies { optional("org.jetbrains.kotlinx:kotlinx-coroutines-core") optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") testCompile(project(":kotlin-coroutines")) + testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-core"))) testCompile("javax.xml.bind:jaxb-api") testCompile("com.fasterxml:aalto-xml") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java index 3bfdb2bafbe7..13e3c3c4d9ac 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.server.MockWebSession; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.server.WebSession; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java index a2b413bd30a9..0e3c1fe78d05 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java @@ -28,11 +28,11 @@ import reactor.core.publisher.Mono; import reactor.test.StepVerifier; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.http.MediaType; import org.springframework.lang.Nullable; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.web.test.server.MockServerWebExchange; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.BindingResult; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java index 02caeb096682..ce6ae9151712 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java @@ -29,13 +29,13 @@ import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.http.MediaType; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.web.test.server.MockServerWebExchange; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.ui.ExtendedModelMap; import org.springframework.ui.ModelMap; import org.springframework.util.FileCopyUtils; diff --git a/spring-webmvc/spring-webmvc.gradle b/spring-webmvc/spring-webmvc.gradle index f118436eb7d8..09870708616a 100644 --- a/spring-webmvc/spring-webmvc.gradle +++ b/spring-webmvc/spring-webmvc.gradle @@ -35,7 +35,9 @@ dependencies { optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") optional("org.reactivestreams:reactive-streams") + testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-core"))) + testCompile(testFixtures(project(":spring-context"))) testCompile("javax.servlet:javax.servlet-api") testCompile("org.eclipse.jetty:jetty-servlet") { exclude group: "javax.servlet", module: "javax.servlet" diff --git a/spring-webmvc/src/test/java/org/springframework/context/ACATester.java b/spring-webmvc/src/test/java/org/springframework/context/ACATester.java deleted file mode 100644 index fb179bfe58e8..000000000000 --- a/spring-webmvc/src/test/java/org/springframework/context/ACATester.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2002-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.context; - -import java.util.Locale; - -public class ACATester implements ApplicationContextAware { - - private ApplicationContext ac; - - @Override - public void setApplicationContext(ApplicationContext ctx) throws ApplicationContextException { - // check reinitialization - if (this.ac != null) { - throw new IllegalStateException("Already initialized"); - } - - // check message source availability - if (ctx != null) { - try { - ctx.getMessage("code1", null, Locale.getDefault()); - } - catch (NoSuchMessageException ex) { - // expected - } - } - - this.ac = ctx; - } - - public ApplicationContext getApplicationContext() { - return ac; - } - -} diff --git a/spring-webmvc/src/test/java/org/springframework/context/BeanThatListens.java b/spring-webmvc/src/test/java/org/springframework/context/BeanThatListens.java deleted file mode 100644 index 84a74936bb4d..000000000000 --- a/spring-webmvc/src/test/java/org/springframework/context/BeanThatListens.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2002-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.context; - -import java.util.Map; - -/** - * A stub {@link ApplicationListener}. - * - * @author Thomas Risberg - * @author Juergen Hoeller - */ -public class BeanThatListens implements ApplicationListener { - - private BeanThatBroadcasts beanThatBroadcasts; - - private int eventCount; - - - public BeanThatListens() { - } - - public BeanThatListens(BeanThatBroadcasts beanThatBroadcasts) { - this.beanThatBroadcasts = beanThatBroadcasts; - Map beans = beanThatBroadcasts.applicationContext.getBeansOfType(BeanThatListens.class); - if (!beans.isEmpty()) { - throw new IllegalStateException("Shouldn't have found any BeanThatListens instances"); - } - } - - - @Override - public void onApplicationEvent(ApplicationEvent event) { - eventCount++; - if (beanThatBroadcasts != null) { - beanThatBroadcasts.receivedCount++; - } - } - - public int getEventCount() { - return eventCount; - } - - public void zero() { - eventCount = 0; - } - -} diff --git a/spring-webmvc/src/test/java/org/springframework/context/LifecycleContextBean.java b/spring-webmvc/src/test/java/org/springframework/context/LifecycleContextBean.java index 904100a36913..c6e1fe0b1942 100644 --- a/spring-webmvc/src/test/java/org/springframework/context/LifecycleContextBean.java +++ b/spring-webmvc/src/test/java/org/springframework/context/LifecycleContextBean.java @@ -16,10 +16,9 @@ package org.springframework.context; - import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; -import org.springframework.tests.sample.beans.LifecycleBean; +import org.springframework.beans.test.fixtures.beans.LifecycleBean; /** * Simple bean to test ApplicationContext lifecycle methods for beans diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java index 40add7d57b78..c9f96dfdd3e4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java @@ -29,6 +29,8 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.test.fixtures.beans.LifecycleBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.ApplicationContextInitializer; @@ -38,8 +40,6 @@ import org.springframework.core.env.PropertySource; import org.springframework.mock.web.test.MockServletConfig; import org.springframework.mock.web.test.MockServletContext; -import org.springframework.tests.sample.beans.LifecycleBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.StringUtils; import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.context.support.XmlWebApplicationContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java index c893300e1bad..52d9278ec215 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java @@ -28,12 +28,12 @@ import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.context.AbstractApplicationContextTests; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.NoSuchMessageException; -import org.springframework.context.TestListener; +import org.springframework.context.test.fixtures.AbstractApplicationContextTests; +import org.springframework.context.test.fixtures.beans.TestApplicationListener; import org.springframework.mock.web.test.MockServletContext; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.Assert; import org.springframework.web.context.support.XmlWebApplicationContext; @@ -96,13 +96,13 @@ public void environmentMerge() { /** * Overridden as we can't trust superclass method - * @see org.springframework.context.AbstractApplicationContextTests#testEvents() + * @see org.springframework.context.test.fixtures.AbstractApplicationContextTests#testEvents() */ @Override - protected void doTestEvents(TestListener listener, TestListener parentListener, + protected void doTestEvents(TestApplicationListener listener, TestApplicationListener parentListener, MyEvent event) { - TestListener listenerBean = (TestListener) this.applicationContext.getBean("testListener"); - TestListener parentListenerBean = (TestListener) this.applicationContext.getParent().getBean("parentListener"); + TestApplicationListener listenerBean = (TestApplicationListener) this.applicationContext.getBean("testListener"); + TestApplicationListener parentListenerBean = (TestApplicationListener) this.applicationContext.getParent().getBean("parentListener"); super.doTestEvents(listenerBean, parentListenerBean, event); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java index 5f4c33462002..4fffbccb8a7b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java @@ -27,9 +27,9 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.BeanCreationException; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.Resource; import org.springframework.mock.web.test.MockServletContext; -import org.springframework.tests.sample.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java index 22486a37426c..713e6541e2b3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java @@ -32,6 +32,7 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.PropertyValue; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.ConfigurableEnvironment; @@ -40,7 +41,6 @@ import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.mock.web.test.MockServletConfig; import org.springframework.mock.web.test.MockServletContext; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.web.context.ConfigurableWebApplicationContext; import org.springframework.web.context.ConfigurableWebEnvironment; import org.springframework.web.context.ContextLoader; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java index c533c3aaa949..d03a02418a07 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.Ordered; import org.springframework.core.convert.converter.Converter; import org.springframework.core.io.FileSystemResourceLoader; @@ -41,7 +42,6 @@ import org.springframework.mock.web.test.MockServletContext; import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor; import org.springframework.stereotype.Controller; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.AntPathMatcher; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.DefaultMessageCodesResolver; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java index 833aaf1c86a9..cc7a89378df5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java @@ -24,13 +24,13 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.TypeMismatchException; +import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.support.StaticMessageSource; import org.springframework.core.annotation.AliasFor; import org.springframework.http.HttpStatus; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.tests.sample.beans.ITestBean; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.server.ResponseStatusException; import org.springframework.web.servlet.ModelAndView; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java index f8b6a364a6d0..23baef133096 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java @@ -22,8 +22,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.web.bind.ServletRequestDataBinder; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.servlet.HandlerMapping; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java index 5961552fe4fe..86e85f82efe5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java @@ -23,9 +23,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.ui.ExtendedModelMap; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java index aa119040291e..a4f5e0a24797 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java @@ -41,6 +41,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.propertyeditors.CustomDateEditor; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.MethodParameter; import org.springframework.http.CacheControl; import org.springframework.http.HttpEntity; @@ -51,7 +52,6 @@ import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.mock.web.test.MockMultipartFile; import org.springframework.mock.web.test.MockMultipartHttpServletRequest; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; import org.springframework.validation.BindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index bbcd9379f55f..093f1eda916a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -70,6 +70,10 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.propertyeditors.CustomDateEditor; +import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.test.fixtures.beans.GenericBean; +import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigUtils; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.core.MethodParameter; @@ -102,10 +106,6 @@ import org.springframework.mock.web.test.MockServletContext; import org.springframework.oxm.jaxb.Jaxb2Marshaller; import org.springframework.stereotype.Controller; -import org.springframework.tests.sample.beans.DerivedTestBean; -import org.springframework.tests.sample.beans.GenericBean; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.ui.ExtendedModelMap; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; @@ -288,7 +288,7 @@ public void typeNestedSetBinding() throws Exception { request.addParameter("testBeanSet", "1", "2"); MockHttpServletResponse response = new MockHttpServletResponse(); getServlet().service(request, response); - assertThat(response.getContentAsString()).isEqualTo("[1, 2]-org.springframework.tests.sample.beans.TestBean"); + assertThat(response.getContentAsString()).isEqualTo("[1, 2]-org.springframework.beans.test.fixtures.beans.TestBean"); } @Test // SPR-12903 diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java index 573893791904..125bdeaad653 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java @@ -24,10 +24,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.MethodParameter; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; import org.springframework.web.bind.support.WebDataBinderFactory; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java index ff903342fce2..2ff58d4947b6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java @@ -24,6 +24,7 @@ import org.springframework.beans.ConversionNotSupportedException; import org.springframework.beans.TypeMismatchException; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.MethodParameter; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageNotReadableException; @@ -31,7 +32,6 @@ import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindException; import org.springframework.web.HttpMediaTypeNotSupportedException; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java index a76a5c88ffdf..f0c932b0dfb6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java @@ -23,10 +23,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.convert.converter.Converter; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.format.support.FormattingConversionService; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.DataBinder; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java index 1f302ac1c13c..aa45d57d2c0a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java @@ -30,9 +30,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.CustomDateEditor; -import org.springframework.tests.sample.beans.IndexedTestBean; -import org.springframework.tests.sample.beans.NestedTestBean; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.IndexedTestBean; +import org.springframework.beans.test.fixtures.beans.NestedTestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.validation.BindException; import org.springframework.validation.BindingResult; import org.springframework.validation.DataBinder; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractFormTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractFormTagTests.java index e80ced5c11f1..96d8e54b199e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractFormTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractFormTagTests.java @@ -18,9 +18,9 @@ import javax.servlet.jsp.JspException; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockPageContext; -import org.springframework.tests.sample.beans.TestBean; /** * @author Rob Harrop diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java index b87bda01f9b1..261f88888957 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java index 8ff196b720ca..7a793ed95776 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java @@ -34,9 +34,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringTrimmerEditor; -import org.springframework.tests.sample.beans.Colour; -import org.springframework.tests.sample.beans.Pet; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.Colour; +import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java index 96e4757c581a..3d7b5ee82faf 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java @@ -38,11 +38,11 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringTrimmerEditor; +import org.springframework.beans.test.fixtures.beans.Colour; +import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.format.Formatter; import org.springframework.format.support.FormattingConversionService; -import org.springframework.tests.sample.beans.Colour; -import org.springframework.tests.sample.beans.Pet; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ObjectUtils; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java index 4df506a289af..37083841dff1 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java @@ -28,9 +28,9 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.MockBodyContent; import org.springframework.mock.web.test.MockPageContext; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; import org.springframework.validation.Errors; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java index a304e8c1987c..2e26d9c1a7d5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java index 18a11bc391ef..4ccbd0da4438 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.web.servlet.support.BindStatus; import org.springframework.web.servlet.tags.BindTag; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java index 019f732201fd..ed99587c23ea 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.MockPageContext; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.web.servlet.tags.NestedPathTag; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java index ddbb46a04936..128d99cb98dd 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.CustomEnum; -import org.springframework.tests.sample.beans.GenericBean; +import org.springframework.beans.test.fixtures.beans.CustomEnum; +import org.springframework.beans.test.fixtures.beans.GenericBean; import org.springframework.web.servlet.support.BindStatus; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java index 97dc9c3a1b28..0cb39f93e37e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java @@ -28,10 +28,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringArrayPropertyEditor; +import org.springframework.beans.test.fixtures.beans.Colour; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.MockBodyContent; import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.tests.sample.beans.Colour; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.StringUtils; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.web.servlet.support.BindStatus; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java index e9dd1ec59ffb..8150e9980c8a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java @@ -34,9 +34,9 @@ import org.dom4j.io.SAXReader; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockPageContext; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; import org.springframework.validation.Errors; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java index 465d710851ff..4c0141ec9006 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java @@ -28,8 +28,8 @@ import org.dom4j.io.SAXReader; import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.Pet; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java index f915db0605db..550afd614f32 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java @@ -37,9 +37,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringTrimmerEditor; -import org.springframework.tests.sample.beans.Colour; -import org.springframework.tests.sample.beans.Pet; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.Colour; +import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java index 57183ae4c84c..c2b8f6e8372f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java @@ -41,9 +41,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.CustomCollectionEditor; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.format.Formatter; import org.springframework.format.support.FormattingConversionService; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; import org.springframework.web.servlet.support.BindStatus; @@ -351,7 +351,7 @@ public void withInvalidList() throws Exception { assertThatExceptionOfType(JspException.class).as("use a non-Collection typed value as the value of 'items'").isThrownBy( this.tag::doStartTag) .withMessageContaining("items") - .withMessageContaining("org.springframework.tests.sample.beans.TestBean"); + .withMessageContaining("org.springframework.beans.test.fixtures.beans.TestBean"); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestBeanWithRealCountry.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestBeanWithRealCountry.java index 2f37d5b05cc9..b6e19fee69e4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestBeanWithRealCountry.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestBeanWithRealCountry.java @@ -16,7 +16,7 @@ package org.springframework.web.servlet.tags.form; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; /** * @author Juergen Hoeller diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java index 0defa4d37ba4..4887d25c5afd 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.tests.sample.beans.TestBean; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java index 07c50fede29b..42e3a52c90d8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java @@ -26,11 +26,11 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.http.HttpStatus; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.mock.web.test.MockServletContext; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.ui.ModelMap; import org.springframework.web.context.ContextLoader; import org.springframework.web.context.support.StaticWebApplicationContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java index 3e7c18362102..6ba42c614b8b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java @@ -36,13 +36,13 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.PropertyValue; import org.springframework.beans.factory.BeanDefinitionStoreException; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.mock.web.test.MockRequestDispatcher; import org.springframework.mock.web.test.MockServletContext; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.web.context.support.ServletContextResource; import org.springframework.web.context.support.StaticWebApplicationContext; import org.springframework.web.servlet.DispatcherServlet; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java index 688f8686a44b..d57b19d5e86c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java @@ -32,12 +32,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.mock.web.test.MockServletContext; -import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.FileCopyUtils; import org.springframework.util.StringUtils; import org.springframework.web.context.support.StaticWebApplicationContext; diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml index 32b583bedaf8..40deeea4b155 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml index 9a023f5da25a..2bf1093f519c 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml @@ -9,7 +9,7 @@ - + - + - + - + dummy @@ -45,7 +45,7 @@ Tests of lifecycle callbacks --> + class="org.springframework.beans.test.fixtures.beans.MustBeInitialized"> - + - + - + Roderick 31 - + - + Kerry 34 - + typeMismatch 34x @@ -31,20 +31,20 @@ + class="org.springframework.beans.test.fixtures.beans.factory.DummyFactory"> + class="org.springframework.beans.test.fixtures.beans.factory.DummyFactory"> false - + listenerVeto 66 - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/contextInclude.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/contextInclude.xml index 5f178d50ebb4..5d3eb6c8c9f8 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/contextInclude.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/contextInclude.xml @@ -1,6 +1,6 @@ - + yetanotherdummy diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/sessionContext.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/sessionContext.xml index 2bdd84592c3d..8d2db6fb21ad 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/sessionContext.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/sessionContext.xml @@ -3,12 +3,12 @@ - + - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml index 47f7e89925ea..4f444b9176b8 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml @@ -11,49 +11,49 @@ org/springframework/web/context/WEB-INF/test- - + - + - + Rod 31 - + Roderick 31 - + - + Kerry 34 - + typeMismatch 34x - + - + false - + listenerVeto 66 - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/testNamespace.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/testNamespace.xml index 2983c5360bb9..519b5d89821f 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/testNamespace.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/testNamespace.xml @@ -3,12 +3,12 @@ - + Rod 31 - + Kerry 34 From 0335db23c91aef59130534598cbf2b2c4560b398 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 29 Dec 2019 15:43:15 +0100 Subject: [PATCH 0243/2315] Use Gradle test fixture support for spring-context-support See gh-23550 --- .../build/testsources/TestSourcesPlugin.java | 10 ++++++++-- spring-aspects/spring-aspects.gradle | 1 + .../cache/aspectj/JCacheAspectJJavaConfigTests.java | 2 +- .../aspectj/JCacheAspectJNamespaceConfigTests.java | 2 +- .../cache/config/AnnotatedJCacheableService.java | 6 +++--- spring-context-support/spring-context-support.gradle | 3 +++ .../jcache/config/JCacheCustomInterceptorTests.java | 1 + .../cache/jcache/config/JCacheJavaConfigTests.java | 2 ++ .../jcache/config/JCacheNamespaceDrivenTests.java | 1 + .../jcache/config/JCacheStandaloneConfigTests.java | 1 + .../jcache/interceptor/AnnotatedJCacheableService.java | 6 +++--- .../AnnotationCacheOperationSourceTests.java | 6 +++--- .../testfixture/cache}/TestableCacheKeyGenerator.java | 2 +- .../testfixture/cache}/TestableCacheResolver.java | 2 +- .../cache}/TestableCacheResolverFactory.java | 2 +- .../jcache}/AbstractJCacheAnnotationTests.java | 2 +- .../testfixture/jcache}/JCacheableService.java | 2 +- 17 files changed, 33 insertions(+), 18 deletions(-) rename spring-context-support/src/{test/java/org/springframework/cache/jcache/support => testFixtures/java/org/springframework/contextsupport/testfixture/cache}/TestableCacheKeyGenerator.java (96%) rename spring-context-support/src/{test/java/org/springframework/cache/jcache/support => testFixtures/java/org/springframework/contextsupport/testfixture/cache}/TestableCacheResolver.java (95%) rename spring-context-support/src/{test/java/org/springframework/cache/jcache/support => testFixtures/java/org/springframework/contextsupport/testfixture/cache}/TestableCacheResolverFactory.java (95%) rename spring-context-support/src/{test/java/org/springframework/cache/jcache/config => testFixtures/java/org/springframework/contextsupport/testfixture/jcache}/AbstractJCacheAnnotationTests.java (99%) rename spring-context-support/src/{test/java/org/springframework/cache/jcache/config => testFixtures/java/org/springframework/contextsupport/testfixture/jcache}/JCacheableService.java (96%) diff --git a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java index db5a10a7683e..afe853b2845f 100644 --- a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java +++ b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java @@ -59,7 +59,13 @@ public class TestSourcesPlugin implements Plugin { * Projects which will not be automatically added as a test dependency. *

    This is used to assist with the migration to Gradle test fixtures. */ - private static final List excludedProjects = Arrays.asList("spring-beans", "spring-core", "spring-context"); + private static final List excludedProjects = Arrays.asList( + "spring-beans", + "spring-context", + "spring-context-indexer", + "spring-context-support", + "spring-core" + ); @Override @@ -97,7 +103,7 @@ private void addTestSourcesFromDependency(Project currentProject, ProjectDepende dependencyProject.getPlugins().withType(JavaPlugin.class, plugin -> { JavaPluginConvention javaPlugin = dependencyProject.getConvention().getPlugin(JavaPluginConvention.class); SourceSetOutput test = javaPlugin.getSourceSets().findByName(SourceSet.TEST_SOURCE_SET_NAME).getOutput(); - // System.err.println(String.format("Adding test source dependencies from %s to %s", currentProject.getName(), dependencyProject.getName())); + System.err.println(String.format("Adding test source dependencies from %s to %s", currentProject.getName(), dependencyProject.getName())); currentProject.getDependencies().add(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME, test); }); } diff --git a/spring-aspects/spring-aspects.gradle b/spring-aspects/spring-aspects.gradle index 202014e728c9..26bd68f88212 100644 --- a/spring-aspects/spring-aspects.gradle +++ b/spring-aspects/spring-aspects.gradle @@ -25,6 +25,7 @@ dependencies { testCompile(project(":spring-core")) // for CodeStyleAspect testCompile(project(":spring-test")) testCompile(testFixtures(project(":spring-context"))) + testCompile(testFixtures(project(":spring-context-support"))) testCompile(testFixtures(project(":spring-core"))) testCompile("javax.mail:javax.mail-api") testCompileOnly("org.aspectj:aspectjrt") diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJJavaConfigTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJJavaConfigTests.java index c48ad735e6a9..dc278365d727 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJJavaConfigTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJJavaConfigTests.java @@ -23,13 +23,13 @@ import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.concurrent.ConcurrentMapCache; import org.springframework.cache.config.AnnotatedJCacheableService; -import org.springframework.cache.jcache.config.AbstractJCacheAnnotationTests; import org.springframework.cache.support.SimpleCacheManager; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AdviceMode; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnotationTests; /** * @author Stephane Nicoll diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJNamespaceConfigTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJNamespaceConfigTests.java index a3e924e35502..81ba6d0faff9 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJNamespaceConfigTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJNamespaceConfigTests.java @@ -16,9 +16,9 @@ package org.springframework.cache.aspectj; -import org.springframework.cache.jcache.config.AbstractJCacheAnnotationTests; import org.springframework.context.ApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; +import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnotationTests; /** * @author Stephane Nicoll diff --git a/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedJCacheableService.java b/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedJCacheableService.java index 299f76bf8f61..0b004f46b910 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedJCacheableService.java +++ b/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedJCacheableService.java @@ -30,9 +30,9 @@ import org.springframework.cache.Cache; import org.springframework.cache.interceptor.SimpleKeyGenerator; -import org.springframework.cache.jcache.config.JCacheableService; -import org.springframework.cache.jcache.support.TestableCacheKeyGenerator; -import org.springframework.cache.jcache.support.TestableCacheResolverFactory; +import org.springframework.contextsupport.testfixture.cache.TestableCacheKeyGenerator; +import org.springframework.contextsupport.testfixture.cache.TestableCacheResolverFactory; +import org.springframework.contextsupport.testfixture.jcache.JCacheableService; /** * Repository sample with a @CacheDefaults annotation diff --git a/spring-context-support/spring-context-support.gradle b/spring-context-support/spring-context-support.gradle index be8fb24dfeb9..47ad91ccfad3 100644 --- a/spring-context-support/spring-context-support.gradle +++ b/spring-context-support/spring-context-support.gradle @@ -25,4 +25,7 @@ dependencies { testRuntime("org.ehcache:ehcache") testRuntime("org.glassfish:javax.el") testRuntime("com.sun.mail:javax.mail") + testFixturesApi("org.junit.jupiter:junit-jupiter-api") + testFixturesImplementation("org.assertj:assertj-core") + testFixturesImplementation("org.mockito:mockito-core") } diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheCustomInterceptorTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheCustomInterceptorTests.java index 8ac2f4a3e6b0..6d5714d09574 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheCustomInterceptorTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheCustomInterceptorTests.java @@ -37,6 +37,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.contextsupport.testfixture.jcache.JCacheableService; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java index b7f3007dd78d..e8c4275823f4 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java @@ -43,6 +43,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.test.fixtures.cache.SomeKeyGenerator; +import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnotationTests; +import org.springframework.contextsupport.testfixture.jcache.JCacheableService; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.java index 28f7c513c76d..262689f83ad8 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.java @@ -24,6 +24,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; +import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnotationTests; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheStandaloneConfigTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheStandaloneConfigTests.java index c57d7ecc2134..f07e5214850e 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheStandaloneConfigTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheStandaloneConfigTests.java @@ -18,6 +18,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; +import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnotationTests; /** * @author Stephane Nicoll diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotatedJCacheableService.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotatedJCacheableService.java index 1e44ab251d02..e5cfb12b64e6 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotatedJCacheableService.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotatedJCacheableService.java @@ -30,9 +30,9 @@ import org.springframework.cache.Cache; import org.springframework.cache.interceptor.SimpleKeyGenerator; -import org.springframework.cache.jcache.config.JCacheableService; -import org.springframework.cache.jcache.support.TestableCacheKeyGenerator; -import org.springframework.cache.jcache.support.TestableCacheResolverFactory; +import org.springframework.contextsupport.testfixture.cache.TestableCacheKeyGenerator; +import org.springframework.contextsupport.testfixture.cache.TestableCacheResolverFactory; +import org.springframework.contextsupport.testfixture.jcache.JCacheableService; /** * Repository sample with a @CacheDefaults annotation diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java index 6a2e6d756b01..bcc9276243bd 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java @@ -32,9 +32,9 @@ import org.springframework.cache.interceptor.CacheResolver; import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.cache.jcache.AbstractJCacheTests; -import org.springframework.cache.jcache.support.TestableCacheKeyGenerator; -import org.springframework.cache.jcache.support.TestableCacheResolver; -import org.springframework.cache.jcache.support.TestableCacheResolverFactory; +import org.springframework.contextsupport.testfixture.cache.TestableCacheKeyGenerator; +import org.springframework.contextsupport.testfixture.cache.TestableCacheResolver; +import org.springframework.contextsupport.testfixture.cache.TestableCacheResolverFactory; import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheKeyGenerator.java b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/cache/TestableCacheKeyGenerator.java similarity index 96% rename from spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheKeyGenerator.java rename to spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/cache/TestableCacheKeyGenerator.java index 3e881dd519e0..9bb225ba80f9 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheKeyGenerator.java +++ b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/cache/TestableCacheKeyGenerator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.jcache.support; +package org.springframework.contextsupport.testfixture.cache; import java.lang.annotation.Annotation; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheResolver.java b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/cache/TestableCacheResolver.java similarity index 95% rename from spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheResolver.java rename to spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/cache/TestableCacheResolver.java index 519ba73422de..04567b1a8459 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheResolver.java +++ b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/cache/TestableCacheResolver.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.jcache.support; +package org.springframework.contextsupport.testfixture.cache; import java.lang.annotation.Annotation; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheResolverFactory.java b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/cache/TestableCacheResolverFactory.java similarity index 95% rename from spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheResolverFactory.java rename to spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/cache/TestableCacheResolverFactory.java index c544dde8bbe9..5849090acd1b 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheResolverFactory.java +++ b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/cache/TestableCacheResolverFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.jcache.support; +package org.springframework.contextsupport.testfixture.cache; import java.lang.annotation.Annotation; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/AbstractJCacheAnnotationTests.java b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/jcache/AbstractJCacheAnnotationTests.java similarity index 99% rename from spring-context-support/src/test/java/org/springframework/cache/jcache/config/AbstractJCacheAnnotationTests.java rename to spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/jcache/AbstractJCacheAnnotationTests.java index aa6478acec69..db5bb038e94f 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/AbstractJCacheAnnotationTests.java +++ b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/jcache/AbstractJCacheAnnotationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.jcache.config; +package org.springframework.contextsupport.testfixture.jcache; import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheableService.java b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/jcache/JCacheableService.java similarity index 96% rename from spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheableService.java rename to spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/jcache/JCacheableService.java index 1c43cfbea2e5..db36d1103207 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheableService.java +++ b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/jcache/JCacheableService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cache.jcache.config; +package org.springframework.contextsupport.testfixture.jcache; import java.io.IOException; From 4260c34b476862a3d026e58d7e6295591cdda50a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 29 Dec 2019 16:03:25 +0100 Subject: [PATCH 0244/2315] Rename test fixture package in spring-core See gh-23550 --- .../AopNamespaceHandlerScopeIntegrationTests.java | 2 +- ...uledAndTransactionalAnnotationIntegrationTests.java | 4 ++-- .../aspectj/annotation/AspectProxyFactoryTests.java | 2 +- .../aop/config/AopNamespaceHandlerEventTests.java | 2 +- .../config/AopNamespaceHandlerPointcutErrorTests.java | 2 +- .../aop/config/TopLevelAopTagTests.java | 2 +- .../aop/framework/PrototypeTargetTests.java | 2 +- .../aop/framework/ProxyFactoryTests.java | 2 +- .../ConcurrencyThrottleInterceptorTests.java | 2 +- .../interceptor/ExposeInvocationInterceptorTests.java | 2 +- .../aop/scope/ScopedProxyAutowireTests.java | 2 +- .../aop/support/AbstractRegexpMethodPointcutTests.java | 2 +- .../org/springframework/aop/support/AopUtilsTests.java | 2 +- .../DelegatingIntroductionInterceptorTests.java | 4 ++-- .../aop/support/MethodMatchersTests.java | 2 +- .../aop/support/NameMatchMethodPointcutTests.java | 2 +- .../RegexpMethodPointcutAdvisorIntegrationTests.java | 4 ++-- .../aop/target/CommonsPool2TargetSourceProxyTests.java | 2 +- .../aop/target/HotSwappableTargetSourceTests.java | 4 ++-- .../aop/target/LazyInitTargetSourceTests.java | 2 +- .../aop/target/PrototypeBasedTargetSourceTests.java | 2 +- .../aop/target/PrototypeTargetSourceTests.java | 2 +- .../aop/target/ThreadLocalTargetSourceTests.java | 2 +- .../target/dynamic/RefreshableTargetSourceTests.java | 4 ++-- .../interceptor/TimestampIntroductionInterceptor.java | 2 +- .../aspectj/AnnotationAsyncExecutionAspectTests.java | 4 ++-- .../beans/AbstractPropertyAccessorTests.java | 6 +++--- .../beans/factory/BeanFactoryUtilsTests.java | 2 +- .../beans/factory/ConcurrentBeanFactoryTests.java | 6 +++--- .../beans/factory/DefaultListableBeanFactoryTests.java | 8 ++++---- .../beans/factory/FactoryBeanTests.java | 4 ++-- .../AutowiredAnnotationBeanPostProcessorTests.java | 2 +- .../annotation/CustomAutowireConfigurerTests.java | 2 +- .../InjectAnnotationBeanPostProcessorTests.java | 2 +- .../config/FieldRetrievingFactoryBeanTests.java | 2 +- .../config/ObjectFactoryCreatingFactoryBeanTests.java | 4 ++-- .../factory/config/PropertiesFactoryBeanTests.java | 2 +- .../factory/config/PropertyPathFactoryBeanTests.java | 2 +- .../config/PropertyResourceConfigurerTests.java | 2 +- .../beans/factory/config/SimpleScopeTests.java | 2 +- .../factory/parsing/CustomProblemReporterTests.java | 2 +- .../factory/support/BeanFactoryGenericsTests.java | 4 ++-- .../cache/ehcache/EhCacheCacheTests.java | 4 ++-- .../scheduling/quartz/QuartzSupportTests.java | 4 ++-- .../beanvalidation2/SpringValidatorAdapterTests.java | 2 +- .../autoproxy/AspectJAutoProxyCreatorTests.java | 6 +++--- .../aop/framework/AbstractAopProxyTests.java | 10 +++++----- .../aop/framework/ProxyFactoryBeanTests.java | 4 ++-- .../autoproxy/BeanNameAutoProxyCreatorTests.java | 2 +- .../springframework/aop/scope/ScopedProxyTests.java | 2 +- .../aop/target/CommonsPool2TargetSourceTests.java | 2 +- .../beans/factory/xml/XmlBeanFactoryTests.java | 2 +- .../AnnotationProcessorPerformanceTests.java | 6 +++--- .../CommonAnnotationBeanPostProcessorTests.java | 2 +- .../ComponentScanAnnotationIntegrationTests.java | 2 +- .../ComponentScanParserScopedProxyTests.java | 2 +- .../expression/ApplicationContextExpressionTests.java | 8 ++++---- .../EnvironmentAccessorIntegrationTests.java | 2 +- .../support/DefaultLifecycleProcessorTests.java | 4 ++-- .../EnvironmentSecurityManagerIntegrationTests.java | 2 +- .../PropertySourcesPlaceholderConfigurerTests.java | 2 +- .../org/springframework/mock/env/MockEnvironment.java | 4 ++-- .../scheduling/annotation/EnableSchedulingTests.java | 4 ++-- .../concurrent/ScheduledExecutorFactoryBeanTests.java | 4 ++-- .../support/ScriptFactoryPostProcessorTests.java | 4 ++-- .../beanvalidation/SpringValidatorAdapterTests.java | 2 +- .../context/support/BeanDefinitionDslTests.kt | 2 +- .../java/example/type/AspectJTypeFilterTestsTypes.java | 2 +- .../core/annotation/AnnotatedElementUtilsTests.java | 4 ++-- .../core/annotation/AnnotationUtilsTests.java | 4 ++-- .../core/annotation/MergedAnnotationsTests.java | 6 +++--- .../core/codec/ByteArrayDecoderTests.java | 2 +- .../core/codec/ByteArrayEncoderTests.java | 2 +- .../core/codec/ByteBufferDecoderTests.java | 2 +- .../core/codec/ByteBufferEncoderTests.java | 2 +- .../core/codec/CharSequenceEncoderTests.java | 2 +- .../core/codec/DataBufferDecoderTests.java | 2 +- .../core/codec/DataBufferEncoderTests.java | 2 +- .../core/codec/ResourceDecoderTests.java | 2 +- .../core/codec/ResourceEncoderTests.java | 2 +- .../core/codec/ResourceRegionEncoderTests.java | 4 ++-- .../springframework/core/codec/StringDecoderTests.java | 2 +- .../converter/DefaultConversionServiceTests.java | 4 ++-- .../convert/support/GenericConversionServiceTests.java | 4 ++-- .../core/env/MutablePropertySourcesTests.java | 2 +- .../core/env/PropertySourcesPropertyResolverTests.java | 2 +- .../core/env/StandardEnvironmentTests.java | 4 ++-- .../core/io/buffer/DataBufferTests.java | 2 +- .../core/io/buffer/DataBufferUtilsTests.java | 4 ++-- .../io/buffer/LeakAwareDataBufferFactoryTests.java | 2 +- .../io/buffer/support/DataBufferTestUtilsTests.java | 4 ++-- .../TestGroupParsingTests.java | 2 +- .../{test/fixtures => testfixture}/TestGroupTests.java | 6 +++--- .../core/type/AnnotationMetadataTests.java | 2 +- .../core/type/AnnotationTypeFilterTests.java | 2 +- .../core/type/AspectJTypeFilterTests.java | 6 +++--- .../core/type/CachingMetadataReaderLeakTests.java | 4 ++-- .../springframework/util/AutoPopulatingListTests.java | 2 +- .../org/springframework/util/ReflectionUtilsTests.java | 4 ++-- .../util/xml/AbstractStaxHandlerTests.java | 2 +- .../util/xml/DomContentHandlerTests.java | 2 +- .../util/xml/ListBasedXMLEventReaderTests.java | 2 +- .../org/springframework/util/xml/StaxResultTests.java | 2 +- .../org/springframework/util/xml/StaxSourceTests.java | 2 +- .../util/xml/XMLEventStreamReaderTests.java | 2 +- .../util/xml/XMLEventStreamWriterTests.java | 2 +- .../core/{test/fixtures => testfixture}/Assume.java | 2 +- .../fixtures => testfixture}/EnabledForTestGroups.java | 2 +- .../core/{test/fixtures => testfixture}/TestGroup.java | 2 +- .../fixtures => testfixture}/TestGroupsCondition.java | 2 +- .../{test/fixtures => testfixture}/TimeStamped.java | 2 +- .../codec/AbstractDecoderTests.java | 4 ++-- .../codec/AbstractEncoderTests.java | 4 ++-- .../env/EnvironmentTestUtils.java | 2 +- .../env/MockPropertySource.java | 2 +- .../fixtures => testfixture}/io/ResourceTestUtils.java | 2 +- .../io/SerializationTestUtils.java | 2 +- .../io/buffer/AbstractDataBufferAllocatingTests.java | 4 ++-- .../io/buffer/AbstractLeakCheckingTests.java | 2 +- .../io/buffer/DataBufferTestUtils.java | 2 +- .../io/buffer/LeakAwareDataBuffer.java | 2 +- .../io/buffer/LeakAwareDataBufferFactory.java | 2 +- .../fixtures => testfixture}/stereotype/Component.java | 2 +- .../fixtures => testfixture}/stereotype/Indexed.java | 2 +- .../{test/fixtures => testfixture}/xml/XmlContent.java | 2 +- .../fixtures => testfixture}/xml/XmlContentAssert.java | 2 +- .../expression/spel/MapAccessTests.java | 4 ++-- .../expression/spel/PerformanceTests.java | 4 ++-- .../jdbc/config/JdbcNamespaceIntegrationTests.java | 4 ++-- .../datasource/DataSourceTransactionManagerTests.java | 4 ++-- .../springframework/messaging/MessageHeadersTests.java | 2 +- .../converter/MarshallingMessageConverterTests.java | 2 +- .../reactive/TestEncoderMethodReturnValueHandler.java | 2 +- .../rsocket/LeakAwareNettyDataBufferFactory.java | 2 +- .../messaging/rsocket/MetadataEncoderTests.java | 2 +- .../messaging/rsocket/PayloadUtilsTests.java | 2 +- .../messaging/support/MessageHeaderAccessorTests.java | 2 +- ...tContainerEntityManagerFactoryIntegrationTests.java | 2 +- .../LocalContainerEntityManagerFactoryBeanTests.java | 2 +- .../orm/jpa/support/PersistenceInjectionTests.java | 2 +- .../springframework/oxm/AbstractMarshallerTests.java | 2 +- .../springframework/oxm/jaxb/Jaxb2MarshallerTests.java | 2 +- .../springframework/oxm/jibx/JibxMarshallerTests.java | 2 +- .../oxm/xstream/XStreamMarshallerTests.java | 2 +- .../concurrency/SpringJUnit4ConcurrencyTests.java | 2 +- .../web/reactive/server/HttpHandlerConnectorTests.java | 2 +- .../servlet/htmlunit/DelegatingWebConnectionTests.java | 4 ++-- .../servlet/htmlunit/MockMvcWebClientBuilderTests.java | 2 +- .../webdriver/MockMvcHtmlUnitDriverBuilderTests.java | 2 +- .../AnnotationTransactionAttributeSourceTests.java | 2 +- .../transaction/config/AnnotationDrivenTests.java | 2 +- .../TransactionAttributeSourceAdvisorTests.java | 2 +- .../interceptor/TransactionInterceptorTests.java | 2 +- .../JtaTransactionManagerSerializationTests.java | 2 +- .../http/codec/CancelWithoutDemandCodecTests.java | 2 +- .../http/codec/FormHttpMessageReaderTests.java | 2 +- .../http/codec/FormHttpMessageWriterTests.java | 4 ++-- .../codec/ServerSentEventHttpMessageReaderTests.java | 2 +- .../codec/ServerSentEventHttpMessageWriterTests.java | 4 ++-- .../http/codec/cbor/Jackson2CborDecoderTests.java | 2 +- .../http/codec/cbor/Jackson2CborEncoderTests.java | 4 ++-- .../http/codec/json/Jackson2JsonDecoderTests.java | 2 +- .../http/codec/json/Jackson2JsonEncoderTests.java | 2 +- .../http/codec/json/Jackson2SmileDecoderTests.java | 2 +- .../http/codec/json/Jackson2SmileEncoderTests.java | 4 ++-- .../http/codec/json/Jackson2TokenizerTests.java | 2 +- .../multipart/MultipartHttpMessageWriterTests.java | 2 +- .../SynchronossPartHttpMessageReaderTests.java | 4 ++-- .../http/codec/protobuf/ProtobufDecoderTests.java | 2 +- .../http/codec/protobuf/ProtobufEncoderTests.java | 2 +- .../http/codec/xml/Jaxb2XmlDecoderTests.java | 2 +- .../http/codec/xml/Jaxb2XmlEncoderTests.java | 4 ++-- .../http/codec/xml/XmlEventDecoderTests.java | 2 +- .../feed/AtomFeedHttpMessageConverterTests.java | 2 +- .../feed/RssChannelHttpMessageConverterTests.java | 2 +- .../xml/Jaxb2RootElementHttpMessageConverterTests.java | 2 +- .../converter/xml/SourceHttpMessageConverterTests.java | 2 +- .../http/server/reactive/ChannelSendOperatorTests.java | 2 +- .../reactive/HttpHeadResponseDecoratorTests.java | 2 +- .../web/bind/ServletRequestUtilsTests.java | 4 ++-- .../web/context/request/SessionScopeTests.java | 2 +- .../reactive/config/ResourceHandlerRegistryTests.java | 2 +- .../web/reactive/function/BodyInsertersTests.java | 2 +- .../function/client/ExchangeFilterFunctionsTests.java | 2 +- .../client/WebClientDataBufferAllocatingTests.java | 2 +- .../web/reactive/resource/ResourceWebHandlerTests.java | 2 +- .../annotation/MessageWriterResultHandlerTests.java | 2 +- .../RequestPartMethodArgumentResolverTests.java | 2 +- .../annotation/ResponseEntityResultHandlerTests.java | 2 +- .../result/view/HttpMessageWriterViewTests.java | 2 +- .../result/view/ViewResolutionResultHandlerTests.java | 2 +- .../web/reactive/result/view/ZeroDemandResponse.java | 2 +- .../ServletAnnotationControllerHandlerMethodTests.java | 2 +- .../web/servlet/view/feed/AtomFeedViewTests.java | 2 +- .../web/servlet/view/feed/RssFeedViewTests.java | 2 +- .../sockjs/client/AbstractSockJsIntegrationTests.java | 4 ++-- 196 files changed, 263 insertions(+), 263 deletions(-) rename spring-core/src/test/java/org/springframework/core/{test/fixtures => testfixture}/TestGroupParsingTests.java (98%) rename spring-core/src/test/java/org/springframework/core/{test/fixtures => testfixture}/TestGroupTests.java (95%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/Assume.java (96%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/EnabledForTestGroups.java (96%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/TestGroup.java (98%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/TestGroupsCondition.java (97%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/TimeStamped.java (95%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/codec/AbstractDecoderTests.java (99%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/codec/AbstractEncoderTests.java (98%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/env/EnvironmentTestUtils.java (98%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/env/MockPropertySource.java (98%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/io/ResourceTestUtils.java (96%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/io/SerializationTestUtils.java (97%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/io/buffer/AbstractDataBufferAllocatingTests.java (97%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/io/buffer/AbstractLeakCheckingTests.java (96%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/io/buffer/DataBufferTestUtils.java (97%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/io/buffer/LeakAwareDataBuffer.java (98%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/io/buffer/LeakAwareDataBufferFactory.java (98%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/stereotype/Component.java (95%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/stereotype/Indexed.java (94%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/xml/XmlContent.java (96%) rename spring-core/src/testFixtures/java/org/springframework/core/{test/fixtures => testfixture}/xml/XmlContentAssert.java (97%) diff --git a/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java b/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java index c2a265443ab9..b20012250c72 100644 --- a/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java @@ -23,7 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpSession; import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; diff --git a/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java b/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java index 77f1145de82f..af771522f825 100644 --- a/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java @@ -28,7 +28,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.dao.support.PersistenceExceptionTranslator; import org.springframework.stereotype.Repository; @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.Mockito.mock; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * Integration tests cornering bug SPR-8651, which revealed that @Scheduled methods may diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java index e445598dd282..d048e6e0d18c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; import test.aop.PerThisAspect; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java index 2896114e7bb9..c9d752c1699e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java @@ -33,7 +33,7 @@ import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Rob Harrop diff --git a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java index 67cc99823d7c..6a01b03ad7b2 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Mark Fisher diff --git a/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java b/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java index c8e21cb8c40d..f1ab7f273db9 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * Tests that the <aop:config/> element can be used as a top level element. diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java index dd99d98d6470..d58a9b594a16 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java @@ -25,7 +25,7 @@ import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Juergen Hoeller diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java index 9ba9c837dd59..39b93fe473c6 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java @@ -39,7 +39,7 @@ import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.Order; -import org.springframework.core.test.fixtures.TimeStamped; +import org.springframework.core.testfixture.TimeStamped; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.interceptor.NopInterceptor; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java index e50ebf8dc2ee..f06491d000b3 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.test.fixtures.beans.DerivedTestBean; import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java index 2c0d1f1e3797..e9f6a3f0cb83 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * Non-XML tests are in AbstractAopProxyTests diff --git a/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java b/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java index 7c09bbb7c5ab..a746532495b0 100644 --- a/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Mark Fisher diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java index e4358b3883be..880757dcbf9c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java index bf98f8ac491a..cf1e22c356bb 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java @@ -26,7 +26,7 @@ import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.target.EmptyTargetSource; import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.tests.aop.interceptor.NopInterceptor; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java index 21f0b04e05ad..9cb1a04934ba 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java @@ -30,8 +30,8 @@ import org.springframework.beans.test.fixtures.beans.Person; import org.springframework.beans.test.fixtures.beans.SerializablePerson; import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.core.test.fixtures.TimeStamped; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.TimeStamped; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java index 206a2e871185..df7b67dfaf2b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.test.fixtures.beans.IOther; import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.lang.Nullable; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java index 0e921e05862b..8a9f1ec1e3e2 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java @@ -23,7 +23,7 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.test.fixtures.beans.Person; import org.springframework.beans.test.fixtures.beans.SerializablePerson; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java index 62d1d1e5a87e..1782124f278e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java @@ -25,12 +25,12 @@ import org.springframework.beans.test.fixtures.beans.Person; import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.Resource; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Rod Johnson diff --git a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java index 9ddd2a53e071..609f159a9da8 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java @@ -25,7 +25,7 @@ import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Stephane Nicoll diff --git a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java index 85396507092a..d48d213f8d2d 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java @@ -28,12 +28,12 @@ import org.springframework.beans.test.fixtures.beans.Person; import org.springframework.beans.test.fixtures.beans.SerializablePerson; import org.springframework.beans.test.fixtures.beans.SideEffectBean; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Rod Johnson diff --git a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java index 8f1ffc90be89..3a7276921817 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java @@ -26,7 +26,7 @@ import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Juergen Hoeller diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java index c1eaa77ea39a..dc3da8eff31b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.test.fixtures.beans.SerializablePerson; import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java index 04a3c695f6eb..4be4d16b5a3c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.test.fixtures.beans.SideEffectBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Rod Johnson diff --git a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java index 4170e6402f3c..9cfa6d4848b8 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.test.fixtures.beans.SideEffectBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Rod Johnson diff --git a/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java index 23c1c56f048e..ac33fd950adb 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java @@ -18,10 +18,10 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * @author Rob Harrop diff --git a/spring-aop/src/test/java/org/springframework/tests/aop/interceptor/TimestampIntroductionInterceptor.java b/spring-aop/src/test/java/org/springframework/tests/aop/interceptor/TimestampIntroductionInterceptor.java index 41e79f3e5c94..dc04a9fba9db 100644 --- a/spring-aop/src/test/java/org/springframework/tests/aop/interceptor/TimestampIntroductionInterceptor.java +++ b/spring-aop/src/test/java/org/springframework/tests/aop/interceptor/TimestampIntroductionInterceptor.java @@ -17,7 +17,7 @@ package org.springframework.tests.aop.interceptor; import org.springframework.aop.support.DelegatingIntroductionInterceptor; -import org.springframework.core.test.fixtures.TimeStamped; +import org.springframework.core.testfixture.TimeStamped; @SuppressWarnings("serial") public class TimestampIntroductionInterceptor extends DelegatingIntroductionInterceptor diff --git a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java index 940c3e044b21..2f7ad0f5b6f0 100644 --- a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java +++ b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java @@ -30,7 +30,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.core.task.SimpleAsyncTaskExecutor; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @@ -38,7 +38,7 @@ import org.springframework.util.concurrent.ListenableFuture; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * Unit tests for {@link AnnotationAsyncExecutionAspect}. diff --git a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java index 156df6d2802e..0b41d64982ec 100644 --- a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java @@ -52,8 +52,8 @@ import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.core.convert.support.GenericConversionService; -import org.springframework.core.test.fixtures.Assume; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.Assume; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.lang.Nullable; import org.springframework.util.StopWatch; import org.springframework.util.StringUtils; @@ -62,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.within; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * Shared tests for property accessors. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java index 2fc77072a28e..dc214a2a425a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java @@ -37,7 +37,7 @@ import org.springframework.util.ObjectUtils; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Rod Johnson diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java index 2587d05e4e60..2e4857b4ccd1 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java @@ -33,11 +33,11 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.propertyeditors.CustomDateEditor; -import org.springframework.core.test.fixtures.EnabledForTestGroups; -import org.springframework.core.test.fixtures.TestGroup; +import org.springframework.core.testfixture.EnabledForTestGroups; +import org.springframework.core.testfixture.TestGroup; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Guillaume Poirier diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java index 6d50c6e1df66..da710e31a589 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java @@ -94,10 +94,10 @@ import org.springframework.core.convert.support.GenericConversionService; import org.springframework.core.io.Resource; import org.springframework.core.io.UrlResource; -import org.springframework.core.test.fixtures.Assume; -import org.springframework.core.test.fixtures.EnabledForTestGroups; -import org.springframework.core.test.fixtures.TestGroup; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.Assume; +import org.springframework.core.testfixture.EnabledForTestGroups; +import org.springframework.core.testfixture.TestGroup; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.util.StopWatch; import org.springframework.util.StringValueResolver; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java index 427161efb3b3..1e466c6da352 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java @@ -27,11 +27,11 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.Resource; -import org.springframework.core.test.fixtures.stereotype.Component; +import org.springframework.core.testfixture.stereotype.Component; import org.springframework.util.Assert; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Rob Harrop diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java index e7e79b6b3e54..87dcbe72d314 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java @@ -72,7 +72,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.Order; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java index 259132d5ff90..02a87f6c0d4b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * Unit tests for {@link CustomAutowireConfigurer}. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java index d6cd527c74ec..a90d044209a4 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java @@ -44,7 +44,7 @@ import org.springframework.beans.test.fixtures.beans.IndexedTestBean; import org.springframework.beans.test.fixtures.beans.NestedTestBean; import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java index e9241a8353b2..38ad12dc7eb5 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * Unit tests for {@link FieldRetrievingFactoryBean}. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java index d045f1d9619d..97805143da86 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java @@ -28,13 +28,13 @@ import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Colin Sampaleanu diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java index cdd9778c1348..27a00cb5c47c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java @@ -23,7 +23,7 @@ import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * Unit tests for {@link PropertiesFactoryBean}. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java index 1dc74c7115af..dd256ece36ae 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java @@ -25,7 +25,7 @@ import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * Unit tests for {@link PropertyPathFactoryBean}. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java index f48ec3470c2a..c85944480a17 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java @@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * Unit tests for various {@link PropertyResourceConfigurer} implementations including: diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java index 6bfc37ad9222..a123a5721b84 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java @@ -28,7 +28,7 @@ import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * Simple test to illustrate and verify scope usage. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java index 40b07c0b628a..feb10d03633b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java @@ -27,7 +27,7 @@ import org.springframework.beans.test.fixtures.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource; +import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; /** * @author Rob Harrop diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java index 311b87088907..de938f38b746 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java @@ -53,11 +53,11 @@ import org.springframework.core.annotation.Order; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.UrlResource; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.core.test.fixtures.TestGroup.LONG_RUNNING; +import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING; /** * @author Juergen Hoeller diff --git a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java index e5a548cacd2d..eff54703337d 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java @@ -26,10 +26,10 @@ import org.junit.jupiter.api.Test; import org.springframework.context.test.fixtures.cache.AbstractCacheTests; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.TestGroup.LONG_RUNNING; +import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING; /** * @author Costin Leau diff --git a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java index c6b4efeff831..d8e4506c516a 100644 --- a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java +++ b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java @@ -38,7 +38,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.StaticApplicationContext; import org.springframework.core.task.TaskExecutor; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.jdbc.core.JdbcTemplate; import static org.assertj.core.api.Assertions.assertThat; @@ -46,7 +46,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * @author Juergen Hoeller diff --git a/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java b/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java index deb14733357b..99f9d412910d 100644 --- a/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java +++ b/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java @@ -52,7 +52,7 @@ import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; import org.springframework.context.support.StaticMessageSource; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.util.ObjectUtils; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.FieldError; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java index fee1f223aebf..b93e64480468 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java @@ -54,9 +54,9 @@ import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.core.io.ClassPathResource; -import org.springframework.core.test.fixtures.Assume; -import org.springframework.core.test.fixtures.EnabledForTestGroups; -import org.springframework.core.test.fixtures.TestGroup; +import org.springframework.core.testfixture.Assume; +import org.springframework.core.testfixture.EnabledForTestGroups; +import org.springframework.core.testfixture.TestGroup; import org.springframework.lang.Nullable; import org.springframework.util.StopWatch; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java index 3876a78a33d4..94b08b3ff02e 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java @@ -62,10 +62,10 @@ import org.springframework.beans.test.fixtures.beans.Person; import org.springframework.beans.test.fixtures.beans.SerializablePerson; import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.core.test.fixtures.EnabledForTestGroups; -import org.springframework.core.test.fixtures.TestGroup; -import org.springframework.core.test.fixtures.TimeStamped; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.EnabledForTestGroups; +import org.springframework.core.testfixture.TestGroup; +import org.springframework.core.testfixture.TimeStamped; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.tests.aop.advice.CountingAfterReturningAdvice; import org.springframework.tests.aop.advice.CountingBeforeAdvice; @@ -765,7 +765,7 @@ public void testIntroductionThrowsUncheckedException() throws Throwable { @SuppressWarnings("serial") class MyDi extends DelegatingIntroductionInterceptor implements TimeStamped { /** - * @see org.springframework.core.test.fixtures.util.TimeStamped#getTimeStamp() + * @see org.springframework.core.testfixture.util.TimeStamped#getTimeStamp() */ @Override public long getTimeStamp() { diff --git a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java index 22ca040e5173..040687e30ad8 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java @@ -52,8 +52,8 @@ import org.springframework.context.ApplicationListener; import org.springframework.context.test.fixtures.beans.TestApplicationListener; import org.springframework.core.io.ClassPathResource; -import org.springframework.core.test.fixtures.TimeStamped; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.TimeStamped; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.advice.MyThrowsHandler; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java index e60395ef6f86..cbd7ba5aff73 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java @@ -28,7 +28,7 @@ import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.core.test.fixtures.TimeStamped; +import org.springframework.core.testfixture.TimeStamped; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.interceptor.NopInterceptor; diff --git a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java index 3a2bf91f916d..246863726d3b 100644 --- a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java @@ -30,7 +30,7 @@ import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.test.fixtures.SimpleMapScope; import org.springframework.core.io.ClassPathResource; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java index 0c2390d12435..68f75103a80b 100644 --- a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java @@ -30,7 +30,7 @@ import org.springframework.beans.test.fixtures.beans.SideEffectBean; import org.springframework.context.support.StaticApplicationContext; import org.springframework.core.io.ClassPathResource; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java index 311a933b21a0..70c6116e7c60 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java @@ -61,7 +61,7 @@ import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.UrlResource; import org.springframework.core.io.support.EncodedResource; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.sample.beans.ResourceTestBean; import org.springframework.util.ClassUtils; import org.springframework.util.FileCopyUtils; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java index 128bd67f2d6d..b0a89c07e961 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java @@ -36,11 +36,11 @@ import org.springframework.beans.test.fixtures.beans.ITestBean; import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.core.test.fixtures.Assume; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.Assume; +import org.springframework.core.testfixture.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * @author Juergen Hoeller diff --git a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java index 405aa16ccbcb..44af70d9b10f 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java @@ -42,7 +42,7 @@ import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.jndi.support.SimpleJndiBeanFactory; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java index 441ca88cd0d2..25061f5a0451 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java @@ -56,7 +56,7 @@ import org.springframework.core.env.Environment; import org.springframework.core.env.Profiles; import org.springframework.core.io.ResourceLoader; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.filter.TypeFilter; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java index 4b1630566016..e0669373f71b 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.test.fixtures.SimpleMapScope; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java index 598c1a0c8633..f2f584f29f20 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java @@ -52,14 +52,14 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.core.io.support.EncodedResource; -import org.springframework.core.test.fixtures.Assume; -import org.springframework.core.test.fixtures.EnabledForTestGroups; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.Assume; +import org.springframework.core.testfixture.EnabledForTestGroups; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.util.FileCopyUtils; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * @author Juergen Hoeller diff --git a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java index 8db30517da02..ca8e26eb73a5 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.core.test.fixtures.env.MockPropertySource; +import org.springframework.core.testfixture.env.MockPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java index f24be678c738..16e0000c88ab 100644 --- a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java @@ -27,10 +27,10 @@ import org.springframework.context.Lifecycle; import org.springframework.context.LifecycleProcessor; import org.springframework.context.SmartLifecycle; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * @author Mark Fisher diff --git a/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java index 190ba795821f..968aba7f695f 100644 --- a/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java @@ -28,7 +28,7 @@ import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; import org.springframework.context.annotation.Profile; import org.springframework.core.env.AbstractEnvironment; -import org.springframework.core.test.fixtures.env.EnvironmentTestUtils; +import org.springframework.core.testfixture.env.EnvironmentTestUtils; import org.springframework.stereotype.Component; import static java.lang.String.format; diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java index bc71706e11f8..f899e376c40c 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java @@ -30,7 +30,7 @@ import org.springframework.core.env.StandardEnvironment; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.core.test.fixtures.env.MockPropertySource; +import org.springframework.core.testfixture.env.MockPropertySource; import org.springframework.mock.env.MockEnvironment; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java b/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java index bb23db28d4a0..6397865a1f88 100644 --- a/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java +++ b/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java @@ -18,7 +18,7 @@ import org.springframework.core.env.AbstractEnvironment; import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.test.fixtures.env.MockPropertySource; +import org.springframework.core.testfixture.env.MockPropertySource; /** * Simple {@link ConfigurableEnvironment} implementation exposing @@ -27,7 +27,7 @@ * @author Chris Beams * @author Sam Brannen * @since 3.2 - * @see org.springframework.mock.env.MockPropertySource + * @see org.springframework.core.testfixture.env.MockPropertySource */ public class MockEnvironment extends AbstractEnvironment { diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java index 6a155d4cc899..89d7e09c9c3f 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java @@ -26,7 +26,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.config.IntervalTask; @@ -35,7 +35,7 @@ import org.springframework.scheduling.config.TaskManagementConfigUtils; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * Tests use of @EnableScheduling on @Configuration classes. diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java index c35995d0f6bd..5272b8596ee3 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import org.springframework.core.task.NoOpRunnable; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * @author Rick Evans diff --git a/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java b/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java index 65c9bfdb5e61..ac8d95bf9555 100644 --- a/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.scripting.Messenger; import org.springframework.scripting.ScriptCompilationException; import org.springframework.scripting.groovy.GroovyScriptFactory; @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.mockito.Mockito.mock; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * @author Rick Evans diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java index 0145e155b780..b4d925d845df 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java @@ -50,7 +50,7 @@ import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; import org.springframework.context.support.StaticMessageSource; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.util.ObjectUtils; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.FieldError; diff --git a/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt b/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt index d9fc98990aef..cc315fcddecd 100644 --- a/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt @@ -25,7 +25,7 @@ import org.springframework.beans.factory.getBean import org.springframework.context.support.BeanDefinitionDsl.* import org.springframework.core.env.SimpleCommandLinePropertySource import org.springframework.core.env.get -import org.springframework.core.test.fixtures.env.MockPropertySource +import org.springframework.core.testfixture.env.MockPropertySource import java.util.stream.Collectors @Suppress("UNUSED_EXPRESSION") diff --git a/spring-core/src/test/java/example/type/AspectJTypeFilterTestsTypes.java b/spring-core/src/test/java/example/type/AspectJTypeFilterTestsTypes.java index bf17886f9b7a..089fe1b4f172 100644 --- a/spring-core/src/test/java/example/type/AspectJTypeFilterTestsTypes.java +++ b/spring-core/src/test/java/example/type/AspectJTypeFilterTestsTypes.java @@ -16,7 +16,7 @@ package example.type; -import org.springframework.core.test.fixtures.stereotype.Component; +import org.springframework.core.testfixture.stereotype.Component; /** * We must use a standalone set of types to ensure that no one else is loading diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java index 0aca2ed60776..5cb78d611ff5 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java @@ -42,8 +42,8 @@ import org.springframework.core.annotation.AnnotationUtilsTests.ImplementsInterfaceWithGenericAnnotatedMethod; import org.springframework.core.annotation.AnnotationUtilsTests.WebController; import org.springframework.core.annotation.AnnotationUtilsTests.WebMapping; -import org.springframework.core.test.fixtures.stereotype.Component; -import org.springframework.core.test.fixtures.stereotype.Indexed; +import org.springframework.core.testfixture.stereotype.Component; +import org.springframework.core.testfixture.stereotype.Indexed; import org.springframework.lang.NonNullApi; import org.springframework.lang.Nullable; import org.springframework.util.MultiValueMap; diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 78ec17e6b8ca..556c7c684357 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -39,7 +39,7 @@ import org.springframework.core.Ordered; import org.springframework.core.annotation.subpackage.NonPublicAnnotatedClass; -import org.springframework.core.test.fixtures.stereotype.Component; +import org.springframework.core.testfixture.stereotype.Component; import org.springframework.lang.NonNullApi; import static java.util.Arrays.asList; @@ -928,7 +928,7 @@ void synthesizeAnnotationFromMapWithAttributeOfIncorrectType() throws Exception Map map = Collections.singletonMap(VALUE, 42L); assertThatIllegalStateException().isThrownBy(() -> synthesizeAnnotation(map, Component.class, null).value()) - .withMessageContaining("Attribute 'value' in annotation org.springframework.core.test.fixtures.stereotype.Component " + .withMessageContaining("Attribute 'value' in annotation org.springframework.core.testfixture.stereotype.Component " + "should be compatible with java.lang.String but a java.lang.Long value was returned"); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java index 956f93f549a8..4b6ab16ca923 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java @@ -43,8 +43,8 @@ import org.springframework.core.annotation.MergedAnnotation.Adapt; import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; import org.springframework.core.annotation.subpackage.NonPublicAnnotatedClass; -import org.springframework.core.test.fixtures.stereotype.Component; -import org.springframework.core.test.fixtures.stereotype.Indexed; +import org.springframework.core.testfixture.stereotype.Component; +import org.springframework.core.testfixture.stereotype.Indexed; import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import org.springframework.util.MultiValueMap; @@ -1770,7 +1770,7 @@ void synthesizeFromMapWithAttributeOfIncorrectType() throws Exception { MergedAnnotation annotation = MergedAnnotation.of(Component.class, map); assertThatIllegalStateException().isThrownBy(() -> annotation.synthesize().value()) .withMessage("Attribute 'value' in annotation " + - "org.springframework.core.test.fixtures.stereotype.Component should be " + + "org.springframework.core.testfixture.stereotype.Component should be " + "compatible with java.lang.String but a java.lang.Long value was returned"); } diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java index c41874ef0836..10f93f515031 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java @@ -24,7 +24,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; +import org.springframework.core.testfixture.codec.AbstractDecoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java index 12d40d64aad0..dcb5043f2974 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java @@ -22,7 +22,7 @@ import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; -import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; +import org.springframework.core.testfixture.codec.AbstractEncoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java index 1d0215ee58e6..d14a7543609a 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java @@ -25,7 +25,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; +import org.springframework.core.testfixture.codec.AbstractDecoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java index 066aa9051d9b..1bc0e3f665d6 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java @@ -23,7 +23,7 @@ import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; -import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; +import org.springframework.core.testfixture.codec.AbstractEncoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java index 6356dfc810e2..e73bb2c12455 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java @@ -23,7 +23,7 @@ import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; -import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; +import org.springframework.core.testfixture.codec.AbstractEncoderTests; import org.springframework.util.MimeTypeUtils; import static java.nio.charset.StandardCharsets.ISO_8859_1; diff --git a/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java index ec0ccdda0869..e1296537bfd3 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java @@ -25,7 +25,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; +import org.springframework.core.testfixture.codec.AbstractDecoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java index cb6242c7182c..9a578ed403ff 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java @@ -24,7 +24,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; +import org.springframework.core.testfixture.codec.AbstractEncoderTests; import org.springframework.util.MimeTypeUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java index 409d9c693e96..1c3a531f7a3e 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java @@ -28,7 +28,7 @@ import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.Resource; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; +import org.springframework.core.testfixture.codec.AbstractDecoderTests; import org.springframework.util.MimeTypeUtils; import org.springframework.util.StreamUtils; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java index b99bcb3812cf..1925415e7345 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java @@ -28,7 +28,7 @@ import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.Resource; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; +import org.springframework.core.testfixture.codec.AbstractEncoderTests; import org.springframework.lang.Nullable; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java index 8148ecf64e05..2a25e3cc141b 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java @@ -32,8 +32,8 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.support.ResourceRegion; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; diff --git a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java index bcfc43b498f0..0d3d29ceef55 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java @@ -30,7 +30,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferLimitException; -import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; +import org.springframework.core.testfixture.codec.AbstractDecoderTests; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; diff --git a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java index f5a932bacbd5..a91f54152705 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java @@ -51,13 +51,13 @@ import org.springframework.core.convert.ConverterNotFoundException; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.support.DefaultConversionService; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.util.ClassUtils; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * Unit tests for {@link DefaultConversionService}. diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java index fd2271d26f6b..9e0c64648279 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java @@ -43,7 +43,7 @@ import org.springframework.core.convert.converter.GenericConverter; import org.springframework.core.io.DescriptiveResource; import org.springframework.core.io.Resource; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.lang.Nullable; import org.springframework.util.StopWatch; import org.springframework.util.StringUtils; @@ -54,7 +54,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * Unit tests for {@link GenericConversionService}. diff --git a/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java b/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java index 9d04dcbd2466..222104a2a32b 100644 --- a/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.env.MockPropertySource; +import org.springframework.core.testfixture.env.MockPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java index bed53fce1f4d..f51fc97e9a02 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.springframework.core.convert.ConverterNotFoundException; -import org.springframework.core.test.fixtures.env.MockPropertySource; +import org.springframework.core.testfixture.env.MockPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java index 24bb7143ebe6..ee87b557100d 100644 --- a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java @@ -24,8 +24,8 @@ import org.junit.jupiter.api.Test; import org.springframework.core.SpringProperties; -import org.springframework.core.test.fixtures.env.EnvironmentTestUtils; -import org.springframework.core.test.fixtures.env.MockPropertySource; +import org.springframework.core.testfixture.env.EnvironmentTestUtils; +import org.springframework.core.testfixture.env.MockPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java index 2d006cd45a7e..cd0932e6257b 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java @@ -22,7 +22,7 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; -import org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests; +import org.springframework.core.testfixture.io.buffer.AbstractDataBufferAllocatingTests; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java index 168a6df23e84..2b785b0b7196 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java @@ -45,8 +45,8 @@ import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.AbstractDataBufferAllocatingTests; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java index 37d941dde6f1..64531c0865d9 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory; +import org.springframework.core.testfixture.io.buffer.LeakAwareDataBufferFactory; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.springframework.core.io.buffer.DataBufferUtils.release; diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java index 576df2655887..b369d125b300 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java @@ -20,8 +20,8 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.AbstractDataBufferAllocatingTests; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupParsingTests.java b/spring-core/src/test/java/org/springframework/core/testfixture/TestGroupParsingTests.java similarity index 98% rename from spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupParsingTests.java rename to spring-core/src/test/java/org/springframework/core/testfixture/TestGroupParsingTests.java index 097fd19c8c79..76f427d38c68 100644 --- a/spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupParsingTests.java +++ b/spring-core/src/test/java/org/springframework/core/testfixture/TestGroupParsingTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures; +package org.springframework.core.testfixture; import java.util.Collections; import java.util.EnumSet; diff --git a/spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupTests.java b/spring-core/src/test/java/org/springframework/core/testfixture/TestGroupTests.java similarity index 95% rename from spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupTests.java rename to spring-core/src/test/java/org/springframework/core/testfixture/TestGroupTests.java index 84eda4984c59..af9d829dae74 100644 --- a/spring-core/src/test/java/org/springframework/core/test/fixtures/TestGroupTests.java +++ b/spring-core/src/test/java/org/springframework/core/testfixture/TestGroupTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures; +package org.springframework.core.testfixture; import java.util.Arrays; import java.util.Set; @@ -30,8 +30,8 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.junit.jupiter.api.Assumptions.assumeTrue; -import static org.springframework.core.test.fixtures.TestGroup.LONG_RUNNING; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * Tests for {@link TestGroup}. diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index 0881e55de54f..f1342883bca0 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -33,7 +33,7 @@ import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AnnotationAttributes; -import org.springframework.core.test.fixtures.stereotype.Component; +import org.springframework.core.testfixture.stereotype.Component; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java index d1c7d1652f6c..1550c9d7c7b2 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java @@ -21,7 +21,7 @@ import example.type.NonInheritedAnnotation; import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.stereotype.Component; +import org.springframework.core.testfixture.stereotype.Component; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; diff --git a/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java b/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java index a3dfed9fcc9d..a356881775a8 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java @@ -88,7 +88,7 @@ void subclassPatternNoMatches() throws Exception { @Test void annotationPatternMatches() throws Exception { assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", - "@org.springframework.core.test.fixtures.stereotype.Component *..*"); + "@org.springframework.core.testfixture.stereotype.Component *..*"); assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", "@* *..*"); assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", @@ -96,9 +96,9 @@ void annotationPatternMatches() throws Exception { assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", "@*..*Component *..*"); assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", - "@org.springframework.core.test.fixtures.stereotype.Component *..*Component"); + "@org.springframework.core.testfixture.stereotype.Component *..*Component"); assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", - "@org.springframework.core.test.fixtures.stereotype.Component *"); + "@org.springframework.core.testfixture.stereotype.Component *"); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java b/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java index 405a742034bb..89421fe90538 100644 --- a/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java @@ -22,13 +22,13 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.UrlResource; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.core.type.classreading.CachingMetadataReaderFactory; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.TestGroup.LONG_RUNNING; +import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING; /** * Unit tests for checking the behaviour of {@link CachingMetadataReaderFactory} under diff --git a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java index 416ad92d2dbf..00e65b3f0747 100644 --- a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java +++ b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.sample.objects.TestObject; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java index 4bef1397a210..f9ed283756bd 100644 --- a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java @@ -27,12 +27,12 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.tests.sample.objects.TestObject; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * @author Rob Harrop diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTests.java index 2592d12a4a83..76d55709d13c 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTests.java @@ -34,7 +34,7 @@ import org.xml.sax.XMLReader; import org.xmlunit.util.Predicate; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java index a7fe73634c8d..40cef2118496 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java @@ -28,7 +28,7 @@ import org.xml.sax.InputSource; import org.xml.sax.XMLReader; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java index 0049180a3c5d..9ea91f2be760 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import static javax.xml.stream.XMLStreamConstants.END_DOCUMENT; import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java index 000307e318cd..e284337c723b 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java @@ -31,7 +31,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java index 908dfd3d1b93..dc82a03c3922 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java @@ -34,7 +34,7 @@ import org.w3c.dom.Document; import org.xml.sax.InputSource; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java index 7d9719a34733..633a5383701f 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java @@ -31,7 +31,7 @@ import org.w3c.dom.Node; import org.xmlunit.util.Predicate; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java index 7ed978406b42..f09526e7924c 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java @@ -27,7 +27,7 @@ import org.w3c.dom.Node; import org.xmlunit.util.Predicate; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/Assume.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/Assume.java similarity index 96% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/Assume.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/Assume.java index 1537f459a2a1..83c3dd8d9e90 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/Assume.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/Assume.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures; +package org.springframework.core.testfixture; import org.apache.commons.logging.Log; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/EnabledForTestGroups.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/EnabledForTestGroups.java similarity index 96% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/EnabledForTestGroups.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/EnabledForTestGroups.java index 5fd5eeab9201..490f42811edb 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/EnabledForTestGroups.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/EnabledForTestGroups.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures; +package org.springframework.core.testfixture; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroup.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/TestGroup.java similarity index 98% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroup.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/TestGroup.java index 0203908775b6..ddad71992076 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroup.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/TestGroup.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures; +package org.springframework.core.testfixture; import java.util.Collections; import java.util.EnumSet; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroupsCondition.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/TestGroupsCondition.java similarity index 97% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroupsCondition.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/TestGroupsCondition.java index e17d446033c4..010f33b7eb1d 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TestGroupsCondition.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/TestGroupsCondition.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures; +package org.springframework.core.testfixture; import java.util.Arrays; import java.util.Optional; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TimeStamped.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/TimeStamped.java similarity index 95% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TimeStamped.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/TimeStamped.java index 27fe1634002c..58f45ad8acdd 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/TimeStamped.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/TimeStamped.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures; +package org.springframework.core.testfixture; /** * This interface can be implemented by cacheable objects or cache entries, diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractDecoderTests.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractDecoderTests.java similarity index 99% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractDecoderTests.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractDecoderTests.java index 72fece41b7e3..5804d93fa83c 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractDecoderTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractDecoderTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.codec; +package org.springframework.core.testfixture.codec; import java.time.Duration; import java.util.Map; @@ -29,7 +29,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.codec.Decoder; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.MimeType; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractEncoderTests.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java similarity index 98% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractEncoderTests.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java index 33af4bb64b0e..09cae0ca19c0 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/codec/AbstractEncoderTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.codec; +package org.springframework.core.testfixture.codec; import java.util.Map; import java.util.function.Consumer; @@ -28,7 +28,7 @@ import org.springframework.core.codec.Encoder; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.MimeType; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/EnvironmentTestUtils.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/EnvironmentTestUtils.java similarity index 98% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/EnvironmentTestUtils.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/EnvironmentTestUtils.java index 227c70a84b73..8606c47be386 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/EnvironmentTestUtils.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/EnvironmentTestUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.env; +package org.springframework.core.testfixture.env; import java.lang.reflect.Field; import java.util.Collections; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/MockPropertySource.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/MockPropertySource.java similarity index 98% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/MockPropertySource.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/MockPropertySource.java index 9037af3d5b84..ae4944ddccb7 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/env/MockPropertySource.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/MockPropertySource.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.env; +package org.springframework.core.testfixture.env; import java.util.Properties; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/ResourceTestUtils.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/ResourceTestUtils.java similarity index 96% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/ResourceTestUtils.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/ResourceTestUtils.java index 3925c486876c..3542ab5d9793 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/ResourceTestUtils.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/ResourceTestUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.io; +package org.springframework.core.testfixture.io; import org.springframework.core.io.ClassPathResource; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/SerializationTestUtils.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/SerializationTestUtils.java similarity index 97% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/SerializationTestUtils.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/SerializationTestUtils.java index 798dc834776e..8958435aa21b 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/SerializationTestUtils.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/SerializationTestUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.io; +package org.springframework.core.testfixture.io; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractDataBufferAllocatingTests.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/AbstractDataBufferAllocatingTests.java similarity index 97% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractDataBufferAllocatingTests.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/AbstractDataBufferAllocatingTests.java index e8f40a82e1f7..5c5ad5f44fa3 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractDataBufferAllocatingTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/AbstractDataBufferAllocatingTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.io.buffer; +package org.springframework.core.testfixture.io.buffer; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -148,7 +148,7 @@ private static long getAllocations(List metrics) { @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @ParameterizedTest(name = "[{index}] {0}") - @MethodSource("org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests#dataBufferFactories()") + @MethodSource("org.springframework.core.testfixture.io.buffer.AbstractDataBufferAllocatingTests#dataBufferFactories()") public @interface ParameterizedDataBufferAllocatingTest { } diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractLeakCheckingTests.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/AbstractLeakCheckingTests.java similarity index 96% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractLeakCheckingTests.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/AbstractLeakCheckingTests.java index e6b5f3b425a9..061cad5f8e37 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/AbstractLeakCheckingTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/AbstractLeakCheckingTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.io.buffer; +package org.springframework.core.testfixture.io.buffer; import org.junit.jupiter.api.AfterEach; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/DataBufferTestUtils.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/DataBufferTestUtils.java similarity index 97% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/DataBufferTestUtils.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/DataBufferTestUtils.java index d66fca194798..2410d07a716d 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/DataBufferTestUtils.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/DataBufferTestUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.io.buffer; +package org.springframework.core.testfixture.io.buffer; import java.nio.charset.Charset; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBuffer.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/LeakAwareDataBuffer.java similarity index 98% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBuffer.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/LeakAwareDataBuffer.java index cb42a0468e44..f03036f13109 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBuffer.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/LeakAwareDataBuffer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.io.buffer; +package org.springframework.core.testfixture.io.buffer; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferWrapper; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBufferFactory.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/LeakAwareDataBufferFactory.java similarity index 98% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBufferFactory.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/LeakAwareDataBufferFactory.java index e3c8dced702a..29ed5905cd94 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/io/buffer/LeakAwareDataBufferFactory.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/LeakAwareDataBufferFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.io.buffer; +package org.springframework.core.testfixture.io.buffer; import java.nio.ByteBuffer; import java.time.Duration; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Component.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/stereotype/Component.java similarity index 95% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Component.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/stereotype/Component.java index 04bf3e0fc7eb..15dc1f13f650 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Component.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/stereotype/Component.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.stereotype; +package org.springframework.core.testfixture.stereotype; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Indexed.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/stereotype/Indexed.java similarity index 94% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Indexed.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/stereotype/Indexed.java index 2da265f6cb77..0f91f76bc360 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/stereotype/Indexed.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/stereotype/Indexed.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.stereotype; +package org.springframework.core.testfixture.stereotype; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContent.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/xml/XmlContent.java similarity index 96% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContent.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/xml/XmlContent.java index becbae6d2c78..94b44912c65c 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContent.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/xml/XmlContent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.xml; +package org.springframework.core.testfixture.xml; import java.io.StringWriter; diff --git a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContentAssert.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/xml/XmlContentAssert.java similarity index 97% rename from spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContentAssert.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/xml/XmlContentAssert.java index c76d1cb3a5ce..6e05f8208124 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/test/fixtures/xml/XmlContentAssert.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/xml/XmlContentAssert.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.test.fixtures.xml; +package org.springframework.core.testfixture.xml; import org.assertj.core.api.AbstractAssert; import org.w3c.dom.Node; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java index a18114da24d6..40a6fa7cb25d 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.expression.AccessException; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; @@ -33,7 +33,7 @@ import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * Testing variations on map access. diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java index b1cbb7f0aa6b..164e849f9f38 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; @@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; ///CLOVER:OFF diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java index ad5e78c6cf93..cf3d4b8a9f46 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java @@ -29,7 +29,7 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.io.ClassPathResource; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.jdbc.BadSqlGrammarException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.AbstractDriverBasedDataSource; @@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.core.test.fixtures.TestGroup.LONG_RUNNING; +import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING; import static org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.DEFAULT_DATABASE_NAME; /** diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java index 919f4b17dabc..0b401b2a87c9 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; import org.mockito.InOrder; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.jdbc.UncategorizedSQLException; import org.springframework.transaction.CannotCreateTransactionException; @@ -58,7 +58,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * @author Juergen Hoeller diff --git a/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java b/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java index 088a53804c4e..8e207444f1f1 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java index 8f256aa50776..a676edb99b10 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; import org.xmlunit.diff.DifferenceEvaluator; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.messaging.Message; import org.springframework.messaging.support.MessageBuilder; import org.springframework.oxm.jaxb.Jaxb2Marshaller; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestEncoderMethodReturnValueHandler.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestEncoderMethodReturnValueHandler.java index ed40c25a9dd4..50bb018c1ac6 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestEncoderMethodReturnValueHandler.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestEncoderMethodReturnValueHandler.java @@ -24,7 +24,7 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.codec.Encoder; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.messaging.Message; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/LeakAwareNettyDataBufferFactory.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/LeakAwareNettyDataBufferFactory.java index 762ba52151b3..1f2e9271fa94 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/LeakAwareNettyDataBufferFactory.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/LeakAwareNettyDataBufferFactory.java @@ -31,7 +31,7 @@ import org.springframework.util.ObjectUtils; /** - * Unlike {@link org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory} + * Unlike {@link org.springframework.core.testfixture.io.buffer.LeakAwareDataBufferFactory} * this one is an instance of {@link NettyDataBufferFactory} which is necessary * since {@link PayloadUtils} does instanceof checks, and that also allows * intercepting {@link NettyDataBufferFactory#wrap(ByteBuf)}. diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java index 23d73df77aba..6a8e84a32f15 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java @@ -33,7 +33,7 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.core.io.buffer.NettyDataBuffer; import org.springframework.core.io.buffer.NettyDataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java index f368ce745779..ddeca0ddeb74 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java @@ -30,7 +30,7 @@ import org.springframework.core.io.buffer.DefaultDataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.core.io.buffer.NettyDataBuffer; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java index 3d59175823a8..937bdaef4c47 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.util.MimeTypeUtils; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java index 51ffa961aa32..15c27ccc5f03 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.orm.jpa.domain.DriversLicense; import org.springframework.orm.jpa.domain.Person; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java index 23fb944acef9..a2495d2267cc 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java @@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.dao.DataAccessException; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java index 885e22d77c3e..9409e437cece 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java @@ -39,7 +39,7 @@ import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.test.fixtures.SimpleMapScope; import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.orm.jpa.AbstractEntityManagerFactoryBeanTests; import org.springframework.orm.jpa.DefaultJpaDialect; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java index 6dd6a91f1f76..d6a539691cdf 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java @@ -36,7 +36,7 @@ import org.w3c.dom.Element; import org.w3c.dom.Text; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.util.xml.StaxUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java index 2dc7d4336109..be10b7fecdb9 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java @@ -46,7 +46,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.oxm.AbstractMarshallerTests; import org.springframework.oxm.UncategorizedMappingException; import org.springframework.oxm.XmlMappingException; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java index 6a904c2dd7d3..6ed3d7102d5c 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledOnJre; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.oxm.AbstractMarshallerTests; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java index c57a30455478..5d06efc4f4cd 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java @@ -56,7 +56,7 @@ import org.xmlunit.builder.Input; import org.xmlunit.xpath.JAXPXPathEngine; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.util.xml.StaxUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java index 5075ccd9f6e3..ee61b3ebeff1 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java @@ -24,7 +24,7 @@ import org.junit.Test; import org.junit.experimental.ParallelComputer; -import org.springframework.core.test.fixtures.TestGroup; +import org.springframework.core.testfixture.TestGroup; import org.springframework.test.context.junit4.InheritedConfigSpringJUnit4ClassRunnerAppCtxTests; import org.springframework.test.context.junit4.MethodLevelTransactionalSpringRunnerTests; import org.springframework.test.context.junit4.SpringJUnit47ClassRunnerRuleTests; diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java index 08c0948f33ee..17c04a825429 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java @@ -28,7 +28,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpCookie; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java index c5fae22e8844..229faa1aa4fb 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java @@ -32,7 +32,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.stereotype.Controller; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection; @@ -42,7 +42,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * Unit and integration tests for {@link DelegatingWebConnection}. diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java index 981e25d01a4a..bd74b3d6f080 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Configuration; -import org.springframework.core.test.fixtures.TestGroup; +import org.springframework.core.testfixture.TestGroup; import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java index 16670b908bdb..8c8146d09916 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java @@ -25,7 +25,7 @@ import org.openqa.selenium.htmlunit.HtmlUnitDriver; import org.springframework.context.annotation.Configuration; -import org.springframework.core.test.fixtures.TestGroup; +import org.springframework.core.testfixture.TestGroup; import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java index 62ecf10fd5ff..bb869e84744f 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java @@ -31,7 +31,7 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.interceptor.NoRollbackRuleAttribute; import org.springframework.transaction.interceptor.RollbackRuleAttribute; diff --git a/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java b/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java index 114348dcbcb7..5760d3b351a0 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java @@ -27,7 +27,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.support.TransactionSynchronizationManager; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java index dc4d69b840b5..c0900611d599 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; /** * @author Rod Johnson diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java index 5eb598d6688d..c870022cc2f2 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java @@ -24,7 +24,7 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java index 5b07c460bd6e..be9f8e6b43d5 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import org.springframework.context.test.fixtures.jndi.SimpleNamingContextBuilder; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.transaction.jta.JtaTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java b/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java index 22a30a2af022..2bb2e8c6fa48 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java @@ -33,7 +33,7 @@ import org.springframework.core.codec.CharSequenceEncoder; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory; +import org.springframework.core.testfixture.io.buffer.LeakAwareDataBufferFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpOutputMessage; diff --git a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java index 26bdaaa5b2f7..161c467b5c02 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java @@ -28,7 +28,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java index 152a3eb31cd5..6a133141ce4d 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java @@ -27,8 +27,8 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; diff --git a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java index b213758b4b7e..d6ef84b73f1e 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java @@ -27,7 +27,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import org.springframework.http.MediaType; import org.springframework.http.codec.json.Jackson2JsonDecoder; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java index 8e9bc7070869..2bd290d9b883 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java @@ -31,8 +31,8 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.AbstractDataBufferAllocatingTests; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.MediaType; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java index 4cfe5cb3868b..b434b2fdd156 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java @@ -26,7 +26,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; +import org.springframework.core.testfixture.codec.AbstractDecoderTests; import org.springframework.http.codec.Pojo; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.util.MimeType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java index e1293d55883e..b3ae238a8cab 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java @@ -26,8 +26,8 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.codec.Pojo; import org.springframework.http.codec.ServerSentEvent; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java index 6ec074bafb83..c1e0b61715da 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java @@ -37,7 +37,7 @@ import org.springframework.core.codec.CodecException; import org.springframework.core.codec.DecodingException; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; +import org.springframework.core.testfixture.codec.AbstractDecoderTests; import org.springframework.http.MediaType; import org.springframework.http.codec.Pojo; import org.springframework.http.codec.json.JacksonViewBean.MyJacksonView1; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java index 84a979c0fdc8..946b730f6c2e 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java @@ -34,7 +34,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; +import org.springframework.core.testfixture.codec.AbstractEncoderTests; import org.springframework.http.MediaType; import org.springframework.http.codec.Pojo; import org.springframework.http.codec.ServerSentEvent; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java index 13a8326fd7c9..b672918fcb90 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java @@ -26,7 +26,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; +import org.springframework.core.testfixture.codec.AbstractDecoderTests; import org.springframework.http.codec.Pojo; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.util.MimeType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java index 3fdffe872e5d..7b39ac59f44a 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java @@ -29,8 +29,8 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.codec.AbstractEncoderTests; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.codec.Pojo; import org.springframework.http.codec.ServerSentEvent; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java index 20dc4d994b51..c42291d0c9b1 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java @@ -35,7 +35,7 @@ import org.springframework.core.codec.DecodingException; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferLimitException; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; diff --git a/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java index 87e1f3300dce..36bfc18302e7 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java @@ -35,7 +35,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import org.springframework.http.HttpEntity; import org.springframework.http.MediaType; import org.springframework.http.client.MultipartBodyBuilder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java index b2fb11b3c77c..7d6661dfa9c7 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java @@ -36,8 +36,8 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.client.MultipartBodyBuilder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java index 1d3c367ce027..40501537dbca 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java @@ -29,7 +29,7 @@ import org.springframework.core.codec.DecodingException; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.test.fixtures.codec.AbstractDecoderTests; +import org.springframework.core.testfixture.codec.AbstractDecoderTests; import org.springframework.http.MediaType; import org.springframework.protobuf.Msg; import org.springframework.protobuf.SecondMsg; diff --git a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java index f0bfbd15a70a..c4738469dee7 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java @@ -27,7 +27,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; +import org.springframework.core.testfixture.codec.AbstractEncoderTests; import org.springframework.http.MediaType; import org.springframework.protobuf.Msg; import org.springframework.protobuf.SecondMsg; diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java index 9bc7894d1a08..7fda7067f20a 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java @@ -30,7 +30,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import org.springframework.http.MediaType; import org.springframework.http.codec.Pojo; import org.springframework.http.codec.xml.jaxb.XmlRootElement; diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java index 6522f57bf0fe..81d5767c15d9 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java @@ -30,8 +30,8 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.codec.AbstractEncoderTests; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.codec.AbstractEncoderTests; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.http.MediaType; import org.springframework.http.codec.Pojo; diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java index 3bd9b8ff50a4..cf48d090fa48 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java @@ -28,7 +28,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferLimitException; -import org.springframework.core.test.fixtures.io.buffer.AbstractLeakCheckingTests; +import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java index 4f733570186e..856dcd787067 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java @@ -31,7 +31,7 @@ import org.xmlunit.diff.ElementSelectors; import org.xmlunit.diff.NodeMatcher; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; import org.springframework.http.MockHttpOutputMessage; diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java index cea67dac4111..5d1e01f32871 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java @@ -27,7 +27,7 @@ import com.rometools.rome.feed.rss.Item; import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; import org.springframework.http.MockHttpOutputMessage; diff --git a/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java index 277eb3291faf..cf5fa05d46cd 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java @@ -36,7 +36,7 @@ import org.springframework.aop.framework.DefaultAopProxyFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; import org.springframework.http.MockHttpOutputMessage; diff --git a/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java index 53ccbb62f9e3..a54e6895efb7 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java @@ -41,7 +41,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; import org.springframework.http.MockHttpOutputMessage; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java index 24d14c548f4a..7a050dd67e7b 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java @@ -35,7 +35,7 @@ import reactor.test.StepVerifier; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory; +import org.springframework.core.testfixture.io.buffer.LeakAwareDataBufferFactory; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java index 83ccd8b089e1..55695bca6463 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java @@ -24,7 +24,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.NettyDataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory; +import org.springframework.core.testfixture.io.buffer.LeakAwareDataBufferFactory; import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java index f459f4f04aa8..c9a9553f255a 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java @@ -18,13 +18,13 @@ import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * @author Juergen Hoeller diff --git a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java index a767bbd8d460..da0d226b9a2c 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java @@ -31,7 +31,7 @@ import org.springframework.beans.test.fixtures.beans.DerivedTestBean; import org.springframework.beans.test.fixtures.beans.TestBean; import org.springframework.core.io.ClassPathResource; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpSession; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java index dec3055660d1..5ec569118c95 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java @@ -28,7 +28,7 @@ import org.springframework.cache.concurrent.ConcurrentMapCache; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.CacheControl; import org.springframework.http.server.PathContainer; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java index 2a37cf847811..a74864d76593 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java @@ -45,7 +45,7 @@ import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpMethod; import org.springframework.http.HttpRange; import org.springframework.http.ReactiveHttpOutputMessage; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java index 64e016e55ec8..a98844e486e8 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java @@ -27,7 +27,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java index a2e80fe64037..555c3f518023 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java @@ -34,7 +34,7 @@ import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.NettyDataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.AbstractDataBufferAllocatingTests; +import org.springframework.core.testfixture.io.buffer.AbstractDataBufferAllocatingTests; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java index 838a11cca3ac..f057b690661b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java @@ -39,7 +39,7 @@ import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.CacheControl; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java index 5da68b75be63..4273bd98b28e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java @@ -54,7 +54,7 @@ import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils.dumpString; +import static org.springframework.core.testfixture.io.buffer.DataBufferTestUtils.dumpString; import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.web.method.ResolvableMethod.on; import static org.springframework.web.reactive.HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java index d55746f8381e..4beaf7af247e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java @@ -33,7 +33,7 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.client.MultipartBodyBuilder; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java index 58c90779e1f1..86b92d67cff7 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java @@ -40,7 +40,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.codec.ByteBufferEncoder; import org.springframework.core.codec.CharSequenceEncoder; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java index acee2437d10d..e44647d08975 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java @@ -29,7 +29,7 @@ import org.springframework.core.codec.CharSequenceEncoder; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.MediaType; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.codec.xml.Jaxb2XmlEncoder; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java index b461aaaa076e..72e1f392ec85 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java @@ -38,7 +38,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.DataBufferTestUtils; +import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.server.reactive.ServerHttpResponse; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ZeroDemandResponse.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ZeroDemandResponse.java index d7e150bac8df..59b3c9460281 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ZeroDemandResponse.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ZeroDemandResponse.java @@ -24,7 +24,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; -import org.springframework.core.test.fixtures.io.buffer.LeakAwareDataBufferFactory; +import org.springframework.core.testfixture.io.buffer.LeakAwareDataBufferFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseCookie; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index 093f1eda916a..374c3516bed3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -78,7 +78,7 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.core.MethodParameter; import org.springframework.core.convert.converter.Converter; -import org.springframework.core.test.fixtures.io.SerializationTestUtils; +import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.format.support.FormattingConversionServiceFactoryBean; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java index f8b7bc7c5356..a0f05ac66329 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java @@ -29,7 +29,7 @@ import com.rometools.rome.feed.atom.Feed; import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java index bc4a2ac49f33..cf362d398d0c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java @@ -29,7 +29,7 @@ import com.rometools.rome.feed.rss.Item; import org.junit.jupiter.api.Test; -import org.springframework.core.test.fixtures.xml.XmlContent; +import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java index 8af8d83e3d05..ae57059f1932 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java @@ -49,7 +49,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.core.test.fixtures.EnabledForTestGroups; +import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.http.HttpHeaders; import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; @@ -69,7 +69,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import static org.springframework.core.test.fixtures.TestGroup.PERFORMANCE; +import static org.springframework.core.testfixture.TestGroup.PERFORMANCE; /** * Abstract base class for integration tests using the From 7cd4ddf5fcaeee4e288f57801eb0713a652eb979 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 29 Dec 2019 17:37:19 +0100 Subject: [PATCH 0245/2315] Rename test fixture package in spring-beans See gh-23550 --- ...NamespaceHandlerScopeIntegrationTests.java | 4 +- ...visorAutoProxyCreatorIntegrationTests.java | 2 +- ...ceHandlerScopeIntegrationTests-context.xml | 8 +- ...toProxyCreatorIntegrationTests-context.xml | 10 +-- .../AspectJExpressionPointcutTests.java | 26 +++--- .../BeanNamePointcutMatchingTests.java | 2 +- ...hodInvocationProceedingJoinPointTests.java | 4 +- .../TigerAspectJExpressionPointcutTests.java | 4 +- .../aspectj/TypePatternClassFilterTests.java | 28 +++---- .../AbstractAspectJAdvisorFactoryTests.java | 8 +- .../annotation/ArgumentBindingTests.java | 4 +- .../AspectJPointcutAdvisorTests.java | 2 +- .../AspectJNamespaceHandlerTests.java | 2 +- .../config/AopNamespaceHandlerEventTests.java | 2 +- .../aop/framework/AopProxyUtilsTests.java | 4 +- .../framework/IntroductionBenchmarkTests.java | 4 +- .../aop/framework/MethodInvocationTests.java | 2 +- .../aop/framework/ProxyFactoryTests.java | 6 +- .../ConcurrencyThrottleInterceptorTests.java | 6 +- .../ExposeBeanNameAdvisorsTests.java | 4 +- .../ExposeInvocationInterceptorTests.java | 4 +- .../AbstractRegexpMethodPointcutTests.java | 2 +- .../aop/support/AopUtilsTests.java | 2 +- .../aop/support/ClassFiltersTests.java | 4 +- .../aop/support/ClassUtilsTests.java | 2 +- .../aop/support/ComposablePointcutTests.java | 2 +- .../aop/support/ControlFlowPointcutTests.java | 4 +- ...elegatingIntroductionInterceptorTests.java | 12 +-- .../aop/support/MethodMatchersTests.java | 6 +- .../support/NameMatchMethodPointcutTests.java | 4 +- .../aop/support/PointcutsTests.java | 2 +- ...MethodPointcutAdvisorIntegrationTests.java | 6 +- .../aop/support/RootClassFilterTests.java | 2 +- .../CommonsPool2TargetSourceProxyTests.java | 2 +- .../target/HotSwappableTargetSourceTests.java | 6 +- .../aop/target/LazyInitTargetSourceTests.java | 2 +- .../PrototypeBasedTargetSourceTests.java | 4 +- .../target/PrototypeTargetSourceTests.java | 2 +- .../target/ThreadLocalTargetSourceTests.java | 4 +- .../AopNamespaceHandlerEventTests-context.xml | 2 +- ...PointcutErrorTests-pointcutDuplication.xml | 2 +- ...dlerPointcutErrorTests-pointcutMissing.xml | 2 +- ...ointcutAdvisorIntegrationTests-context.xml | 10 +-- ...onsPool2TargetSourceProxyTests-context.xml | 2 +- .../HotSwappableTargetSourceTests-context.xml | 4 +- ...LazyInitTargetSourceTests-customTarget.xml | 2 +- .../LazyInitTargetSourceTests-singleton.xml | 2 +- .../PrototypeTargetSourceTests-context.xml | 4 +- .../ThreadLocalTargetSourceTests-context.xml | 6 +- .../beans/AbstractPropertyAccessorTests.java | 10 +-- .../springframework/beans/BeanUtilsTests.java | 6 +- .../beans/BeanWrapperEnumTests.java | 4 +- .../beans/BeanWrapperGenericsTests.java | 8 +- .../beans/BeanWrapperTests.java | 2 +- .../CachedIntrospectionResultsTests.java | 4 +- .../beans/DirectFieldAccessorTests.java | 2 +- .../beans/ExtendedBeanInfoTests.java | 2 +- .../beans/factory/BeanFactoryUtilsTests.java | 12 +-- .../DefaultListableBeanFactoryTests.java | 16 ++-- ...wiredAnnotationBeanPostProcessorTests.java | 8 +- ...njectAnnotationBeanPostProcessorTests.java | 8 +- .../annotation/LookupAnnotationTests.java | 2 +- .../config/CustomEditorConfigurerTests.java | 2 +- .../FieldRetrievingFactoryBeanTests.java | 4 +- .../config/PropertyPathFactoryBeanTests.java | 4 +- .../PropertyPlaceholderConfigurerTests.java | 2 +- .../PropertyResourceConfigurerTests.java | 4 +- .../factory/config/SimpleScopeTests.java | 2 +- .../parsing/CustomProblemReporterTests.java | 2 +- .../support/BeanDefinitionBuilderTests.java | 2 +- .../factory/support/BeanDefinitionTests.java | 2 +- .../support/BeanFactoryGenericsTests.java | 8 +- .../DefaultSingletonBeanRegistryTests.java | 4 +- ...DefinitionMetadataEqualsHashCodeTests.java | 2 +- .../factory/support/LookupMethodTests.java | 2 +- .../PropertiesBeanDefinitionReaderTests.java | 2 +- .../wiring/BeanConfigurerSupportTests.java | 2 +- .../xml/AutowireWithExclusionTests.java | 2 +- .../factory/xml/CollectionMergingTests.java | 2 +- .../xml/CollectionsWithDefaultTypesTests.java | 2 +- .../xml/ConstructorDependenciesBean.java | 4 +- .../beans/factory/xml/CountingFactory.java | 2 +- .../beans/factory/xml/DummyReferencer.java | 4 +- .../factory/xml/DuplicateBeanIdTests.java | 2 +- .../factory/xml/EventPublicationTests.java | 2 +- .../beans/factory/xml/FactoryMethodTests.java | 2 +- .../beans/factory/xml/FactoryMethods.java | 2 +- .../beans/factory/xml/InstanceFactory.java | 2 +- ...edBeansElementAttributeRecursionTests.java | 2 +- .../factory/xml/SchemaValidationTests.java | 2 +- ...impleConstructorNamespaceHandlerTests.java | 4 +- .../SimplePropertyNamespaceHandlerTests.java | 4 +- .../beans/factory/xml/TestBeanCreator.java | 2 +- .../xml/UtilNamespaceHandlerTests.java | 6 +- .../factory/xml/XmlBeanCollectionTests.java | 4 +- .../xml/XmlBeanDefinitionReaderTests.java | 2 +- .../xml/XmlListableBeanFactoryTests.java | 10 +-- .../propertyeditors/CustomEditorTests.java | 14 ++-- .../beans/support/PagedListHolderTests.java | 2 +- .../annotation/KotlinAutowiredTests.kt | 4 +- .../factory/BeanFactoryUtilsTests-leaf.xml | 2 +- .../factory/BeanFactoryUtilsTests-middle.xml | 4 +- .../factory/BeanFactoryUtilsTests-root.xml | 12 +-- ...ieldRetrievingFactoryBeanTests-context.xml | 2 +- .../PropertyPathFactoryBeanTests-context.xml | 18 ++--- .../config/SimpleScopeTests-context.xml | 2 +- .../CustomProblemReporterTests-context.xml | 8 +- .../factory/support/genericBeanTests.xml | 6 +- .../factory/support/lookupMethodTests.xml | 4 +- .../support/multiConstructorArgs.properties | 2 +- .../support/refConstructorArg.properties | 4 +- .../support/simpleConstructorArg.properties | 2 +- ...uplicateBeanIdTests-multiLevel-context.xml | 4 +- ...DuplicateBeanIdTests-sameLevel-context.xml | 4 +- ...tAttributeRecursionTests-merge-context.xml | 2 +- .../autowire-constructor-with-exclusion.xml | 4 +- .../factory/xml/autowire-with-exclusion.xml | 4 +- .../factory/xml/autowire-with-inclusion.xml | 4 +- .../xml/autowire-with-selective-inclusion.xml | 4 +- .../beans/factory/xml/beanEvents.xml | 8 +- .../beans/factory/xml/collectionMerging.xml | 28 +++---- .../beans/factory/xml/collections.xml | 54 ++++++------- .../xml/collectionsWithDefaultTypes.xml | 4 +- .../beans/factory/xml/factory-methods.xml | 4 +- .../beans/factory/xml/schemaValidated.xml | 10 +-- ...simpleConstructorNamespaceHandlerTests.xml | 22 ++--- ...tructorNamespaceHandlerTestsWithErrors.xml | 2 +- .../simplePropertyNamespaceHandlerTests.xml | 10 +-- ...ropertyNamespaceHandlerTestsWithErrors.xml | 4 +- .../beans/factory/xml/test.xml | 32 ++++---- .../beans/factory/xml/testUtilNamespace.xml | 20 ++--- .../beans/factory/xml/validateWithDtd.xml | 2 +- .../beans/factory/xml/validateWithXsd.xml | 2 +- .../beans/factory/xml/withMeta.xml | 6 +- .../beans/AgeHolder.java | 2 +- .../beans/AnnotatedBean.java | 2 +- .../beans/BooleanTestBean.java | 2 +- .../beans/CollectingReaderEventListener.java | 2 +- .../beans/Colour.java | 2 +- .../beans/CountingTestBean.java | 2 +- .../beans/CustomEnum.java | 2 +- .../beans/DependenciesBean.java | 2 +- .../beans/DerivedTestBean.java | 2 +- .../beans/DummyBean.java | 2 +- .../beans/DummyFactory.java | 2 +- .../beans/Employee.java | 2 +- .../beans/GenericBean.java | 2 +- .../beans/GenericIntegerBean.java | 2 +- .../beans/GenericSetOfIntegerBean.java | 2 +- .../beans/HasMap.java | 2 +- .../beans/INestedTestBean.java | 2 +- .../beans/IOther.java | 2 +- .../beans/ITestBean.java | 4 +- .../beans/IndexedTestBean.java | 2 +- .../beans/LifecycleBean.java | 2 +- .../beans/MustBeInitialized.java | 2 +- .../beans/NestedTestBean.java | 2 +- .../beans/NumberTestBean.java | 2 +- .../beans/PackageLevelVisibleBean.java | 2 +- .../beans/Person.java | 2 +- .../fixtures => testfixture}/beans/Pet.java | 2 +- .../beans/SerializablePerson.java | 2 +- .../beans/SideEffectBean.java | 2 +- .../beans/TestAnnotation.java | 2 +- .../beans/TestBean.java | 8 +- .../beans/factory/DummyFactory.java | 4 +- .../beans/package-info.java | 2 +- .../beans/subpkg/DeepBean.java | 2 +- .../factory/xml/AbstractBeanFactoryTests.java | 10 +-- .../xml/AbstractListableBeanFactoryTests.java | 8 +- .../scheduling/quartz/QuartzSupportTests.java | 2 +- .../BeanValidationPostProcessorTests.java | 2 +- .../aop/aspectj/AfterAdviceBindingTests.java | 4 +- .../AfterReturningAdviceBindingTests.java | 4 +- .../AfterThrowingAdviceBindingTests.java | 2 +- .../aop/aspectj/AroundAdviceBindingTests.java | 4 +- .../AspectAndAdvicePrecedenceTests.java | 2 +- ...AspectJExpressionPointcutAdvisorTests.java | 2 +- .../BeanNamePointcutAtAspectTests.java | 4 +- .../aop/aspectj/BeanNamePointcutTests.java | 2 +- .../aop/aspectj/BeforeAdviceBindingTests.java | 4 +- .../aop/aspectj/DeclareParentsTests.java | 2 +- ...licitJPArgumentMatchingAtAspectJTests.java | 4 +- .../AspectImplementingInterfaceTests.java | 2 +- ...xyCreatorAndLazyInitTargetSourceTests.java | 4 +- .../AspectJAutoProxyCreatorTests.java | 8 +- .../AtAspectJAfterThrowingTests.java | 4 +- .../autoproxy/benchmark/BenchmarkTests.java | 2 +- ...fterReturningGenericTypeMatchingTests.java | 4 +- ...NamespaceHandlerProxyTargetClassTests.java | 2 +- .../aop/config/AopNamespaceHandlerTests.java | 4 +- .../aop/framework/AbstractAopProxyTests.java | 10 +-- .../aop/framework/CglibProxyTests.java | 4 +- .../aop/framework/JdkDynamicProxyTests.java | 6 +- .../aop/framework/ProxyFactoryBeanTests.java | 8 +- .../AdvisorAdapterRegistrationTests.java | 2 +- .../AdvisorAutoProxyCreatorTests.java | 4 +- .../autoproxy/AutoProxyCreatorTests.java | 8 +- .../BeanNameAutoProxyCreatorInitTests.java | 2 +- .../BeanNameAutoProxyCreatorTests.java | 4 +- .../aop/scope/ScopedProxyTests.java | 4 +- .../target/CommonsPool2TargetSourceTests.java | 6 +- .../LookupMethodWrappedByCglibProxyTests.java | 2 +- ...aceHandlerWithExpressionLanguageTests.java | 2 +- .../factory/xml/XmlBeanFactoryTestTypes.java | 8 +- .../factory/xml/XmlBeanFactoryTests.java | 12 +-- .../support/CustomNamespaceHandlerTests.java | 4 +- .../cache/CacheReproTests.java | 2 +- .../context/LifecycleContextBean.java | 2 +- .../AbstractCircularImportDetectionTests.java | 2 +- .../AnnotationProcessorPerformanceTests.java | 4 +- .../ClassPathBeanDefinitionScannerTests.java | 2 +- ...PathFactoryBeanDefinitionScannerTests.java | 2 +- ...ommonAnnotationBeanPostProcessorTests.java | 8 +- .../ConfigurationClassAndBFPPTests.java | 2 +- ...nClassPostConstructAndAutowiringTests.java | 2 +- .../ConfigurationClassPostProcessorTests.java | 4 +- .../FooServiceDependentConverter.java | 6 +- ...wiredAnnotationBeanPostProcessorTests.java | 2 +- .../context/annotation/MyTestBean.java | 4 +- .../NestedConfigurationClassTests.java | 2 +- .../PropertySourceAnnotationTests.java | 2 +- .../componentscan/level1/Level1Config.java | 2 +- .../componentscan/level2/Level2Config.java | 2 +- .../AutowiredConfigurationTests.java | 4 +- .../BeanMethodQualificationTests.java | 4 +- ...figurationClassAspectIntegrationTests.java | 6 +- .../ConfigurationClassProcessingTests.java | 6 +- ...assWithPlaceholderConfigurerBeanTests.java | 4 +- .../ConfigurationMetaAnnotationTests.java | 2 +- .../ImportAnnotationDetectionTests.java | 2 +- .../configuration/ImportResourceTests.java | 4 +- .../annotation/configuration/ImportTests.java | 4 +- ...tedConfigurationClassEnhancementTests.java | 2 +- .../configuration/ScopingTests.java | 4 +- .../annotation4/FactoryMethodComponent.java | 2 +- .../context/annotation4/SimpleBean.java | 2 +- .../annotation6/ConfigForScanning.java | 2 +- .../event/ApplicationContextEventTests.java | 2 +- .../EventPublicationInterceptorTests.java | 4 +- .../ApplicationContextExpressionTests.java | 2 +- .../EnvironmentAccessorIntegrationTests.java | 2 +- .../BeanFactoryPostProcessorTests.java | 2 +- ...rtyResourceConfigurerIntegrationTests.java | 2 +- ...ertySourcesPlaceholderConfigurerTests.java | 2 +- .../support/SimpleThreadScopeTests.java | 2 +- ...ticApplicationContextMulticasterTests.java | 2 +- .../StaticApplicationContextTests.java | 2 +- .../support/StaticMessageSourceTests.java | 4 +- .../config/JeeNamespaceHandlerEventTests.java | 2 +- .../ejb/config/JeeNamespaceHandlerTests.java | 4 +- .../jmx/export/MBeanExporterTests.java | 2 +- .../jndi/JndiObjectFactoryBeanTests.java | 8 +- .../scripting/ContextScriptBean.java | 2 +- .../scripting/TestBeanAwareMessenger.java | 2 +- .../scripting/bsh/BshScriptFactoryTests.java | 2 +- .../groovy/GroovyScriptFactoryTests.java | 2 +- .../tests/sample/beans/FieldAccessBean.java | 2 +- .../org/springframework/ui/ModelMapTests.java | 2 +- .../DataBinderFieldAccessTests.java | 2 +- .../validation/DataBinderTests.java | 26 +++--- .../DefaultMessageCodesResolverTests.java | 14 ++-- .../validation/ValidationUtilsTests.java | 2 +- .../BeanValidationPostProcessorTests.java | 2 +- .../java/test/aspect/TwoAdviceAspect.java | 4 +- .../aop/aspectj/AfterAdviceBindingTests.xml | 2 +- .../AfterReturningAdviceBindingTests.xml | 4 +- .../AfterThrowingAdviceBindingTests.xml | 2 +- .../aop/aspectj/AroundAdviceBindingTests.xml | 2 +- .../aop/aspectj/AroundAdviceCircularTests.xml | 4 +- .../AspectAndAdvicePrecedenceTests.xml | 2 +- .../AspectJExpressionPointcutAdvisorTests.xml | 4 +- .../aspectj/BeanNamePointcutAtAspectTests.xml | 6 +- .../aop/aspectj/BeanNamePointcutTests.xml | 12 +-- .../aop/aspectj/BeforeAdviceBindingTests.xml | 2 +- .../aop/aspectj/DeclareParentsTests.xml | 4 +- ...plicitJPArgumentMatchingAtAspectJTests.xml | 2 +- .../ImplicitJPArgumentMatchingTests.xml | 4 +- .../OverloadedAdviceTests-ambiguous.xml | 2 +- .../aop/aspectj/OverloadedAdviceTests.xml | 2 +- ...pectImplementingInterfaceTests-context.xml | 2 +- .../AspectJAutoProxyCreatorTests-aspects.xml | 4 +- ...toProxyCreatorTests-aspectsPlusAdvisor.xml | 6 +- ...xyCreatorTests-aspectsWithAbstractBean.xml | 2 +- ...oProxyCreatorTests-aspectsWithOrdering.xml | 2 +- ...AspectJAutoProxyCreatorTests-pertarget.xml | 4 +- .../AspectJAutoProxyCreatorTests-perthis.xml | 2 +- ...JAutoProxyCreatorTests-twoAdviceAspect.xml | 2 +- ...yCreatorTests-twoAdviceAspectPrototype.xml | 2 +- ...yCreatorTests-twoAdviceAspectSingleton.xml | 2 +- ...pectJAutoProxyCreatorTests-usesInclude.xml | 2 +- ...oProxyCreatorTests-usesJoinPointAspect.xml | 2 +- .../AtAspectJAfterThrowingTests-context.xml | 2 +- .../benchmark/BenchmarkTests-aspectj.xml | 2 +- .../benchmark/BenchmarkTests-springAop.xml | 2 +- ...pNamespaceHandlerAdviceTypeTests-error.xml | 2 +- .../AopNamespaceHandlerAdviceTypeTests-ok.xml | 2 +- ...AopNamespaceHandlerArgNamesTests-error.xml | 2 +- .../AopNamespaceHandlerArgNamesTests-ok.xml | 2 +- ...ceHandlerProxyTargetClassTests-context.xml | 2 +- ...opNamespaceHandlerReturningTests-error.xml | 2 +- .../AopNamespaceHandlerReturningTests-ok.xml | 2 +- .../AopNamespaceHandlerTests-context.xml | 2 +- ...AopNamespaceHandlerThrowingTests-error.xml | 2 +- .../AopNamespaceHandlerThrowingTests-ok.xml | 2 +- .../config/PrototypeProxyTests-context.xml | 8 +- .../ProxyFactoryBeanTests-autowiring.xml | 2 +- .../ProxyFactoryBeanTests-context.xml | 26 +++--- ...xyFactoryBeanTests-double-targetsource.xml | 8 +- .../ProxyFactoryBeanTests-frozen.xml | 4 +- ...roxyFactoryBeanTests-inner-bean-target.xml | 2 +- .../ProxyFactoryBeanTests-invalid.xml | 4 +- ...yFactoryBeanTests-notlast-targetsource.xml | 4 +- .../ProxyFactoryBeanTests-prototype.xml | 4 +- .../ProxyFactoryBeanTests-serialization.xml | 10 +-- .../ProxyFactoryBeanTests-targetsource.xml | 4 +- ...visorAdapterRegistrationTests-with-bpp.xml | 4 +- ...orAdapterRegistrationTests-without-bpp.xml | 4 +- ...oProxyCreatorTests-common-interceptors.xml | 4 +- ...oProxyCreatorTests-custom-targetsource.xml | 8 +- ...AdvisorAutoProxyCreatorTests-optimized.xml | 2 +- ...toProxyCreatorTests-quick-targetsource.xml | 10 +-- ...nNameAutoProxyCreatorInitTests-context.xml | 2 +- .../BeanNameAutoProxyCreatorTests-context.xml | 16 ++-- .../aop/scope/ScopedProxyTests-list.xml | 2 +- .../aop/scope/ScopedProxyTests-override.xml | 2 +- .../aop/scope/ScopedProxyTests-testbean.xml | 2 +- .../CommonsPool2TargetSourceTests-context.xml | 4 +- ...MethodWrappedByCglibProxyTests-context.xml | 2 +- .../xml/XmlBeanFactoryTests-autowire.xml | 12 +-- .../factory/xml/XmlBeanFactoryTests-child.xml | 6 +- .../xml/XmlBeanFactoryTests-collections.xml | 46 +++++------ ...lBeanFactoryTests-complexFactoryCircle.xml | 8 +- .../XmlBeanFactoryTests-constructorArg.xml | 12 +-- ...lBeanFactoryTests-constructorOverrides.xml | 2 +- .../XmlBeanFactoryTests-defaultAutowire.xml | 8 +- .../XmlBeanFactoryTests-defaultLazyInit.xml | 2 +- ...mlBeanFactoryTests-delegationOverrides.xml | 4 +- .../xml/XmlBeanFactoryTests-factoryCircle.xml | 2 +- .../xml/XmlBeanFactoryTests-initializers.xml | 2 +- .../xml/XmlBeanFactoryTests-invalid.xml | 2 +- ...toryTests-invalidOverridesNoSuchMethod.xml | 2 +- ...nFactoryTests-localCollectionsUsingXsd.xml | 2 +- .../xml/XmlBeanFactoryTests-overrides.xml | 16 ++-- .../xml/XmlBeanFactoryTests-parent.xml | 6 +- .../xml/XmlBeanFactoryTests-reftypes.xml | 80 +++++++++---------- ...toryTests-testWithDuplicateNameInAlias.xml | 4 +- ...eanFactoryTests-testWithDuplicateNames.xml | 4 +- ...paceHandlerWithExpressionLanguageTests.xml | 4 +- .../CustomNamespaceHandlerTests-context.xml | 8 +- ...ndiBeanFactoryLocatorTests-collections.xml | 46 +++++------ ...textJndiBeanFactoryLocatorTests-parent.xml | 6 +- ...ortNonXmlResourceConfig-context.properties | 2 +- .../configuration/ImportXmlConfig-context.xml | 2 +- .../ImportXmlWithAopNamespace-context.xml | 2 +- .../support/simpleThreadScopeTests.xml | 18 ++--- .../context/support/testBeans.properties | 20 ++--- .../ejb/config/jeeNamespaceHandlerTests.xml | 14 ++-- .../scripting/bsh/MessengerImpl.bsh | 2 +- .../scripting/bsh/bsh-with-xsd.xml | 2 +- .../scripting/groovy/ScriptBean.groovy | 2 +- .../groovy/groovy-multiple-properties.xml | 2 +- .../AbstractApplicationContextTests.java | 6 +- .../jdbc/core/RowMapperTests.java | 2 +- .../BeanPropertySqlParameterSourceTests.java | 2 +- .../JdbcBeanDefinitionReaderTests.java | 4 +- .../jms/config/JmsNamespaceHandlerTests.java | 2 +- .../jms/remoting/JmsInvokerTests.java | 4 +- .../jms/config/jmsNamespaceHandlerTests.xml | 4 +- .../orm/jpa/domain/Person.java | 2 +- .../orm/jpa/domain/persistence-multi.xml | 2 +- ...dingPropertiesAndInheritedLoaderTests.java | 2 +- ...ithPropertiesExtendingPropertiesTests.java | 2 +- .../ActiveProfilesInterfaceTests.java | 2 +- .../ContextConfigurationInterfaceTests.java | 2 +- .../ContextConfigurationTestInterface.java | 2 +- ...riptDetectionGroovySpringContextTests.java | 4 +- .../groovy/GroovyControlGroupTests.java | 4 +- .../groovy/GroovySpringContextTests.java | 4 +- .../MixedXmlAndGroovySpringContextTests.java | 4 +- ...TransactionalJUnit4SpringContextTests.java | 4 +- ...ltContextLoaderClassSpringRunnerTests.java | 2 +- ...ParameterizedDependencyInjectionTests.java | 4 +- ...sedSpringJUnit4ClassRunnerAppCtxTests.java | 2 +- .../SpringJUnit4ClassRunnerAppCtxTests.java | 4 +- ...ingDefaultConfigClassesInheritedTests.java | 2 +- .../DefaultConfigClassesBaseTests.java | 2 +- .../DefaultConfigClassesInheritedTests.java | 2 +- ...ingDefaultConfigClassesInheritedTests.java | 2 +- ...ltLoaderDefaultConfigClassesBaseTests.java | 2 +- ...derDefaultConfigClassesInheritedTests.java | 2 +- ...tLoaderExplicitConfigClassesBaseTests.java | 2 +- ...erExplicitConfigClassesInheritedTests.java | 2 +- .../ExplicitConfigClassesBaseTests.java | 2 +- .../ExplicitConfigClassesInheritedTests.java | 2 +- .../annotation/PojoAndStringConfig.java | 4 +- ...mDefaultsMetaConfigWithOverridesTests.java | 4 +- .../DefaultProfileAnnotationConfigTests.java | 4 +- .../annotation/DefaultProfileConfig.java | 2 +- .../profile/annotation/DevProfileConfig.java | 2 +- .../DefaultProfileAnnotationConfigTests.java | 4 +- .../importresource/DefaultProfileConfig.java | 2 +- .../xml/DefaultProfileXmlConfigTests.java | 4 +- .../rules/ParameterizedSpringRuleTests.java | 4 +- .../spr3896/DefaultLocationsBaseTests.java | 2 +- .../DefaultLocationsInheritedTests.java | 2 +- .../spr3896/ExplicitLocationsBaseTests.java | 2 +- .../ExplicitLocationsInheritedTests.java | 2 +- ...ransactionalAnnotatedConfigClassTests.java | 2 +- ...edConfigClassWithAtConfigurationTests.java | 2 +- ...figClassesWithoutAtConfigurationTests.java | 2 +- ...otationConfigTestNGSpringContextTests.java | 4 +- ...TransactionalTestNGSpringContextTests.java | 4 +- ...TransactionalTestNGSpringContextTests.java | 4 +- .../RequestAndSessionScopedBeansWacTests.java | 2 +- ...AndInheritedLoaderTests-context.properties | 2 +- ...xtendingPropertiesTests-context.properties | 2 +- ...tionGroovySpringContextTestsContext.groovy | 4 +- .../test/context/groovy/context.groovy | 4 +- .../test/context/groovy/contextB.xml | 4 +- ...tionalJUnit4SpringContextTests-context.xml | 4 +- ...gJUnit4ClassRunnerAppCtxTests-context1.xml | 2 +- ...gJUnit4ClassRunnerAppCtxTests-context2.xml | 2 +- ...erizedDependencyInjectionTests-context.xml | 6 +- ...4ClassRunnerAppCtxTests-context.properties | 2 +- ...ngJUnit4ClassRunnerAppCtxTests-context.xml | 4 +- .../junit4/profile/importresource/import.xml | 2 +- .../DefaultProfileXmlConfigTests-context.xml | 4 +- ...DefaultLocationsInheritedTests-context.xml | 2 +- .../DefaultLocationsBaseTests-context.xml | 2 +- ...DefaultLocationsInheritedTests-context.xml | 2 +- ...tionalTestNGSpringContextTests-context.xml | 4 +- ...tAndSessionScopedBeansWacTests-context.xml | 4 +- .../TxNamespaceHandlerEventTests.java | 2 +- .../transaction/TxNamespaceHandlerTests.java | 2 +- .../AbstractTransactionAspectTests.java | 4 +- .../BeanFactoryTransactionTests.java | 6 +- .../interceptor/ImplementsNoInterfaces.java | 2 +- .../support/SimpleTransactionScopeTests.java | 4 +- .../noTransactionAttributeSource.xml | 2 +- .../interceptor/transactionalBeanFactory.xml | 12 +-- .../transaction/txNamespaceHandlerTests.xml | 2 +- .../remoting/caucho/CauchoRemotingTests.java | 4 +- .../httpinvoker/HttpInvokerTests.java | 4 +- .../web/bind/EscapedErrorsTests.java | 2 +- .../bind/ServletRequestDataBinderTests.java | 4 +- .../support/WebExchangeDataBinderTests.java | 4 +- .../support/WebRequestDataBinderTests.java | 4 +- .../RequestAndSessionScopedBeanTests.java | 2 +- .../context/request/RequestScopeTests.java | 4 +- .../request/RequestScopedProxyTests.java | 8 +- .../context/request/SessionScopeTests.java | 4 +- .../WebApplicationContextScopeTests.java | 2 +- .../SpringBeanAutowiringSupportTests.java | 4 +- .../ModelAttributeMethodProcessorTests.java | 2 +- .../SessionAttributesHandlerTests.java | 2 +- .../web/context/request/requestScopeTests.xml | 18 ++--- .../request/requestScopedProxyTests.xml | 20 ++--- .../web/context/request/sessionScopeTests.xml | 4 +- .../SessionAttributesHandlerTests.java | 2 +- .../result/view/AbstractViewTests.java | 2 +- .../view/freemarker/FreeMarkerMacroTests.java | 2 +- .../context/LifecycleContextBean.java | 2 +- .../web/context/ContextLoaderTests.java | 4 +- .../XmlWebApplicationContextTests.java | 2 +- .../support/ServletContextSupportTests.java | 2 +- .../web/servlet/DispatcherServletTests.java | 2 +- ...MvcConfigurationSupportExtensionTests.java | 2 +- .../ResponseStatusExceptionResolverTests.java | 2 +- ...ExtendedServletRequestDataBinderTests.java | 2 +- ...ResolverMethodReturnValueHandlerTests.java | 2 +- ...MappingHandlerAdapterIntegrationTests.java | 2 +- ...nnotationControllerHandlerMethodTests.java | 10 +-- ...letModelAttributeMethodProcessorTests.java | 2 +- .../DefaultHandlerExceptionResolverTests.java | 2 +- .../RedirectAttributesModelMapTests.java | 2 +- .../web/servlet/tags/BindTagTests.java | 6 +- .../tags/form/AbstractFormTagTests.java | 2 +- .../web/servlet/tags/form/ButtonTagTests.java | 2 +- .../servlet/tags/form/CheckboxTagTests.java | 6 +- .../servlet/tags/form/CheckboxesTagTests.java | 6 +- .../web/servlet/tags/form/ErrorsTagTests.java | 2 +- .../tags/form/HiddenInputTagTests.java | 2 +- .../web/servlet/tags/form/InputTagTests.java | 2 +- .../web/servlet/tags/form/LabelTagTests.java | 2 +- .../servlet/tags/form/OptionTagEnumTests.java | 4 +- .../web/servlet/tags/form/OptionTagTests.java | 4 +- .../servlet/tags/form/OptionsTagTests.java | 2 +- .../tags/form/RadioButtonTagTests.java | 4 +- .../tags/form/RadioButtonsTagTests.java | 6 +- .../web/servlet/tags/form/SelectTagTests.java | 4 +- .../tags/form/TestBeanWithRealCountry.java | 2 +- .../servlet/tags/form/TextareaTagTests.java | 2 +- .../web/servlet/view/RedirectViewTests.java | 2 +- .../web/servlet/view/ViewResolverTests.java | 2 +- .../view/freemarker/FreeMarkerMacroTests.java | 2 +- .../ContextLoaderTests-acc-context.xml | 2 +- .../context/WEB-INF/applicationContext.xml | 6 +- .../web/context/WEB-INF/context-addition.xml | 14 ++-- .../web/context/WEB-INF/contextInclude.xml | 2 +- .../web/context/WEB-INF/sessionContext.xml | 4 +- .../web/context/WEB-INF/test-servlet.xml | 16 ++-- .../web/context/WEB-INF/testNamespace.xml | 4 +- 503 files changed, 1148 insertions(+), 1142 deletions(-) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/AgeHolder.java (93%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/AnnotatedBean.java (92%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/BooleanTestBean.java (94%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/CollectingReaderEventListener.java (98%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/Colour.java (95%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/CountingTestBean.java (93%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/CustomEnum.java (93%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/DependenciesBean.java (96%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/DerivedTestBean.java (97%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/DummyBean.java (96%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/DummyFactory.java (98%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/Employee.java (94%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/GenericBean.java (99%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/GenericIntegerBean.java (92%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/GenericSetOfIntegerBean.java (93%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/HasMap.java (97%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/INestedTestBean.java (92%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/IOther.java (92%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/ITestBean.java (92%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/IndexedTestBean.java (98%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/LifecycleBean.java (98%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/MustBeInitialized.java (96%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/NestedTestBean.java (96%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/NumberTestBean.java (97%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/PackageLevelVisibleBean.java (93%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/Person.java (94%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/Pet.java (95%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/SerializablePerson.java (96%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/SideEffectBean.java (94%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/TestAnnotation.java (93%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/TestBean.java (96%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/factory/DummyFactory.java (97%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/package-info.java (55%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/beans/subpkg/DeepBean.java (93%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/factory/xml/AbstractBeanFactoryTests.java (96%) rename spring-beans/src/testFixtures/java/org/springframework/beans/{test/fixtures => testfixture}/factory/xml/AbstractListableBeanFactoryTests.java (90%) diff --git a/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java b/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java index b20012250c72..32ac556fe482 100644 --- a/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java @@ -21,8 +21,8 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpSession; diff --git a/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java b/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java index e7060f909837..987c643a65cd 100644 --- a/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java @@ -28,7 +28,7 @@ import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.lang.Nullable; import org.springframework.tests.aop.advice.CountingBeforeAdvice; diff --git a/integration-tests/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml b/integration-tests/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml index ccbe045e9a5e..ab891535b514 100644 --- a/integration-tests/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml +++ b/integration-tests/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml @@ -11,19 +11,19 @@ - + - + - + - + diff --git a/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml b/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml index 4e7280580da2..ab6309ff35be 100644 --- a/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml +++ b/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml @@ -74,20 +74,20 @@ - + - + - org.springframework.beans.test.fixtures.beans.ITestBean.getName + org.springframework.beans.testfixture.beans.ITestBean.getName - + 4 @@ -97,7 +97,7 @@ - + diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java index 3e9603edc187..008df78e64d9 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java @@ -31,10 +31,10 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.support.DefaultPointcutAdvisor; -import org.springframework.beans.test.fixtures.beans.IOther; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.beans.subpkg.DeepBean; +import org.springframework.beans.testfixture.beans.IOther; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.beans.subpkg.DeepBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -67,7 +67,7 @@ public void setUp() throws NoSuchMethodException { @Test public void testMatchExplicit() { - String expression = "execution(int org.springframework.beans.test.fixtures.beans.TestBean.getAge())"; + String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())"; Pointcut pointcut = getPointcut(expression); ClassFilter classFilter = pointcut.getClassFilter(); @@ -117,8 +117,8 @@ public void testTarget() throws SecurityException, NoSuchMethodException { * @param which this or target */ private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException { - String matchesTestBean = which + "(org.springframework.beans.test.fixtures.beans.TestBean)"; - String matchesIOther = which + "(org.springframework.beans.test.fixtures.beans.IOther)"; + String matchesTestBean = which + "(org.springframework.beans.testfixture.beans.TestBean)"; + String matchesIOther = which + "(org.springframework.beans.testfixture.beans.IOther)"; AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut(); testBeanPc.setExpression(matchesTestBean); @@ -142,7 +142,7 @@ public void testWithinRootAndSubpackages() throws SecurityException, NoSuchMetho } private void testWithinPackage(boolean matchSubpackages) throws SecurityException, NoSuchMethodException { - String withinBeansPackage = "within(org.springframework.beans.test.fixtures.beans."; + String withinBeansPackage = "within(org.springframework.beans.testfixture.beans."; // Subpackages are matched by ** if (matchSubpackages) { withinBeansPackage += "."; @@ -187,7 +187,7 @@ public void testFriendlyErrorOnNoLocation3ArgMatching() { @Test public void testMatchWithArgs() throws Exception { - String expression = "execution(void org.springframework.beans.test.fixtures.beans.TestBean.setSomeNumber(Number)) && args(Double)"; + String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)"; Pointcut pointcut = getPointcut(expression); ClassFilter classFilter = pointcut.getClassFilter(); @@ -206,7 +206,7 @@ public void testMatchWithArgs() throws Exception { @Test public void testSimpleAdvice() { - String expression = "execution(int org.springframework.beans.test.fixtures.beans.TestBean.getAge())"; + String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())"; CallCountingInterceptor interceptor = new CallCountingInterceptor(); TestBean testBean = getAdvisedProxy(expression, interceptor); @@ -219,7 +219,7 @@ public void testSimpleAdvice() { @Test public void testDynamicMatchingProxy() { - String expression = "execution(void org.springframework.beans.test.fixtures.beans.TestBean.setSomeNumber(Number)) && args(Double)"; + String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)"; CallCountingInterceptor interceptor = new CallCountingInterceptor(); TestBean testBean = getAdvisedProxy(expression, interceptor); @@ -233,7 +233,7 @@ public void testDynamicMatchingProxy() { @Test public void testInvalidExpression() { - String expression = "execution(void org.springframework.beans.test.fixtures.beans.TestBean.setSomeNumber(Number) && args(Double)"; + String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number) && args(Double)"; assertThatIllegalArgumentException().isThrownBy( getPointcut(expression)::getClassFilter); // call to getClassFilter forces resolution } @@ -264,7 +264,7 @@ private void assertMatchesTestBeanClass(ClassFilter classFilter) { @Test public void testWithUnsupportedPointcutPrimitive() { - String expression = "call(int org.springframework.beans.test.fixtures.beans.TestBean.getAge())"; + String expression = "call(int org.springframework.beans.testfixture.beans.TestBean.getAge())"; assertThatExceptionOfType(UnsupportedPointcutPrimitiveException.class).isThrownBy(() -> getPointcut(expression).getClassFilter()) // call to getClassFilter forces resolution... .satisfies(ex -> assertThat(ex.getUnsupportedPrimitive()).isEqualTo(PointcutPrimitive.CALL)); diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java index f64fbdaf301b..3fd1b1e0c844 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java index 157c85f0e646..4591b74624aa 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java @@ -33,8 +33,8 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java index 6a87160981fd..23d63fb1bea0 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java @@ -27,7 +27,7 @@ import test.annotation.transaction.Tx; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; @@ -56,7 +56,7 @@ public void setup() throws NoSuchMethodException { @Test public void testMatchGenericArgument() { - String expression = "execution(* set*(java.util.List) )"; + String expression = "execution(* set*(java.util.List) )"; AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); ajexp.setExpression(expression); diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java index c95710517425..43373063622c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java @@ -20,11 +20,11 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.CountingTestBean; -import org.springframework.beans.test.fixtures.beans.IOther; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.beans.subpkg.DeepBean; +import org.springframework.beans.testfixture.beans.CountingTestBean; +import org.springframework.beans.testfixture.beans.IOther; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.beans.subpkg.DeepBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -57,7 +57,7 @@ void invocationOfMatchesMethodBlowsUpWhenNoTypePatternHasBeenSet() throws Except @Test void validPatternMatching() { - TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); + TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*"); assertThat(tpcf.matches(TestBean.class)).as("Must match: in package").isTrue(); assertThat(tpcf.matches(ITestBean.class)).as("Must match: in package").isTrue(); @@ -70,7 +70,7 @@ void validPatternMatching() { @Test void subclassMatching() { - TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.ITestBean+"); + TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.ITestBean+"); assertThat(tpcf.matches(TestBean.class)).as("Must match: in package").isTrue(); assertThat(tpcf.matches(ITestBean.class)).as("Must match: in package").isTrue(); @@ -98,8 +98,8 @@ void andOrNotReplacement() { @Test void testEquals() { - TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); - TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); + TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*"); + TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*"); TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*"); assertThat(filter1).isEqualTo(filter2); @@ -108,8 +108,8 @@ void testEquals() { @Test void testHashCode() { - TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); - TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); + TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*"); + TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*"); TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*"); assertThat(filter1.hashCode()).isEqualTo(filter2.hashCode()); @@ -118,11 +118,11 @@ void testHashCode() { @Test void testToString() { - TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); - TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*"); + TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*"); + TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*"); assertThat(filter1.toString()) - .isEqualTo("org.springframework.aop.aspectj.TypePatternClassFilter: org.springframework.beans.test.fixtures.beans.*"); + .isEqualTo("org.springframework.aop.aspectj.TypePatternClassFilter: org.springframework.beans.testfixture.beans.*"); assertThat(filter1.toString()).isEqualTo(filter2.toString()); } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java index c71218f6384c..88bfdfb30b94 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java @@ -50,8 +50,8 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.OrderComparator; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; @@ -590,7 +590,7 @@ public void countSetter() { } - @Aspect("pertypewithin(org.springframework.beans.test.fixtures.beans.IOther+)") + @Aspect("pertypewithin(org.springframework.beans.testfixture.beans.IOther+)") public static class PerTypeWithinAspect { public int count; @@ -931,7 +931,7 @@ private Method getGetterFromSetter(Method setter) { @Aspect class MakeITestBeanModifiable extends AbstractMakeModifiable { - @DeclareParents(value = "org.springframework.beans.test.fixtures.beans.ITestBean+", + @DeclareParents(value = "org.springframework.beans.testfixture.beans.ITestBean+", defaultImpl=ModifiableImpl.class) public static MutableModifiable mixin; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java index 432dfef3757a..835f4a4f95c3 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java @@ -27,8 +27,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java index 02345f252298..b944da483e0b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java @@ -23,7 +23,7 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcut; import org.springframework.aop.aspectj.AspectJExpressionPointcutTests; import org.springframework.aop.framework.AopConfigException; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java index c8188315f7e3..a6ecf37304de 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java @@ -29,7 +29,7 @@ import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlReaderContext; -import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; +import org.springframework.beans.testfixture.beans.CollectingReaderEventListener; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java index c9d752c1699e..d4c774424d04 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java @@ -29,7 +29,7 @@ import org.springframework.beans.factory.parsing.CompositeComponentDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; +import org.springframework.beans.testfixture.beans.CollectingReaderEventListener; import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java index eaa9e7ff524c..c8475794f337 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java @@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.SpringProxy; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java index 98493976ca4f..d3defccfb429 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java @@ -19,8 +19,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.support.DelegatingIntroductionInterceptor; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.util.StopWatch; /** diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java index dbbaaf60af93..91091035aac7 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java @@ -23,7 +23,7 @@ import org.aopalliance.intercept.MethodInterceptor; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java index 39b93fe473c6..033824508e26 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java @@ -34,9 +34,9 @@ import org.springframework.aop.support.DefaultIntroductionAdvisor; import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.aop.support.DelegatingIntroductionInterceptor; -import org.springframework.beans.test.fixtures.beans.IOther; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.IOther; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.Order; import org.springframework.core.testfixture.TimeStamped; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java index f06491d000b3..43e4a93ded88 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java @@ -22,9 +22,9 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java index 2fb5200e4b4c..9bd43d1aef3f 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java @@ -20,8 +20,8 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.NamedBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java index e9f6a3f0cb83..40f266f64710 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java @@ -21,8 +21,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java index 880757dcbf9c..aa8cd95dc9aa 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java index cf1e22c356bb..eeeedd8efb96 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java @@ -25,7 +25,7 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.target.EmptyTargetSource; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.tests.aop.interceptor.NopInterceptor; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java index de4fecfecc27..db83a9424df1 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java @@ -19,8 +19,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.ClassFilter; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.NestedRuntimeException; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java index 5e07be7dd192..6eac64eb77b8 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.util.ClassUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java index 769db77bf047..87b408222c2b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java @@ -23,7 +23,7 @@ import org.springframework.aop.ClassFilter; import org.springframework.aop.MethodMatcher; import org.springframework.aop.Pointcut; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.NestedRuntimeException; import org.springframework.lang.Nullable; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java index 956143c3a3e6..69251aaebc43 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java @@ -20,8 +20,8 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.tests.aop.interceptor.NopInterceptor; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java index 9cb1a04934ba..b0330ff68214 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java @@ -24,12 +24,12 @@ import org.springframework.aop.IntroductionAdvisor; import org.springframework.aop.IntroductionInterceptor; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.beans.test.fixtures.beans.INestedTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.NestedTestBean; -import org.springframework.beans.test.fixtures.beans.Person; -import org.springframework.beans.test.fixtures.beans.SerializablePerson; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.INestedTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.NestedTestBean; +import org.springframework.beans.testfixture.beans.Person; +import org.springframework.beans.testfixture.beans.SerializablePerson; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.testfixture.TimeStamped; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java index df7b67dfaf2b..d7d3a5ceb4c5 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java @@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.MethodMatcher; -import org.springframework.beans.test.fixtures.beans.IOther; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.IOther; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.lang.Nullable; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java index 8a9f1ec1e3e2..e344536e21ac 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java @@ -21,8 +21,8 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.beans.test.fixtures.beans.Person; -import org.springframework.beans.test.fixtures.beans.SerializablePerson; +import org.springframework.beans.testfixture.beans.Person; +import org.springframework.beans.testfixture.beans.SerializablePerson; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java index 0b913b97030b..22940cf59f6d 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java @@ -22,7 +22,7 @@ import org.springframework.aop.ClassFilter; import org.springframework.aop.Pointcut; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.lang.Nullable; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java index 1782124f278e..00021faeb8ff 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java @@ -21,9 +21,9 @@ import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.Person; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.Person; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.Resource; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.NopInterceptor; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/RootClassFilterTests.java b/spring-aop/src/test/java/org/springframework/aop/support/RootClassFilterTests.java index 184858d27f0b..e09344b35bc8 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/RootClassFilterTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/RootClassFilterTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.ClassFilter; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java index 609f159a9da8..6637815d058e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java @@ -21,7 +21,7 @@ import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java index d48d213f8d2d..ca10d0f1b93d 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java @@ -25,9 +25,9 @@ import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.Person; -import org.springframework.beans.test.fixtures.beans.SerializablePerson; -import org.springframework.beans.test.fixtures.beans.SideEffectBean; +import org.springframework.beans.testfixture.beans.Person; +import org.springframework.beans.testfixture.beans.SerializablePerson; +import org.springframework.beans.testfixture.beans.SideEffectBean; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java index 3a7276921817..6c38a0f04fc2 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java index dc3da8eff31b..3a84193d50f1 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java @@ -23,8 +23,8 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.SerializablePerson; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.SerializablePerson; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java index 4be4d16b5a3c..7871e1072d18 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java @@ -21,7 +21,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.SideEffectBean; +import org.springframework.beans.testfixture.beans.SideEffectBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java index 9cfa6d4848b8..7cb788ed1ac8 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java @@ -21,8 +21,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.SideEffectBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.SideEffectBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml index 745dbc3e40fb..64f222cdd372 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml @@ -20,7 +20,7 @@ - + diff --git a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml index 59bd49621c61..33693b7c1c40 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml @@ -14,7 +14,7 @@ - + diff --git a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml index 955540049e93..3d2037805e41 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml @@ -14,7 +14,7 @@ - + diff --git a/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml index 7ce48dc01edf..b4e8fec10d26 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml @@ -4,7 +4,7 @@ - + custom 666 @@ -21,15 +21,15 @@ - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean settersAdvisor - org.springframework.beans.test.fixtures.beans.Person + org.springframework.beans.testfixture.beans.Person - + serializableSettersAdvised @@ -48,7 +48,7 @@ - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean true diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests-context.xml index a18634ee9ff3..c0bbd2fe9097 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests-context.xml @@ -3,7 +3,7 @@ - + diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml index a5d28ca2f8d7..25f39f9f71da 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml @@ -4,11 +4,11 @@ - + 10 - + 20 diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-customTarget.xml b/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-customTarget.xml index d48cdb081756..70f7406195da 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-customTarget.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-customTarget.xml @@ -3,7 +3,7 @@ - + 10 diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-singleton.xml b/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-singleton.xml index 7f29fec4f784..e10984760269 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-singleton.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-singleton.xml @@ -3,7 +3,7 @@ - + 10 diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml index 6b2801a1e9ec..9689ba92e8fc 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml @@ -4,11 +4,11 @@ - + 10 - + 10 diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml index 5d71019c5fc6..40f77d3f9799 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml @@ -3,7 +3,7 @@ - + 10 @@ -34,12 +34,12 @@ - + Rod - + Kerry diff --git a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java index 0b41d64982ec..3cb51ae1eb89 100644 --- a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java @@ -43,11 +43,11 @@ import org.springframework.beans.propertyeditors.StringArrayPropertyEditor; import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.beans.support.DerivedFromProtectedBaseBean; -import org.springframework.beans.test.fixtures.beans.BooleanTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.NumberTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.BooleanTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.NumberTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.convert.ConversionFailedException; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.support.DefaultConversionService; diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java index 948d1913f9bf..e03707d9ab6e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java @@ -34,9 +34,9 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.propertyeditors.CustomDateEditor; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceEditor; import org.springframework.lang.Nullable; diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java index 492cb10d4947..03ec1cd83842 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.CustomEnum; -import org.springframework.beans.test.fixtures.beans.GenericBean; +import org.springframework.beans.testfixture.beans.CustomEnum; +import org.springframework.beans.testfixture.beans.GenericBean; import org.springframework.core.convert.support.DefaultConversionService; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java index 9e6f50e2cfdc..6d582eff559f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java @@ -33,10 +33,10 @@ import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.beans.propertyeditors.StringTrimmerEditor; -import org.springframework.beans.test.fixtures.beans.GenericBean; -import org.springframework.beans.test.fixtures.beans.GenericIntegerBean; -import org.springframework.beans.test.fixtures.beans.GenericSetOfIntegerBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.GenericBean; +import org.springframework.beans.testfixture.beans.GenericIntegerBean; +import org.springframework.beans.testfixture.beans.GenericSetOfIntegerBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.UrlResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java index f9661e84492e..0711189b5f59 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java b/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java index 78f2fdf5a73f..cba7e4964a98 100644 --- a/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.OverridingClassLoader; import static org.assertj.core.api.Assertions.assertThat; @@ -42,7 +42,7 @@ public void acceptAndClearClassLoader() throws Exception { assertThat(CachedIntrospectionResults.strongClassCache.containsKey(TestBean.class)).isTrue(); ClassLoader child = new OverridingClassLoader(getClass().getClassLoader()); - Class tbClass = child.loadClass("org.springframework.beans.test.fixtures.beans.TestBean"); + Class tbClass = child.loadClass("org.springframework.beans.testfixture.beans.TestBean"); assertThat(CachedIntrospectionResults.strongClassCache.containsKey(tbClass)).isFalse(); CachedIntrospectionResults.acceptClassLoader(child); bw = new BeanWrapperImpl(tbClass); diff --git a/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java b/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java index 9f7ff9dda23b..1ca8ddc60298 100644 --- a/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java index 732e61131a55..d9876729023f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java index dc214a2a425a..104556d614c5 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java @@ -26,12 +26,12 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.StaticListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.AnnotatedBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.TestAnnotation; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; +import org.springframework.beans.testfixture.beans.AnnotatedBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.TestAnnotation; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.beans.factory.DummyFactory; import org.springframework.cglib.proxy.NoOp; import org.springframework.core.io.Resource; import org.springframework.util.ObjectUtils; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java index da710e31a589..689dc04547a9 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java @@ -78,14 +78,14 @@ import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.ConstructorDependenciesBean; import org.springframework.beans.propertyeditors.CustomNumberEditor; -import org.springframework.beans.test.fixtures.beans.DependenciesBean; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.LifecycleBean; -import org.springframework.beans.test.fixtures.beans.NestedTestBean; -import org.springframework.beans.test.fixtures.beans.SideEffectBean; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; +import org.springframework.beans.testfixture.beans.DependenciesBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.LifecycleBean; +import org.springframework.beans.testfixture.beans.NestedTestBean; +import org.springframework.beans.testfixture.beans.SideEffectBean; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.beans.factory.DummyFactory; import org.springframework.core.MethodParameter; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationAwareOrderComparator; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java index 87dcbe72d314..69829b2eb2a1 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java @@ -64,10 +64,10 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.NestedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.NestedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.Ordered; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationAwareOrderComparator; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java index a90d044209a4..43e57e7d26a8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java @@ -40,10 +40,10 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.NestedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.NestedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java index d610040ed688..d9b198e3e351 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java index 3fa7f2b4e9ac..a94425ccf1aa 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java @@ -33,7 +33,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.propertyeditors.CustomDateEditor; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java index 38ad12dc7eb5..73c5cf258f5c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; @@ -115,7 +115,7 @@ public void testJustTargetObject() throws Exception { @Test public void testWithConstantOnClassWithPackageLevelVisibility() throws Exception { FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean(); - fr.setBeanName("org.springframework.beans.test.fixtures.beans.PackageLevelVisibleBean.CONSTANT"); + fr.setBeanName("org.springframework.beans.testfixture.beans.PackageLevelVisibleBean.CONSTANT"); fr.afterPropertiesSet(); assertThat(fr.getObject()).isEqualTo("Wuby"); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java index dd256ece36ae..06e750168c49 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java @@ -20,8 +20,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java index b3efca4647f3..13d8b138ff43 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java index c85944480a17..999c2e4b2446 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java @@ -39,8 +39,8 @@ import org.springframework.beans.factory.support.ManagedMap; import org.springframework.beans.factory.support.ManagedSet; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.Resource; import org.springframework.util.StringUtils; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java index a123a5721b84..38b10b562f5c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java index feb10d03633b..34abf223af41 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java index de163b96e34e..ec157df512c2 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java index e5fe0a0e8681..16fc1a1e3570 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinitionHolder; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java index de938f38b746..fbd4d27d9ca3 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java @@ -43,10 +43,10 @@ import org.springframework.beans.factory.config.TypedStringValue; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.propertyeditors.CustomNumberEditor; -import org.springframework.beans.test.fixtures.beans.GenericBean; -import org.springframework.beans.test.fixtures.beans.GenericIntegerBean; -import org.springframework.beans.test.fixtures.beans.GenericSetOfIntegerBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.GenericBean; +import org.springframework.beans.testfixture.beans.GenericIntegerBean; +import org.springframework.beans.testfixture.beans.GenericSetOfIntegerBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.OverridingClassLoader; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationAwareOrderComparator; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java index a325c67a35ef..6e3f8465e9e8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java @@ -20,8 +20,8 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.ObjectFactory; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java index 866556a180cd..1c469274c29c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java @@ -20,7 +20,7 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.RuntimeBeanReference; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java index e6781ed74d42..eeb34b6f8f1e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java index 7efdfe4c0012..dbb70e54b9b0 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java index 05fa60b0b4cc..8ff2952fb113 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java @@ -21,7 +21,7 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java index f7c2542aecc7..8ea0719a82be 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java index bc119e2b1835..04b82ca200a8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java @@ -27,7 +27,7 @@ import org.springframework.beans.factory.support.BeanDefinitionReader; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java index e0ceb48a1edc..0c3ebedd1700 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java index df644ab49cca..1d3c6286d312 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java @@ -18,8 +18,8 @@ import java.io.Serializable; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; /** * Simple bean used to check constructor dependency checking. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java index 2d2720ff1e3d..21ccf619b38b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java @@ -17,7 +17,7 @@ package org.springframework.beans.factory.xml; import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; /** * @author Juergen Hoeller diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java index 2c1a8b99b5b7..10bf54f5e07c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java @@ -17,8 +17,8 @@ package org.springframework.beans.factory.xml; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.beans.factory.DummyFactory; /** * @author Juergen Hoeller diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java index 8f9a71541469..2520004ea3c6 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java index 0d872c14fa20..29e2561fc756 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java @@ -30,7 +30,7 @@ import org.springframework.beans.factory.parsing.ImportDefinition; import org.springframework.beans.factory.parsing.PassThroughSourceExtractor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; +import org.springframework.beans.testfixture.beans.CollectingReaderEventListener; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java index f6ac02ae32a9..3ae92e3c8e8a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java index 80b7747d969e..88b5321b893c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java @@ -19,7 +19,7 @@ import java.util.Collections; import java.util.List; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; /** * Test class for Spring's ability to create objects using static diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java index e5b1d4d24f3e..3dd4cbd1467a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; /** * Test class for Spring's ability to create objects using diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java index a5bc425d7673..debeb353cafa 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java @@ -20,7 +20,7 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java index c1fa690bf5ae..70199450995b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java @@ -21,7 +21,7 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java index b6eef0422c75..24a9d43e89be 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java @@ -20,8 +20,8 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.DummyBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.DummyBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java index 054e51e95fc7..68ef31d9a82f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java @@ -20,8 +20,8 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java index cf6eb8aa42cd..091a20290e7c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; /** * Test class for Spring's ability to create diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java index 2e0bb5bb33c2..2260a86c52e9 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java @@ -32,9 +32,9 @@ import org.springframework.beans.factory.parsing.ComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; -import org.springframework.beans.test.fixtures.beans.CustomEnum; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.CollectingReaderEventListener; +import org.springframework.beans.testfixture.beans.CustomEnum; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.util.LinkedCaseInsensitiveMap; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java index 51200a52e47b..e502695dd323 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java @@ -38,8 +38,8 @@ import org.springframework.beans.factory.config.MapFactoryBean; import org.springframework.beans.factory.config.SetFactoryBean; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.HasMap; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.HasMap; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java index 34474e075da3..69768da8278f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.Resource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java index e3f69d70bfdc..d48b55f2cb8d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java @@ -30,11 +30,11 @@ import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.LifecycleBean; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; -import org.springframework.beans.test.fixtures.factory.xml.AbstractListableBeanFactoryTests; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.LifecycleBean; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.beans.factory.DummyFactory; +import org.springframework.beans.testfixture.factory.xml.AbstractListableBeanFactoryTests; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java index eb3c0b6d7f18..c6bbf52eb5d7 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java @@ -43,11 +43,11 @@ import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.PropertyValue; -import org.springframework.beans.test.fixtures.beans.BooleanTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.NumberTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.BooleanTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.NumberTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -593,9 +593,9 @@ public void testClassEditorWithNonExistentClass() throws Exception { @Test public void testClassEditorWithArray() { PropertyEditor classEditor = new ClassEditor(); - classEditor.setAsText("org.springframework.beans.test.fixtures.beans.TestBean[]"); + classEditor.setAsText("org.springframework.beans.testfixture.beans.TestBean[]"); assertThat(classEditor.getValue()).isEqualTo(TestBean[].class); - assertThat(classEditor.getAsText()).isEqualTo("org.springframework.beans.test.fixtures.beans.TestBean[]"); + assertThat(classEditor.getAsText()).isEqualTo("org.springframework.beans.testfixture.beans.TestBean[]"); } /* diff --git a/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java b/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java index e244830c1c55..0afce6483444 100644 --- a/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt b/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt index 81c910b2b154..37d6793cad50 100644 --- a/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt +++ b/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt @@ -22,8 +22,8 @@ import org.junit.jupiter.api.Test import org.springframework.beans.factory.BeanCreationException import org.springframework.beans.factory.support.DefaultListableBeanFactory import org.springframework.beans.factory.support.RootBeanDefinition -import org.springframework.beans.test.fixtures.beans.Colour -import org.springframework.beans.test.fixtures.beans.TestBean +import org.springframework.beans.testfixture.beans.Colour +import org.springframework.beans.testfixture.beans.TestBean /** * Tests for Kotlin support with [Autowired]. diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-leaf.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-leaf.xml index 08e3ff9ab394..435dcb06cbd8 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-leaf.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-leaf.xml @@ -3,7 +3,7 @@ - + custom 25 diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-middle.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-middle.xml index 29fdf9a87253..4804e44cf889 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-middle.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-middle.xml @@ -4,7 +4,7 @@ - + custom 666 @@ -13,7 +13,7 @@ Check that invoker is automatically added to wrap target. Non pointcut bean name should be wrapped in invoker. --> - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-root.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-root.xml index 75ee49e0ee72..fea62a3791b1 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-root.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/BeanFactoryUtilsTests-root.xml @@ -6,21 +6,21 @@ - + - + - + - + custom 25 - + - + false diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests-context.xml index 7cb6892b03dc..35c854bdb0e0 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests-context.xml @@ -3,7 +3,7 @@ - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests-context.xml index 9b1e2953138a..d9979e38339a 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests-context.xml @@ -3,19 +3,19 @@ - + 10 - + 11 - + 98 - + 99 @@ -23,7 +23,7 @@ - + 12 @@ -46,10 +46,10 @@ tb spouse - org.springframework.beans.test.fixtures.beans.TestBean + org.springframework.beans.testfixture.beans.TestBean - + @@ -59,11 +59,11 @@ - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/config/SimpleScopeTests-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/config/SimpleScopeTests-context.xml index 22cfc5d272b4..9ac321b0cc45 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/config/SimpleScopeTests-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/config/SimpleScopeTests-context.xml @@ -3,6 +3,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/parsing/CustomProblemReporterTests-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/parsing/CustomProblemReporterTests-context.xml index b1c5df805a98..1c6e22b51182 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/parsing/CustomProblemReporterTests-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/parsing/CustomProblemReporterTests-context.xml @@ -6,7 +6,7 @@ - + @@ -14,9 +14,9 @@ - + - + @@ -26,6 +26,6 @@ - + \ No newline at end of file diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/support/genericBeanTests.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/support/genericBeanTests.xml index 37f949c079b8..c610f9cf1591 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/support/genericBeanTests.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/support/genericBeanTests.xml @@ -3,7 +3,7 @@ - + @@ -43,7 +43,7 @@ autowire="constructor"> - + @@ -53,7 +53,7 @@ - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/support/lookupMethodTests.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/support/lookupMethodTests.xml index 2fb5d2204f58..a04f0e3beb42 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/support/lookupMethodTests.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/support/lookupMethodTests.xml @@ -13,9 +13,9 @@ - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/support/multiConstructorArgs.properties b/spring-beans/src/test/resources/org/springframework/beans/factory/support/multiConstructorArgs.properties index 529c97ce9e17..9cc82ac44933 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/support/multiConstructorArgs.properties +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/support/multiConstructorArgs.properties @@ -1,3 +1,3 @@ -testBean.(class)=org.springframework.beans.test.fixtures.beans.TestBean +testBean.(class)=org.springframework.beans.testfixture.beans.TestBean testBean.$0=Rob Harrop testBean.$1=23 diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/support/refConstructorArg.properties b/spring-beans/src/test/resources/org/springframework/beans/factory/support/refConstructorArg.properties index ff4aff4552ec..b1bb01e2a507 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/support/refConstructorArg.properties +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/support/refConstructorArg.properties @@ -1,5 +1,5 @@ -sally.(class)=org.springframework.beans.test.fixtures.beans.TestBean +sally.(class)=org.springframework.beans.testfixture.beans.TestBean sally.name=Sally -rob.(class)=org.springframework.beans.test.fixtures.beans.TestBean +rob.(class)=org.springframework.beans.testfixture.beans.TestBean rob.$0(ref)=sally diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/support/simpleConstructorArg.properties b/spring-beans/src/test/resources/org/springframework/beans/factory/support/simpleConstructorArg.properties index 8d4246bba2be..bc39b1b018c0 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/support/simpleConstructorArg.properties +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/support/simpleConstructorArg.properties @@ -1,2 +1,2 @@ -testBean.(class)=org.springframework.beans.test.fixtures.beans.TestBean +testBean.(class)=org.springframework.beans.testfixture.beans.TestBean testBean.$0=Rob Harrop diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-multiLevel-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-multiLevel-context.xml index ee803599bb66..0e326790f7fd 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-multiLevel-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-multiLevel-context.xml @@ -4,12 +4,12 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-sameLevel-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-sameLevel-context.xml index 58e3415afc8d..40ecbec4ac9a 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-sameLevel-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/DuplicateBeanIdTests-sameLevel-context.xml @@ -4,12 +4,12 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests-merge-context.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests-merge-context.xml index 10015b0fc0de..f3453c7bb943 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests-merge-context.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests-merge-context.xml @@ -5,7 +5,7 @@ https://www.springframework.org/schema/beans/spring-beans-3.1.xsd" default-merge="false"> - + alpha diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-constructor-with-exclusion.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-constructor-with-exclusion.xml index 8f5f1b01b1ed..2b2515103095 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-constructor-with-exclusion.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-constructor-with-exclusion.xml @@ -3,9 +3,9 @@ - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-exclusion.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-exclusion.xml index 26651d8bbbed..692cc7743f56 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-exclusion.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-exclusion.xml @@ -3,9 +3,9 @@ - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-inclusion.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-inclusion.xml index 0b9bb1ceb03c..f4090d14a71e 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-inclusion.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-inclusion.xml @@ -4,9 +4,9 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd" default-autowire-candidates=""> - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-selective-inclusion.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-selective-inclusion.xml index d23d1888d212..d52ba19ec021 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-selective-inclusion.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/autowire-with-selective-inclusion.xml @@ -4,9 +4,9 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd" default-autowire-candidates="props*,*ly"> - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/beanEvents.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/beanEvents.xml index 7a5640559d3a..2bdea186844c 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/beanEvents.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/beanEvents.xml @@ -10,22 +10,22 @@ - + - + - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionMerging.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionMerging.xml index 9243ec32bc4d..d45764707947 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionMerging.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionMerging.xml @@ -3,7 +3,7 @@ - + Rob Harrop @@ -23,12 +23,12 @@ - + - + Rob Harrop @@ -47,14 +47,14 @@ - + - + @@ -76,7 +76,7 @@ - + @@ -84,7 +84,7 @@ - + Sall @@ -103,7 +103,7 @@ - + Rob Harrop @@ -123,12 +123,12 @@ - + - + Rob Harrop @@ -147,14 +147,14 @@ - + - + @@ -176,7 +176,7 @@ - + @@ -184,7 +184,7 @@ - + Sall diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml index d245ac3afc3b..5683b4fe490e 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> - + Jenny 30 @@ -12,7 +12,7 @@ - + Simple bean, without any collections. @@ -23,7 +23,7 @@ 27 - + Rod 32 @@ -35,7 +35,7 @@ - + Jenny 30 @@ -43,13 +43,13 @@ - + David 27 - + Rod 32 @@ -63,7 +63,7 @@ - + loner 26 @@ -101,26 +101,26 @@ - + verbose - + - + - + - + @@ -130,7 +130,7 @@ - + @@ -157,7 +157,7 @@ - + @@ -176,7 +176,7 @@ - + @@ -185,7 +185,7 @@ - + @@ -217,14 +217,14 @@ - + - + bar @@ -234,7 +234,7 @@ - + bar @@ -244,7 +244,7 @@ - + @@ -253,7 +253,7 @@ - + @@ -261,7 +261,7 @@ - + bar @@ -270,7 +270,7 @@ - + @@ -279,7 +279,7 @@ - + one @@ -288,7 +288,7 @@ - + 0 @@ -298,11 +298,11 @@ - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionsWithDefaultTypes.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionsWithDefaultTypes.xml index e68a24410a74..a1a1ea378b1b 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionsWithDefaultTypes.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collectionsWithDefaultTypes.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - + 1 @@ -28,7 +28,7 @@ - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml index d9ba0aaeba67..dc328aa88847 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml @@ -107,7 +107,7 @@ - + Juergen @@ -130,7 +130,7 @@ - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/schemaValidated.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/schemaValidated.xml index 5fc58aa6093a..59b5ef71c3cc 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/schemaValidated.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/schemaValidated.xml @@ -3,16 +3,16 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> - + - + - + - - + + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTests.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTests.xml index eab699ae5f6e..c8adc6bdb3dc 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTests.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTests.xml @@ -5,43 +5,43 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + - + - + - + - + - + \ No newline at end of file diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTestsWithErrors.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTestsWithErrors.xml index 037baf8b0939..3dbfb5fae18f 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTestsWithErrors.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simpleConstructorNamespaceHandlerTestsWithErrors.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTests.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTests.xml index 82954f02b3ab..83e74fad1694 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTests.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTests.xml @@ -4,20 +4,20 @@ xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + - + - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTestsWithErrors.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTestsWithErrors.xml index a761f9e86a8c..b64093d0fc8a 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTestsWithErrors.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTestsWithErrors.xml @@ -4,10 +4,10 @@ xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/test.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/test.xml index d1bf86605390..7c4c7596e79f 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/test.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/test.xml @@ -3,7 +3,7 @@ - + I have no properties and I'm happy without them. @@ -12,7 +12,7 @@ - + aliased @@ -20,17 +20,17 @@ - + aliased - + aliased - + @@ -40,7 +40,7 @@ - + Rod 31 @@ -52,29 +52,29 @@ - + Kerry 34 - + Kathy 28 - + typeMismatch 34x - + - true @@ -85,10 +85,10 @@ - + - + false @@ -113,14 +113,14 @@ - + listenerVeto 66 - + - + this is a ]]> diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/testUtilNamespace.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/testUtilNamespace.xml index 47bce335d181..972aabcd669a 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/testUtilNamespace.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/testUtilNamespace.xml @@ -17,7 +17,7 @@ name "/> - + @@ -26,13 +26,13 @@ - + - + @@ -50,7 +50,7 @@ + key-type="java.lang.String" value-type="org.springframework.beans.testfixture.beans.TestBean"> @@ -72,7 +72,7 @@ Rob Harrop - + foo @@ -94,13 +94,13 @@ - + - + @@ -116,13 +116,13 @@ min - + - + @@ -152,7 +152,7 @@ - + diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithDtd.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithDtd.xml index f58440bfa423..fbe7861e21c0 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithDtd.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithDtd.xml @@ -9,5 +9,5 @@ This is a top level block comment - + \ No newline at end of file diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithXsd.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithXsd.xml index 615980708143..1e467348ea18 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithXsd.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/validateWithXsd.xml @@ -7,5 +7,5 @@ This is a top level block comment the parser now --> - + \ No newline at end of file diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/withMeta.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/withMeta.xml index 4148dffe92a6..5f7388177722 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/withMeta.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/withMeta.xml @@ -4,15 +4,15 @@ xmlns:spring="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - + - + - + diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AgeHolder.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/AgeHolder.java similarity index 93% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AgeHolder.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/AgeHolder.java index e48d4ff72500..722cea949646 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AgeHolder.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/AgeHolder.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; public interface AgeHolder { diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AnnotatedBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/AnnotatedBean.java similarity index 92% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AnnotatedBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/AnnotatedBean.java index 9a071690a352..985cf64de8af 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/AnnotatedBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/AnnotatedBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** * @author Stephane Nicoll diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/BooleanTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/BooleanTestBean.java similarity index 94% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/BooleanTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/BooleanTestBean.java index 52375b011383..5edbd304eddc 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/BooleanTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/BooleanTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** * @author Juergen Hoeller diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CollectingReaderEventListener.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CollectingReaderEventListener.java similarity index 98% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CollectingReaderEventListener.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CollectingReaderEventListener.java index 2145e26679f6..63e2e20a4267 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CollectingReaderEventListener.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CollectingReaderEventListener.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import java.util.ArrayList; import java.util.Collection; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Colour.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Colour.java similarity index 95% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Colour.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Colour.java index 011dbf0edb3e..531149005197 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Colour.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Colour.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** * @author Rob Harrop diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CountingTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CountingTestBean.java similarity index 93% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CountingTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CountingTestBean.java index 892f71d5305f..aa9083a88e11 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CountingTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CountingTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CustomEnum.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CustomEnum.java similarity index 93% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CustomEnum.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CustomEnum.java index 5bb56eaf26f5..de0d721943d8 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/CustomEnum.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CustomEnum.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** * @author Juergen Hoeller diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DependenciesBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DependenciesBean.java similarity index 96% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DependenciesBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DependenciesBean.java index cb81eb3b1696..f990781e11df 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DependenciesBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DependenciesBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DerivedTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DerivedTestBean.java similarity index 97% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DerivedTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DerivedTestBean.java index 6851deb9973a..c0e9c2e1dca4 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DerivedTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DerivedTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import java.io.Serializable; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DummyBean.java similarity index 96% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DummyBean.java index caa0a461b5b3..cac5cced1c8a 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DummyBean.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** * @author Costin Leau diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyFactory.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DummyFactory.java similarity index 98% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyFactory.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DummyFactory.java index 623884a8acc0..2cf683a7c5fb 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/DummyFactory.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DummyFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Employee.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Employee.java similarity index 94% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Employee.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Employee.java index eaf350ed1e38..3e9da7609e35 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Employee.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Employee.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; public class Employee extends TestBean { diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/GenericBean.java similarity index 99% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/GenericBean.java index 6946e890f8f4..2ad5ece17f5e 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/GenericBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import java.util.ArrayList; import java.util.Collection; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericIntegerBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/GenericIntegerBean.java similarity index 92% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericIntegerBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/GenericIntegerBean.java index 375d57fac97d..69fd56d17472 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericIntegerBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/GenericIntegerBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericSetOfIntegerBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/GenericSetOfIntegerBean.java similarity index 93% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericSetOfIntegerBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/GenericSetOfIntegerBean.java index d39f9078b79d..c0439f9fb669 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/GenericSetOfIntegerBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/GenericSetOfIntegerBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import java.util.Set; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/HasMap.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/HasMap.java similarity index 97% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/HasMap.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/HasMap.java index 02cf25b1ca8f..c874077bd1b2 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/HasMap.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/HasMap.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import java.util.IdentityHashMap; import java.util.List; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/INestedTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/INestedTestBean.java similarity index 92% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/INestedTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/INestedTestBean.java index ab83dd232241..3107e6b5f21c 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/INestedTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/INestedTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; public interface INestedTestBean { diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IOther.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/IOther.java similarity index 92% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IOther.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/IOther.java index 36d287fc9aac..05059bcf6873 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IOther.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/IOther.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; public interface IOther { diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/ITestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/ITestBean.java similarity index 92% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/ITestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/ITestBean.java index 9572e1265e0e..742b39c4ea7e 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/ITestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/ITestBean.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import java.io.IOException; /** - * Interface used for {@link org.springframework.beans.test.fixtures.beans.TestBean}. + * Interface used for {@link org.springframework.beans.testfixture.beans.TestBean}. * *

    Two methods are the same as on Person, but if this * extends person it breaks quite a few tests.. diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IndexedTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/IndexedTestBean.java similarity index 98% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IndexedTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/IndexedTestBean.java index 92de9d367806..02948f7eb854 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/IndexedTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/IndexedTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import java.util.ArrayList; import java.util.Collection; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/LifecycleBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/LifecycleBean.java similarity index 98% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/LifecycleBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/LifecycleBean.java index 3a070b01e524..b2e54028270d 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/LifecycleBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/LifecycleBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/MustBeInitialized.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/MustBeInitialized.java similarity index 96% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/MustBeInitialized.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/MustBeInitialized.java index 39309643620d..2e53ce2f885a 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/MustBeInitialized.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/MustBeInitialized.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import org.springframework.beans.factory.InitializingBean; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NestedTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/NestedTestBean.java similarity index 96% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NestedTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/NestedTestBean.java index 179fa2a561d8..ea26ec0072c0 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NestedTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/NestedTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** * Simple nested test bean used for testing bean factories, AOP framework etc. diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NumberTestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/NumberTestBean.java similarity index 97% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NumberTestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/NumberTestBean.java index e8874a2f92e1..224965b5c7a6 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/NumberTestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/NumberTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import java.math.BigDecimal; import java.math.BigInteger; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/PackageLevelVisibleBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/PackageLevelVisibleBean.java similarity index 93% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/PackageLevelVisibleBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/PackageLevelVisibleBean.java index 1a7300325d8f..73a0bd3b9358 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/PackageLevelVisibleBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/PackageLevelVisibleBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** * @see org.springframework.beans.factory.config.FieldRetrievingFactoryBeanTests diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Person.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Person.java similarity index 94% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Person.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Person.java index 37f5a55a9cb6..d57a8ca4267f 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Person.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Person.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** * diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Pet.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Pet.java similarity index 95% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Pet.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Pet.java index 44073a367c70..661eff92feb7 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/Pet.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/Pet.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** * @author Rob Harrop diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SerializablePerson.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/SerializablePerson.java similarity index 96% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SerializablePerson.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/SerializablePerson.java index e9d9398deff0..6f9436906cc1 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SerializablePerson.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/SerializablePerson.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import java.io.Serializable; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SideEffectBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/SideEffectBean.java similarity index 94% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SideEffectBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/SideEffectBean.java index cc1333610ed0..36911bdedcf1 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/SideEffectBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/SideEffectBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; /** * Bean that changes state on a business invocation, so that diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestAnnotation.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestAnnotation.java similarity index 93% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestAnnotation.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestAnnotation.java index 83090e6bb83d..379c87419b5f 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestAnnotation.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestAnnotation.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java similarity index 96% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java index 9cd31e42f00f..10431c03425a 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/TestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; import java.io.IOException; import java.util.ArrayList; @@ -421,7 +421,7 @@ public void setPets(List pets) { /** - * @see org.springframework.beans.test.fixtures.beans.ITestBean#exceptional(Throwable) + * @see org.springframework.beans.testfixture.beans.ITestBean#exceptional(Throwable) */ @Override public void exceptional(Throwable t) throws Throwable { @@ -435,7 +435,7 @@ public void unreliableFileOperation() throws IOException { throw new IOException(); } /** - * @see org.springframework.beans.test.fixtures.beans.ITestBean#returnsThis() + * @see org.springframework.beans.testfixture.beans.ITestBean#returnsThis() */ @Override public Object returnsThis() { @@ -443,7 +443,7 @@ public Object returnsThis() { } /** - * @see org.springframework.beans.test.fixtures.beans.IOther#absquatulate() + * @see org.springframework.beans.testfixture.beans.IOther#absquatulate() */ @Override public void absquatulate() { diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/factory/DummyFactory.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/factory/DummyFactory.java similarity index 97% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/factory/DummyFactory.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/factory/DummyFactory.java index ea27e526d174..9e3d8b6511a2 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/factory/DummyFactory.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/factory/DummyFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans.factory; +package org.springframework.beans.testfixture.beans.factory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; @@ -24,7 +24,7 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; /** * Simple factory to allow testing of FactoryBean support in AbstractBeanFactory. diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/package-info.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/package-info.java similarity index 55% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/package-info.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/package-info.java index 010c228ef82e..14a1870d42b7 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/package-info.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/package-info.java @@ -1,4 +1,4 @@ /** * General purpose sample beans that can be used with tests. */ -package org.springframework.beans.test.fixtures.beans; +package org.springframework.beans.testfixture.beans; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/subpkg/DeepBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/subpkg/DeepBean.java similarity index 93% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/subpkg/DeepBean.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/subpkg/DeepBean.java index fb5950c205c4..50fc891ad832 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/beans/subpkg/DeepBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/subpkg/DeepBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.beans.subpkg; +package org.springframework.beans.testfixture.beans.subpkg; /** * Used for testing pointcut matching. diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractBeanFactoryTests.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractBeanFactoryTests.java similarity index 96% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractBeanFactoryTests.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractBeanFactoryTests.java index 5695b05d4aa8..307a9d64c12d 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractBeanFactoryTests.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractBeanFactoryTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.factory.xml; +package org.springframework.beans.testfixture.factory.xml; import java.beans.PropertyEditorSupport; import java.util.StringTokenizer; @@ -29,10 +29,10 @@ import org.springframework.beans.factory.BeanNotOfRequiredTypeException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.beans.test.fixtures.beans.LifecycleBean; -import org.springframework.beans.test.fixtures.beans.MustBeInitialized; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; +import org.springframework.beans.testfixture.beans.LifecycleBean; +import org.springframework.beans.testfixture.beans.MustBeInitialized; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.beans.factory.DummyFactory; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractListableBeanFactoryTests.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractListableBeanFactoryTests.java similarity index 90% rename from spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractListableBeanFactoryTests.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractListableBeanFactoryTests.java index 2d319fe47f16..0717f8a49366 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/test/fixtures/factory/xml/AbstractListableBeanFactoryTests.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractListableBeanFactoryTests.java @@ -14,14 +14,14 @@ * limitations under the License. */ -package org.springframework.beans.test.fixtures.factory.xml; +package org.springframework.beans.testfixture.factory.xml; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; @@ -55,13 +55,13 @@ protected final void assertCount(int count) { protected void assertTestBeanCount(int count) { String[] defNames = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, false); - assertThat(defNames.length == count).as("We should have " + count + " beans for class org.springframework.beans.test.fixtures.beans.TestBean, not " + + assertThat(defNames.length == count).as("We should have " + count + " beans for class org.springframework.beans.testfixture.beans.TestBean, not " + defNames.length).isTrue(); int countIncludingFactoryBeans = count + 2; String[] names = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, true); assertThat(names.length == countIncludingFactoryBeans).as("We should have " + countIncludingFactoryBeans + - " beans for class org.springframework.beans.test.fixtures.beans.TestBean, not " + names.length).isTrue(); + " beans for class org.springframework.beans.testfixture.beans.TestBean, not " + names.length).isTrue(); } @Test diff --git a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java index d8e4506c516a..a30b1c291212 100644 --- a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java +++ b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java @@ -34,7 +34,7 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.StaticApplicationContext; import org.springframework.core.task.TaskExecutor; diff --git a/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/BeanValidationPostProcessorTests.java b/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/BeanValidationPostProcessorTests.java index 39c6aae3808a..4d014707077a 100644 --- a/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/BeanValidationPostProcessorTests.java +++ b/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/BeanValidationPostProcessorTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor; import org.springframework.context.support.GenericApplicationContext; import org.springframework.validation.beanvalidation.BeanValidationPostProcessor; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java index b5046caae516..036a78c7adfa 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java @@ -22,8 +22,8 @@ import org.springframework.aop.aspectj.AdviceBindingTestAspect.AdviceBindingCollaborator; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java index 224e749c670b..1ea6cecb4d98 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java @@ -22,8 +22,8 @@ import org.springframework.aop.aspectj.AfterReturningAdviceBindingTestAspect.AfterReturningAdviceBindingCollaborator; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java index 95829f7c96ee..000a9f3efbb0 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.aspectj.AfterThrowingAdviceBindingTestAspect.AfterThrowingAdviceBindingCollaborator; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java index f01b706f3ac8..c3404c7662bb 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java @@ -23,8 +23,8 @@ import org.springframework.aop.aspectj.AroundAdviceBindingTestAspect.AroundAdviceBindingCollaborator; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java index 159d40ef02b8..e813f37c899e 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java @@ -24,7 +24,7 @@ import org.springframework.aop.MethodBeforeAdvice; import org.springframework.beans.factory.BeanNameAware; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.Ordered; import org.springframework.lang.Nullable; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java index 53441e6f8525..cb59c1a8d8d3 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java index 60de4114d9d8..3329cec3bd26 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java @@ -22,8 +22,8 @@ import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; import org.springframework.aop.framework.Advised; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java index f315b7643b16..a56014324e00 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java @@ -25,7 +25,7 @@ import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.lang.Nullable; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java index e3be4ccc2006..90c5879aaa69 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java @@ -22,8 +22,8 @@ import org.springframework.aop.aspectj.AdviceBindingTestAspect.AdviceBindingCollaborator; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java index ce1c128623f9..c1bf87d25560 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java @@ -21,7 +21,7 @@ import test.mixin.Lockable; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.java index 0ac74719adcd..fc9970bc0916 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.java @@ -21,7 +21,7 @@ import org.aspectj.lang.annotation.Aspect; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; /** @@ -42,7 +42,7 @@ public void testAspect() { @Aspect static class CounterAtAspectJAspect { - @Around(value="execution(* org.springframework.beans.test.fixtures.beans.TestBean.*(..)) and this(bean) and args(argument)", + @Around(value="execution(* org.springframework.beans.testfixture.beans.TestBean.*(..)) and this(bean) and args(argument)", argNames="bean,argument") public void increment(ProceedingJoinPoint pjp, TestBean bean, Object argument) throws Throwable { pjp.proceed(); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java index f4b650f8da62..dc67e2e90023 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorAndLazyInitTargetSourceTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorAndLazyInitTargetSourceTests.java index 43c9226c9953..82b6fbb4d448 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorAndLazyInitTargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorAndLazyInitTargetSourceTests.java @@ -18,8 +18,8 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java index b93e64480468..152c9a128d30 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java @@ -43,10 +43,10 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.INestedTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.NestedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.INestedTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.NestedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.GenericApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java index eb254e8dd1ca..13bd4d38c0e9 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThat; @@ -64,7 +64,7 @@ class ExceptionHandlingAspect { public IOException lastException; - @AfterThrowing(pointcut = "within(org.springframework.beans.test.fixtures.beans.ITestBean+)", throwing = "ex") + @AfterThrowing(pointcut = "within(org.springframework.beans.testfixture.beans.ITestBean+)", throwing = "ex") public void handleIOException(IOException ex) { handled++; lastException = ex; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java index 0ed10779ddc6..c26ed5e6b896 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java @@ -32,7 +32,7 @@ import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.aop.support.StaticMethodMatcherPointcut; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.util.StopWatch; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java index 2b37c428ab1e..55507fec3779 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java @@ -25,8 +25,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java b/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java index a57e1113e3ac..d295b1d1edc7 100644 --- a/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java +++ b/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java @@ -20,7 +20,7 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java index 3b5af8a87a48..4e71cd317714 100644 --- a/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java @@ -23,8 +23,8 @@ import org.springframework.aop.Advisor; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.tests.aop.advice.CountingBeforeAdvice; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java index 94b08b3ff02e..c1bcc57b52da 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java @@ -57,11 +57,11 @@ import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; import org.springframework.aop.target.HotSwappableTargetSource; import org.springframework.aop.target.SingletonTargetSource; -import org.springframework.beans.test.fixtures.beans.IOther; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.Person; -import org.springframework.beans.test.fixtures.beans.SerializablePerson; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.IOther; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.Person; +import org.springframework.beans.testfixture.beans.SerializablePerson; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.core.testfixture.TestGroup; import org.springframework.core.testfixture.TimeStamped; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java index aec81a331e8c..60b0e73c419e 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java @@ -28,8 +28,8 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.DefaultPointcutAdvisor; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java index d34ac00a3ad0..1488d384715b 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java @@ -24,9 +24,9 @@ import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.IOther; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.IOther; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java index 040687e30ad8..dd8e884664d9 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java @@ -45,10 +45,10 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.Person; -import org.springframework.beans.test.fixtures.beans.SideEffectBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.Person; +import org.springframework.beans.testfixture.beans.SideEffectBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationListener; import org.springframework.context.test.fixtures.beans.TestApplicationListener; import org.springframework.core.io.ClassPathResource; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java b/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java index cb71798c54f6..6fc225979e1b 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java @@ -28,7 +28,7 @@ import org.springframework.aop.Advisor; import org.springframework.aop.BeforeAdvice; import org.springframework.aop.framework.Advised; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java index 1b83b1680d12..db7fb5fb25ed 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java @@ -31,8 +31,8 @@ import org.springframework.aop.target.PrototypeTargetSource; import org.springframework.aop.target.ThreadLocalTargetSource; import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.test.fixtures.beans.CountingTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.CountingTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.interceptor.NopInterceptor; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java index e2565bde7910..b0fde5f2be9c 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java @@ -37,10 +37,10 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.beans.factory.DummyFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.MessageSource; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java index 2374a56fcbb4..71d49ff2c06c 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.MethodBeforeAdvice; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.lang.Nullable; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java index cbd7ba5aff73..5167ba3f089b 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java @@ -25,8 +25,8 @@ import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.testfixture.TimeStamped; import org.springframework.tests.aop.advice.CountingBeforeAdvice; diff --git a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java index 246863726d3b..7b6cb703a7bd 100644 --- a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java @@ -25,8 +25,8 @@ import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.test.fixtures.SimpleMapScope; import org.springframework.core.io.ClassPathResource; diff --git a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java index 68f75103a80b..ebfc29c8fd56 100644 --- a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java @@ -25,9 +25,9 @@ import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.Person; -import org.springframework.beans.test.fixtures.beans.SerializablePerson; -import org.springframework.beans.test.fixtures.beans.SideEffectBean; +import org.springframework.beans.testfixture.beans.Person; +import org.springframework.beans.testfixture.beans.SerializablePerson; +import org.springframework.beans.testfixture.beans.SideEffectBean; import org.springframework.context.support.StaticApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.testfixture.io.SerializationTestUtils; diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java index 275ddd9fcbb0..e65b730e6938 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.interceptor.DebugInterceptor; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerWithExpressionLanguageTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerWithExpressionLanguageTests.java index 18ef636ee135..954cf1f6dbf1 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerWithExpressionLanguageTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerWithExpressionLanguageTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java index 936981add7b3..1ac5e555bad1 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java @@ -33,10 +33,10 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.support.MethodReplacer; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.beans.factory.DummyFactory; /** * Types used by {@link XmlBeanFactoryTests} and its attendant XML config files. diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java index 70c6116e7c60..4a66ed91ef03 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java @@ -51,12 +51,12 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.MethodReplacer; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.DependenciesBean; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; +import org.springframework.beans.testfixture.beans.DependenciesBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.beans.factory.DummyFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.UrlResource; diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java index a03a18f4a1e3..e623102553c1 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java @@ -51,8 +51,8 @@ import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.PluggableSchemaResolver; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationListener; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.ClassPathResource; diff --git a/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java b/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java index 4ade8ae382a6..05e821511407 100644 --- a/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java +++ b/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Caching; diff --git a/spring-context/src/test/java/org/springframework/context/LifecycleContextBean.java b/spring-context/src/test/java/org/springframework/context/LifecycleContextBean.java index c6e1fe0b1942..1f04eb182ccc 100644 --- a/spring-context/src/test/java/org/springframework/context/LifecycleContextBean.java +++ b/spring-context/src/test/java/org/springframework/context/LifecycleContextBean.java @@ -18,7 +18,7 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.test.fixtures.beans.LifecycleBean; +import org.springframework.beans.testfixture.beans.LifecycleBean; /** * Simple bean to test ApplicationContext lifecycle methods for beans diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java index 3ad2a49c70a5..28808939e395 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java index b0a89c07e961..4b564506fa89 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java @@ -33,8 +33,8 @@ import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.testfixture.Assume; import org.springframework.core.testfixture.EnabledForTestGroups; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java index f569b9e252dc..225a6fc7440a 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java @@ -31,7 +31,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.support.StaticListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.MessageSource; import org.springframework.context.annotation2.NamedStubDao2; import org.springframework.context.support.GenericApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java index b8cd73c5b046..a15cc4c76877 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java @@ -23,7 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation4.DependencyBean; import org.springframework.context.annotation4.FactoryMethodComponent; import org.springframework.context.support.AbstractApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java index 44af70d9b10f..7c1fa7016aa8 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java @@ -36,10 +36,10 @@ import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.INestedTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.NestedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.INestedTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.NestedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; import org.springframework.core.testfixture.io.SerializationTestUtils; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java index 4eb979370fe2..21324a769edc 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java index 5d8fe0c6e1fc..0aaf4c00a069 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java index f6ac667ba901..a99e16e530c2 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java @@ -53,8 +53,8 @@ import org.springframework.beans.factory.support.ChildBeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.componentscan.simple.SimpleComponent; import org.springframework.core.ResolvableType; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/FooServiceDependentConverter.java b/spring-context/src/test/java/org/springframework/context/annotation/FooServiceDependentConverter.java index b2f5d054444c..34af301685ba 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/FooServiceDependentConverter.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/FooServiceDependentConverter.java @@ -23,7 +23,7 @@ /** * @author Juergen Hoeller */ -public class FooServiceDependentConverter implements Converter { +public class FooServiceDependentConverter implements Converter { @SuppressWarnings("unused") private FooService fooService; @@ -33,8 +33,8 @@ public void setFooService(FooService fooService) { } @Override - public org.springframework.beans.test.fixtures.beans.TestBean convert(String source) { - return new org.springframework.beans.test.fixtures.beans.TestBean(source); + public org.springframework.beans.testfixture.beans.TestBean convert(String source) { + return new org.springframework.beans.testfixture.beans.TestBean(source); } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java index 3befa5d860a1..92f97576e206 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java @@ -28,7 +28,7 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/MyTestBean.java b/spring-context/src/test/java/org/springframework/context/annotation/MyTestBean.java index f72bc3498c38..5baa5c6040e0 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/MyTestBean.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/MyTestBean.java @@ -23,8 +23,8 @@ class MyTestBean { @Bean - public org.springframework.beans.test.fixtures.beans.TestBean myTestBean() { - return new org.springframework.beans.test.fixtures.beans.TestBean(); + public org.springframework.beans.testfixture.beans.TestBean myTestBean() { + return new org.springframework.beans.testfixture.beans.TestBean(); } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java b/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java index f3e98bdc2f53..8d7c1c359812 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.stereotype.Component; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java index 701ce6288c94..b127a3731248 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java @@ -30,7 +30,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.annotation.AliasFor; import org.springframework.core.env.Environment; import org.springframework.core.env.MapPropertySource; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level1/Level1Config.java b/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level1/Level1Config.java index e570cb88ace6..bf817afa00ab 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level1/Level1Config.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level1/Level1Config.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.componentscan.level1; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level2/Level2Config.java b/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level2/Level2Config.java index 24c38b01d187..3a69e5e564b8 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level2/Level2Config.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/componentscan/level2/Level2Config.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.componentscan.level2; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java index 77bbe0efe021..fa9052002566 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java @@ -33,8 +33,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.Colour; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.Colour; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java index 1022a6eb18b5..d38bda76f7e3 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java @@ -25,8 +25,8 @@ import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.NestedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.NestedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java index 2ada5e53b202..d46c3a44f548 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -97,7 +97,7 @@ public TestBean testBean() { return new TestBean("name"); } - @Before("execution(* org.springframework.beans.test.fixtures.beans.TestBean.absquatulate(..)) && target(testBean)") + @Before("execution(* org.springframework.beans.testfixture.beans.TestBean.absquatulate(..)) && target(testBean)") public void touchBean(TestBean testBean) { testBean.setName("advisedName"); } @@ -122,7 +122,7 @@ public NameChangingAspect nameChangingAspect() { @Aspect static class NameChangingAspect { - @Before("execution(* org.springframework.beans.test.fixtures.beans.TestBean.absquatulate(..)) && target(testBean)") + @Before("execution(* org.springframework.beans.testfixture.beans.TestBean.absquatulate(..)) && target(testBean)") public void touchBean(TestBean testBean) { testBean.setName("advisedName"); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java index 7fc345371f49..733e087954e4 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java @@ -46,9 +46,9 @@ import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.NestedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.NestedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationListener; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigUtils; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java index 7b030fe87410..0dfcb05c2f90 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java @@ -19,8 +19,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java index 7dd91b4dca69..43aac4f7cf31 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java index 04f566a259fe..240640c6864d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java index 80aa7fa7bf5a..87dd37d39886 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java @@ -26,7 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -147,7 +147,7 @@ static class ImportXmlWithAopNamespaceConfig { @Aspect static class AnAspect { - @Before("execution(* org.springframework.beans.test.fixtures.beans.TestBean.*(..))") + @Before("execution(* org.springframework.beans.testfixture.beans.TestBean.*(..))") public void advice() { } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java index 1d6968ba81c9..e82f604157b0 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java @@ -20,8 +20,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java index 1dfe75633feb..df640ffbd72d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java index d9cac63a3b14..d407d046b5ed 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java @@ -31,8 +31,8 @@ import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-context/src/test/java/org/springframework/context/annotation4/FactoryMethodComponent.java b/spring-context/src/test/java/org/springframework/context/annotation4/FactoryMethodComponent.java index 68659f6c67d5..1e751e3471ea 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation4/FactoryMethodComponent.java +++ b/spring-context/src/test/java/org/springframework/context/annotation4/FactoryMethodComponent.java @@ -18,7 +18,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.BeanAge; import org.springframework.context.annotation.Scope; diff --git a/spring-context/src/test/java/org/springframework/context/annotation4/SimpleBean.java b/spring-context/src/test/java/org/springframework/context/annotation4/SimpleBean.java index b3250692f590..69b5d94b393d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation4/SimpleBean.java +++ b/spring-context/src/test/java/org/springframework/context/annotation4/SimpleBean.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation4; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.Bean; /** diff --git a/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java b/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java index ec576df29c58..a95eafcce819 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java +++ b/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation6; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java index 1b88c9807e31..49cc3f85e971 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java @@ -31,7 +31,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationEvent; diff --git a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java index cd6a0d93ddb5..72e593f7d4e4 100644 --- a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java @@ -22,8 +22,8 @@ import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.event.test.TestEvent; diff --git a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java index f2f584f29f20..274be7aef120 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java @@ -43,7 +43,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigUtils; import org.springframework.context.support.GenericApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java index ca8e26eb73a5..93bd12add15d 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.testfixture.env.MockPropertySource; diff --git a/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java index d17406dec442..ffbdceb815e7 100644 --- a/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java @@ -27,7 +27,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java index 47cabda4f517..82a018cf3663 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java @@ -26,7 +26,7 @@ import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.config.PropertyResourceConfigurer; import org.springframework.beans.factory.config.RuntimeBeanReference; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.util.StringUtils; diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java index f899e376c40c..03606bc6979c 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java @@ -23,7 +23,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; diff --git a/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java b/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java index 2dfc95a76a38..95f4e0d98b30 100644 --- a/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java @@ -21,7 +21,7 @@ import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java index 9eda916bce5a..c3fbc6818a48 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationEvent; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.event.SimpleApplicationEventMulticaster; diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java index 16562fec9a4d..ac15f3bcaeee 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.test.fixtures.AbstractApplicationContextTests; import org.springframework.context.test.fixtures.beans.ACATester; diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java index d002ff505199..40771a9c6cac 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java @@ -182,9 +182,9 @@ protected ConfigurableApplicationContext createContext() throws Exception { Map m = new HashMap<>(); m.put("name", "Roderick"); - parent.registerPrototype("rod", org.springframework.beans.test.fixtures.beans.TestBean.class, new MutablePropertyValues(m)); + parent.registerPrototype("rod", org.springframework.beans.testfixture.beans.TestBean.class, new MutablePropertyValues(m)); m.put("name", "Albert"); - parent.registerPrototype("father", org.springframework.beans.test.fixtures.beans.TestBean.class, new MutablePropertyValues(m)); + parent.registerPrototype("father", org.springframework.beans.testfixture.beans.TestBean.class, new MutablePropertyValues(m)); parent.refresh(); parent.addApplicationListener(parentListener); diff --git a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java index 214f1b531631..dc0e81943f33 100644 --- a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java @@ -23,7 +23,7 @@ import org.springframework.beans.factory.parsing.ComponentDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; +import org.springframework.beans.testfixture.beans.CollectingReaderEventListener; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java index ac91f812a0e2..2b4ac0d08c06 100644 --- a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java @@ -23,7 +23,7 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean; @@ -126,7 +126,7 @@ public void testComplexRemoteSlsb() throws Exception { assertPropertyValue(beanDefinition, "lookupHomeOnStartup", "true"); assertPropertyValue(beanDefinition, "resourceRef", "true"); assertPropertyValue(beanDefinition, "jndiEnvironment", "foo=bar"); - assertPropertyValue(beanDefinition, "homeInterface", "org.springframework.beans.test.fixtures.beans.ITestBean"); + assertPropertyValue(beanDefinition, "homeInterface", "org.springframework.beans.testfixture.beans.ITestBean"); assertPropertyValue(beanDefinition, "refreshHomeOnConnectFailure", "true"); assertPropertyValue(beanDefinition, "cacheSessionBean", "true"); } diff --git a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java index c743b5d7f71a..e172dfd61d6b 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java @@ -42,7 +42,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.jmx.AbstractMBeanServerTests; diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java index 368b7b68ac7d..f7660b858156 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java @@ -22,9 +22,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; import static org.assertj.core.api.Assertions.assertThat; @@ -365,7 +365,7 @@ public void testLookupWithProxyInterfaceAndExpectedTypeAndNoMatch() { jof.setProxyInterface(ITestBean.class); assertThatExceptionOfType(NamingException.class).isThrownBy( jof::afterPropertiesSet) - .withMessageContaining("org.springframework.beans.test.fixtures.beans.DerivedTestBean"); + .withMessageContaining("org.springframework.beans.testfixture.beans.DerivedTestBean"); } @Test diff --git a/spring-context/src/test/java/org/springframework/scripting/ContextScriptBean.java b/spring-context/src/test/java/org/springframework/scripting/ContextScriptBean.java index b811e3a82938..b5033666dd2c 100644 --- a/spring-context/src/test/java/org/springframework/scripting/ContextScriptBean.java +++ b/spring-context/src/test/java/org/springframework/scripting/ContextScriptBean.java @@ -16,7 +16,7 @@ package org.springframework.scripting; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; /** diff --git a/spring-context/src/test/java/org/springframework/scripting/TestBeanAwareMessenger.java b/spring-context/src/test/java/org/springframework/scripting/TestBeanAwareMessenger.java index 94a5492a9da6..5edefe5c7adf 100644 --- a/spring-context/src/test/java/org/springframework/scripting/TestBeanAwareMessenger.java +++ b/spring-context/src/test/java/org/springframework/scripting/TestBeanAwareMessenger.java @@ -16,7 +16,7 @@ package org.springframework.scripting; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; /** * @author Juergen Hoeller diff --git a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java index 088c1b55399f..39459719073a 100644 --- a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java @@ -24,7 +24,7 @@ import org.springframework.aop.support.AopUtils; import org.springframework.aop.target.dynamic.Refreshable; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java index 66e18acce54a..c657c9ec1ea7 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java @@ -29,7 +29,7 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.NestedRuntimeException; diff --git a/spring-context/src/test/java/org/springframework/tests/sample/beans/FieldAccessBean.java b/spring-context/src/test/java/org/springframework/tests/sample/beans/FieldAccessBean.java index c1453a0d0451..e9a2ea500b98 100644 --- a/spring-context/src/test/java/org/springframework/tests/sample/beans/FieldAccessBean.java +++ b/spring-context/src/test/java/org/springframework/tests/sample/beans/FieldAccessBean.java @@ -16,7 +16,7 @@ package org.springframework.tests.sample.beans; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; /** * @author Juergen Hoeller diff --git a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java index cee193825b8a..376d8a131072 100644 --- a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java +++ b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java index 4f1a60ad6759..602454760041 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.NotWritablePropertyException; import org.springframework.beans.NullValueInNestedPathException; import org.springframework.beans.PropertyValue; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.tests.sample.beans.FieldAccessBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java index 0c6b8ba82e94..67af3f30b972 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java @@ -48,11 +48,11 @@ import org.springframework.beans.propertyeditors.CustomCollectionEditor; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.beans.propertyeditors.StringTrimmerEditor; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.SerializablePerson; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.SerializablePerson; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.support.ResourceBundleMessageSource; import org.springframework.context.support.StaticMessageSource; @@ -1578,7 +1578,7 @@ public String getAsText() { assertThat(errors.getFieldError("array[0]").getCodes()[1]).isEqualTo("NOT_ROD.tb.array"); assertThat(errors.getFieldError("array[0]").getCodes()[2]).isEqualTo("NOT_ROD.array[0]"); assertThat(errors.getFieldError("array[0]").getCodes()[3]).isEqualTo("NOT_ROD.array"); - assertThat(errors.getFieldError("array[0]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.beans.test.fixtures.beans.DerivedTestBean"); + assertThat(errors.getFieldError("array[0]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.beans.testfixture.beans.DerivedTestBean"); assertThat(errors.getFieldError("array[0]").getCodes()[5]).isEqualTo("NOT_ROD"); assertThat(errors.getFieldValue("array[0]")).isEqualTo("arraya"); @@ -1588,7 +1588,7 @@ public String getAsText() { assertThat(errors.getFieldError("map[key1]").getCodes()[1]).isEqualTo("NOT_ROD.tb.map"); assertThat(errors.getFieldError("map[key1]").getCodes()[2]).isEqualTo("NOT_ROD.map[key1]"); assertThat(errors.getFieldError("map[key1]").getCodes()[3]).isEqualTo("NOT_ROD.map"); - assertThat(errors.getFieldError("map[key1]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.beans.test.fixtures.beans.TestBean"); + assertThat(errors.getFieldError("map[key1]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.beans.testfixture.beans.TestBean"); assertThat(errors.getFieldError("map[key1]").getCodes()[5]).isEqualTo("NOT_ROD"); assertThat(errors.getFieldErrorCount("map[key0]")).isEqualTo(1); @@ -1627,7 +1627,7 @@ public String getAsText() { assertThat(errors.getFieldError("map[key0]").getCodes()[3]).isEqualTo("NOT_NULL.map"); // This next code is only generated because of the registered editor, using the // registered type of the editor as guess for the content type of the collection. - assertThat(errors.getFieldError("map[key0]").getCodes()[4]).isEqualTo("NOT_NULL.org.springframework.beans.test.fixtures.beans.TestBean"); + assertThat(errors.getFieldError("map[key0]").getCodes()[4]).isEqualTo("NOT_NULL.org.springframework.beans.testfixture.beans.TestBean"); assertThat(errors.getFieldError("map[key0]").getCodes()[5]).isEqualTo("NOT_NULL"); } @@ -1658,7 +1658,7 @@ public String getAsText() { assertThat(errors.getFieldError("map[key0]").getCodes()[3]).isEqualTo("NOT_NULL.map"); // This next code is only generated because of the registered editor, using the // registered type of the editor as guess for the content type of the collection. - assertThat(errors.getFieldError("map[key0]").getCodes()[4]).isEqualTo("NOT_NULL.org.springframework.beans.test.fixtures.beans.TestBean"); + assertThat(errors.getFieldError("map[key0]").getCodes()[4]).isEqualTo("NOT_NULL.org.springframework.beans.testfixture.beans.TestBean"); assertThat(errors.getFieldError("map[key0]").getCodes()[5]).isEqualTo("NOT_NULL"); } @@ -1691,7 +1691,7 @@ public String getAsText() { assertThat(errors.getFieldError("array[0]").getCodes()[1]).isEqualTo("NOT_ROD.tb.array"); assertThat(errors.getFieldError("array[0]").getCodes()[2]).isEqualTo("NOT_ROD.array[0]"); assertThat(errors.getFieldError("array[0]").getCodes()[3]).isEqualTo("NOT_ROD.array"); - assertThat(errors.getFieldError("array[0]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.beans.test.fixtures.beans.DerivedTestBean"); + assertThat(errors.getFieldError("array[0]").getCodes()[4]).isEqualTo("NOT_ROD.org.springframework.beans.testfixture.beans.DerivedTestBean"); assertThat(errors.getFieldError("array[0]").getCodes()[5]).isEqualTo("NOT_ROD"); assertThat(errors.getFieldValue("array[0]")).isEqualTo("arraya"); } @@ -1783,6 +1783,7 @@ public void testAddAllErrors() { } @Test + @SuppressWarnings("unchecked") public void testBindingWithResortedList() { IndexedTestBean tb = new IndexedTestBean(); DataBinder binder = new DataBinder(tb, "tb"); @@ -2077,6 +2078,7 @@ public String getTitle() { return Title; } + @SuppressWarnings("unused") public void setTitle(String title) { Title = title; } @@ -2085,6 +2087,7 @@ public String getISBN() { return ISBN; } + @SuppressWarnings("unused") public void setISBN(String ISBN) { this.ISBN = ISBN; } @@ -2093,6 +2096,7 @@ public int getNInStock() { return nInStock; } + @SuppressWarnings("unused") public void setNInStock(int nInStock) { this.nInStock = nInStock; } @@ -2109,6 +2113,7 @@ public String getId() { return id; } + @SuppressWarnings("unused") public void setId(String id) { this.id = id; } @@ -2117,6 +2122,7 @@ public Optional getName() { return name; } + @SuppressWarnings("unused") public void setName(Optional name) { this.name = name; } diff --git a/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java b/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java index 91b1e9935752..01c06157a4b7 100644 --- a/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.validation.DefaultMessageCodesResolver.Format; import static org.assertj.core.api.Assertions.assertThat; @@ -47,7 +47,7 @@ public void shouldResolveFieldMessageCode() throws Exception { assertThat(codes).containsExactly( "errorCode.objectName.field", "errorCode.field", - "errorCode.org.springframework.beans.test.fixtures.beans.TestBean", + "errorCode.org.springframework.beans.testfixture.beans.TestBean", "errorCode"); } @@ -63,7 +63,7 @@ public void shouldResolveIndexedFieldMessageCode() throws Exception { "errorCode.a.b[3].c.d", "errorCode.a.b.c.d", "errorCode.d", - "errorCode.org.springframework.beans.test.fixtures.beans.TestBean", + "errorCode.org.springframework.beans.testfixture.beans.TestBean", "errorCode"); } @@ -84,7 +84,7 @@ public void shouldResolveFieldMessageCodeWithPrefix() throws Exception { assertThat(codes).containsExactly( "prefix.errorCode.objectName.field", "prefix.errorCode.field", - "prefix.errorCode.org.springframework.beans.test.fixtures.beans.TestBean", + "prefix.errorCode.org.springframework.beans.testfixture.beans.TestBean", "prefix.errorCode"); } @@ -96,7 +96,7 @@ public void shouldSupportNullPrefix() throws Exception { assertThat(codes).containsExactly( "errorCode.objectName.field", "errorCode.field", - "errorCode.org.springframework.beans.test.fixtures.beans.TestBean", + "errorCode.org.springframework.beans.testfixture.beans.TestBean", "errorCode"); } @@ -107,7 +107,7 @@ public void shouldSupportMalformedIndexField() throws Exception { assertThat(codes).containsExactly( "errorCode.objectName.field[", "errorCode.field[", - "errorCode.org.springframework.beans.test.fixtures.beans.TestBean", + "errorCode.org.springframework.beans.testfixture.beans.TestBean", "errorCode"); } @@ -138,7 +138,7 @@ public void shouldSupportFieldPostfixFormat() throws Exception { assertThat(codes).containsExactly( "objectName.field.errorCode", "field.errorCode", - "org.springframework.beans.test.fixtures.beans.TestBean.errorCode", + "org.springframework.beans.testfixture.beans.TestBean.errorCode", "errorCode"); } diff --git a/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java b/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java index b7cf77ba6202..0a027b95df43 100644 --- a/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java +++ b/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.lang.Nullable; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java index 575563881585..1af2d6dd3bae 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java @@ -25,7 +25,7 @@ import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor; import org.springframework.context.support.GenericApplicationContext; import org.springframework.scheduling.annotation.Async; diff --git a/spring-context/src/test/java/test/aspect/TwoAdviceAspect.java b/spring-context/src/test/java/test/aspect/TwoAdviceAspect.java index a1426d6aafb9..3e544072e4e5 100644 --- a/spring-context/src/test/java/test/aspect/TwoAdviceAspect.java +++ b/spring-context/src/test/java/test/aspect/TwoAdviceAspect.java @@ -26,12 +26,12 @@ public class TwoAdviceAspect { private int totalCalls; - @Around("execution(* org.springframework.beans.test.fixtures.beans.ITestBean.age())") + @Around("execution(* org.springframework.beans.testfixture.beans.ITestBean.age())") public int returnCallCount(ProceedingJoinPoint pjp) throws Exception { return totalCalls; } - @Before("execution(* org.springframework.beans.test.fixtures.beans.ITestBean.setAge(int)) && args(newAge)") + @Before("execution(* org.springframework.beans.testfixture.beans.ITestBean.setAge(int)) && args(newAge)") public void countSet(int newAge) throws Exception { ++totalCalls; } diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterAdviceBindingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterAdviceBindingTests.xml index 5ecde6ca491e..7b7b2f8808d6 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterAdviceBindingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterAdviceBindingTests.xml @@ -19,6 +19,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.xml index 5cc51680df52..796fcd4986c9 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.xml @@ -18,7 +18,7 @@ + pointcut="execution(org.springframework.beans.testfixture.beans.ITestBean[] *(..))"/> @@ -30,6 +30,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.xml index e665e0352503..8e8214617362 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.xml @@ -37,6 +37,6 @@ - + \ No newline at end of file diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceBindingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceBindingTests.xml index 8e68af9d1416..2aa4754ffa06 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceBindingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceBindingTests.xml @@ -17,6 +17,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceCircularTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceCircularTests.xml index f410271d7b34..e2380f0179b8 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceCircularTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AroundAdviceCircularTests.xml @@ -17,11 +17,11 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.xml index 1b140f9632a7..424716d9f1d0 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.xml @@ -85,6 +85,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.xml index baad9c68b561..056c8eff1ba8 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.xml @@ -5,11 +5,11 @@ - + + value="execution(org.springframework.beans.testfixture.beans.ITestBean[] org.springframework.beans.testfixture.beans.ITestBean.*(..))"/> diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.xml index 2cfba0956be8..3e3e9a69f6ff 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.xml @@ -7,9 +7,9 @@ - - - + + + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutTests.xml index 9f41524e6d30..a60d6c0727a0 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeanNamePointcutTests.xml @@ -21,15 +21,15 @@ - + - + - + - + @@ -55,9 +55,9 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeforeAdviceBindingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeforeAdviceBindingTests.xml index 19c4ce3bc8f9..bd0da186ebb3 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/BeforeAdviceBindingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/BeforeAdviceBindingTests.xml @@ -26,7 +26,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml index 7f74e47c7cfd..96779df33382 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml @@ -8,7 +8,7 @@ @@ -22,6 +22,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.xml index 7c46bcce08eb..ade5ce1961b8 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingTests.xml index ac9665408379..b146694936e6 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingTests.xml @@ -8,12 +8,12 @@ + expression="execution(* org.springframework.beans.testfixture.beans.TestBean.*(..)) and this(bean) and args(argument)"/> - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests-ambiguous.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests-ambiguous.xml index 0b5aa6944ccf..ff428b871856 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests-ambiguous.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests-ambiguous.xml @@ -15,6 +15,6 @@ - + \ No newline at end of file diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests.xml index 13e4f86a9833..df9bfadc8ebc 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/OverloadedAdviceTests.xml @@ -16,6 +16,6 @@ - + \ No newline at end of file diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests-context.xml index 002466ec29a9..ffe4eac1aa18 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests-context.xml @@ -13,7 +13,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspects.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspects.xml index c6a0ff0a777b..e390f0737390 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspects.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspects.xml @@ -23,11 +23,11 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsPlusAdvisor.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsPlusAdvisor.xml index ecd344e78e94..62515c21814e 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsPlusAdvisor.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsPlusAdvisor.xml @@ -9,17 +9,17 @@ - + - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithAbstractBean.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithAbstractBean.xml index be0cb20777aa..d4d66d8c9bc5 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithAbstractBean.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithAbstractBean.xml @@ -19,7 +19,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithOrdering.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithOrdering.xml index e29fb7e28542..7760c65cc01c 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithOrdering.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithOrdering.xml @@ -17,7 +17,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-pertarget.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-pertarget.xml index dc1f1bb0787b..8f9d9bdd6956 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-pertarget.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-pertarget.xml @@ -10,12 +10,12 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml index eb7eed64d402..231038cafc57 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml @@ -7,7 +7,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml index f113cfe7169b..c8dcfe9ee967 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml @@ -9,7 +9,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml index d2064c698633..5bb345353cea 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml @@ -7,7 +7,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml index 9df7f552b09b..9202f08e8200 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml @@ -7,7 +7,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesInclude.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesInclude.xml index 5d804f663a07..b63bf5f5da97 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesInclude.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesInclude.xml @@ -18,7 +18,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesJoinPointAspect.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesJoinPointAspect.xml index 9b3669425e5a..1babdf85bb37 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesJoinPointAspect.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-usesJoinPointAspect.xml @@ -7,7 +7,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests-context.xml index 50415ee73774..4e5a8f826d3a 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests-context.xml @@ -5,7 +5,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-aspectj.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-aspectj.xml index 231c290f60ed..aec87459fddb 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-aspectj.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-aspectj.xml @@ -22,7 +22,7 @@ class="org.springframework.aop.aspectj.autoproxy.benchmark.TraceAspect" > - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-springAop.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-springAop.xml index 486d65bfc52e..ec543f9b7187 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-springAop.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests-springAop.xml @@ -31,7 +31,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-error.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-error.xml index c3358ad7bfbb..a400f7118088 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-error.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-error.xml @@ -19,7 +19,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-ok.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-ok.xml index b9f74dac0c9c..4a290477bb9d 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-ok.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests-ok.xml @@ -20,7 +20,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-error.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-error.xml index dcbc2f7e1815..d91aeeb0fe5f 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-error.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-error.xml @@ -16,7 +16,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-ok.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-ok.xml index b6fbab330c95..fd3825157fc3 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-ok.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests-ok.xml @@ -16,7 +16,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests-context.xml index 83a496efa5b8..e64f25a3fc23 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests-context.xml @@ -23,7 +23,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-error.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-error.xml index aff7923afb0b..7fdfd981e510 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-error.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-error.xml @@ -15,7 +15,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-ok.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-ok.xml index 1d16230fdf85..d50e3d862b06 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-ok.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerReturningTests-ok.xml @@ -15,7 +15,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerTests-context.xml index 0757bdc261ef..3929abd30765 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerTests-context.xml @@ -23,7 +23,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-error.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-error.xml index 19151e25d9be..3a940b46a481 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-error.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-error.xml @@ -15,7 +15,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-ok.xml b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-ok.xml index 69bda253a19f..a203d7811630 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-ok.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerThrowingTests-ok.xml @@ -15,7 +15,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml index 31327e7da584..9d25bab05948 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml @@ -5,13 +5,13 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - + - + - + @@ -20,7 +20,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-autowiring.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-autowiring.xml index ff14f489b7d4..190687da043d 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-autowiring.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-autowiring.xml @@ -8,7 +8,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml index edd3e72571fc..b7eaa18ef82c 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml @@ -4,7 +4,7 @@ - + custom 666 @@ -12,7 +12,7 @@ - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean debugInterceptor @@ -27,7 +27,7 @@ Aspect interfaces don't need to be included here. They may, for example, be added by global interceptors. --> - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean countingBeforeAdvice,adamTargetSource @@ -42,7 +42,7 @@ - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean adam diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-frozen.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-frozen.xml index e365c73fd9db..a8883db6820e 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-frozen.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-frozen.xml @@ -4,7 +4,7 @@ - + custom 666 @@ -16,7 +16,7 @@ - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean debugInterceptor diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-inner-bean-target.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-inner-bean-target.xml index 67345999ad25..9d73fe7899d6 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-inner-bean-target.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-inner-bean-target.xml @@ -16,7 +16,7 @@ class="org.springframework.aop.framework.ProxyFactoryBean" > - + innerBeanTarget diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-invalid.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-invalid.xml index ed2ba7dc1cb8..0224d4c823e0 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-invalid.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-invalid.xml @@ -5,7 +5,7 @@ - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean @@ -14,7 +14,7 @@ Must have target after *. --> - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean global* diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-notlast-targetsource.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-notlast-targetsource.xml index 3141c7ffc83f..88a2d4cc718b 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-notlast-targetsource.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-notlast-targetsource.xml @@ -9,7 +9,7 @@ - + Adam @@ -23,7 +23,7 @@ --> - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean adam,countingBeforeAdvice diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-prototype.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-prototype.xml index fa09e6b416c3..f66cd13a4770 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-prototype.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-prototype.xml @@ -7,11 +7,11 @@ - + 10 - + 10 diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-serialization.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-serialization.xml index 86933697ba84..b8416580d691 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-serialization.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-serialization.xml @@ -12,28 +12,28 @@ serializableNopInterceptor - org.springframework.beans.test.fixtures.beans.Person + org.springframework.beans.testfixture.beans.Person - + serializableSingleton - + serializablePrototype serializableNopInterceptor,prototypeTarget - org.springframework.beans.test.fixtures.beans.Person + org.springframework.beans.testfixture.beans.Person false nopInterceptor - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml index e4df8653c776..46fb7b112d34 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml @@ -8,7 +8,7 @@ - + Adam @@ -49,7 +49,7 @@ --> - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean nopInterceptor,unsupportedInterceptor diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-with-bpp.xml b/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-with-bpp.xml index 7d66aec58476..358f83035636 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-with-bpp.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-with-bpp.xml @@ -3,7 +3,7 @@ - + @@ -12,7 +12,7 @@ - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean simpleBeforeAdviceAdvisor,testBeanTarget diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-without-bpp.xml b/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-without-bpp.xml index a6b51baf38b1..418c8955cb2f 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-without-bpp.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests-without-bpp.xml @@ -3,7 +3,7 @@ - + @@ -12,7 +12,7 @@ - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean simpleBeforeAdviceAdvisor,testBeanTarget diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml index 2a06a46d7d2c..b5db44fbac4c 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml @@ -33,11 +33,11 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-custom-targetsource.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-custom-targetsource.xml index ddabde322af7..a596c404ef46 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-custom-targetsource.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-custom-targetsource.xml @@ -12,22 +12,22 @@ - + Rod - + Rod - + Rod - + Kerry diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml index 8c2df4bcb022..20adb97333cc 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml @@ -3,7 +3,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-quick-targetsource.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-quick-targetsource.xml index 8294fff16bea..6b34f7975285 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-quick-targetsource.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-quick-targetsource.xml @@ -14,29 +14,29 @@ - + Rod - + Kerry - + Rod - + Rod - + Rod diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests-context.xml index c5a497646f08..f6d209698675 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests-context.xml @@ -24,6 +24,6 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml index 9b9c9bd2e9eb..3a228ff01db5 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml @@ -73,11 +73,11 @@ - + introductionUsingJdk - + second-introductionUsingJdk @@ -88,29 +88,29 @@ lazy-init="true"> - + jdk1 - + - + cglib1 - + onlyJdk - + doubleJdk - + noproxy diff --git a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-list.xml b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-list.xml index 72c913aad664..011fad243adf 100644 --- a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-list.xml +++ b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-list.xml @@ -9,7 +9,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml index ac7df01af81f..26892681e278 100644 --- a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml +++ b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> - + diff --git a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-testbean.xml b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-testbean.xml index c580a34580b3..62e23b517ac2 100644 --- a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-testbean.xml +++ b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-testbean.xml @@ -3,7 +3,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceTests-context.xml index 95922d4e0337..f83897a3f0ba 100644 --- a/spring-context/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceTests-context.xml @@ -3,7 +3,7 @@ - + 10 @@ -42,7 +42,7 @@ - + prototypePerson diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests-context.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests-context.xml index 2d780083d690..9f753da0b557 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests-context.xml @@ -22,7 +22,7 @@ interceptor - + Jenny 30 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-autowire.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-autowire.xml index 27c17dbce59c..54c25f542b91 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-autowire.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-autowire.xml @@ -3,19 +3,19 @@ - + - + - + - + @@ -31,12 +31,12 @@ - - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-child.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-child.xml index 2010652c0460..e2e43b3f6e9a 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-child.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-child.xml @@ -8,13 +8,13 @@ - override - override @@ -42,7 +42,7 @@ - + myname diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-collections.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-collections.xml index 468e027e5e62..c1af44a6e7d1 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-collections.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-collections.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - + Jenny 30 @@ -12,7 +12,7 @@ - + Simple bean, without any collections. @@ -23,7 +23,7 @@ 27 - + Rod 32 @@ -35,7 +35,7 @@ - + Jenny 30 @@ -44,12 +44,12 @@ - + David 27 - + Rod 32 @@ -63,7 +63,7 @@ - + loner 26 @@ -97,26 +97,26 @@ - + verbose - + - + - + - + @@ -126,7 +126,7 @@ - + @@ -158,7 +158,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -199,7 +199,7 @@ - + @@ -207,7 +207,7 @@ - + bar @@ -217,7 +217,7 @@ - + @@ -225,7 +225,7 @@ - + bar @@ -234,7 +234,7 @@ - + @@ -243,7 +243,7 @@ - + one @@ -252,7 +252,7 @@ - + java.lang.String @@ -261,7 +261,7 @@ - + 0 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-complexFactoryCircle.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-complexFactoryCircle.xml index 5b2b7da536dc..b5ad92e9ac0a 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-complexFactoryCircle.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-complexFactoryCircle.xml @@ -11,16 +11,16 @@ - + - + - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorArg.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorArg.xml index f9b1f979dbc5..099305bddd76 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorArg.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorArg.xml @@ -13,7 +13,7 @@ - + @@ -117,7 +117,7 @@ - + Kerry1 @@ -126,7 +126,7 @@ - + Kerry2 @@ -135,7 +135,7 @@ - + /test @@ -187,13 +187,13 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml index 7fcdaa785e85..0c2fc310727f 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml @@ -18,7 +18,7 @@ - Jenny 30 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultAutowire.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultAutowire.xml index 10357e8ae7c5..778369a127a8 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultAutowire.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultAutowire.xml @@ -3,19 +3,19 @@ - + - + - + - + Kerry diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultLazyInit.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultLazyInit.xml index eccba590a25b..8266a050aaae 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultLazyInit.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-defaultLazyInit.xml @@ -15,6 +15,6 @@ destroy-method="customDestroy" /> - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml index f5a896a8a396..175408a2cb39 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml @@ -58,7 +58,7 @@ - Jenny 30 @@ -68,7 +68,7 @@ - Simple bean, without any collections. diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-factoryCircle.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-factoryCircle.xml index d7b39e4d7572..77fab13244e2 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-factoryCircle.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-factoryCircle.xml @@ -3,7 +3,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-initializers.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-initializers.xml index b082cb757d6b..3c3bc613c69d 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-initializers.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-initializers.xml @@ -11,7 +11,7 @@ - - + Jenny 30 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml index d4940de54e80..e88d1667d3c7 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml @@ -11,7 +11,7 @@ - + Jenny 30 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-localCollectionsUsingXsd.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-localCollectionsUsingXsd.xml index e34567d283d3..51a9be97732d 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-localCollectionsUsingXsd.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-localCollectionsUsingXsd.xml @@ -12,7 +12,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-overrides.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-overrides.xml index 96decab1c688..210538136b73 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-overrides.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-overrides.xml @@ -35,32 +35,32 @@ - + Jenny 30 - + - + Jenny 30 - + - + - + Simple bean, without any collections. @@ -71,12 +71,12 @@ 27 - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-parent.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-parent.xml index 7b4a0a00d720..3f6f14fff2fc 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-parent.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-parent.xml @@ -3,7 +3,7 @@ - + parent 1 @@ -13,11 +13,11 @@ 1 - + parent 2 - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml index 9497d2622661..d2933467d64e 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-reftypes.xml @@ -1,121 +1,121 @@ - + Jenny 30 - + - + - + - + - + - + - + - + Andrew 36 - + - + Georgia 33 - + - + - + - + - + - + - + - + - + - + outer 0 - + hasInner 5 - + inner1 6 - + inner2 7 - - + + inner5 6 @@ -124,7 +124,7 @@ - + inner3 8 @@ -139,41 +139,41 @@ - + - + inner1 6 - + - + inner1 6 - + hasInner 5 - + inner1 6 - + inner2 7 - - + + inner5 6 @@ -181,11 +181,11 @@ - + - + inner3 8 @@ -201,9 +201,9 @@ - + - + inner1 6 diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNameInAlias.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNameInAlias.xml index 843f46bf064c..333f448615ce 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNameInAlias.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNameInAlias.xml @@ -3,8 +3,8 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNames.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNames.xml index 996faed7f3a5..84f4ca25f504 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNames.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-testWithDuplicateNames.xml @@ -3,8 +3,8 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerWithExpressionLanguageTests.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerWithExpressionLanguageTests.xml index 081c8b20f893..fcb71786431e 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerWithExpressionLanguageTests.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerWithExpressionLanguageTests.xml @@ -4,8 +4,8 @@ xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests-context.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests-context.xml index eccc3bfd0eff..8962b3661ded 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests-context.xml @@ -10,11 +10,11 @@ - + - + @@ -24,14 +24,14 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-collections.xml b/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-collections.xml index 7077cad2d41e..7430fc403388 100644 --- a/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-collections.xml +++ b/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-collections.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - + Jenny 30 @@ -12,7 +12,7 @@ - + Simple bean, without any collections. @@ -23,7 +23,7 @@ 27 - + Rod 32 @@ -35,7 +35,7 @@ - + Jenny 30 @@ -44,12 +44,12 @@ - + David 27 - + Rod 32 @@ -63,7 +63,7 @@ - + loner 26 @@ -97,26 +97,26 @@ - + verbose - + - + - + - + @@ -126,7 +126,7 @@ - + @@ -158,7 +158,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -199,7 +199,7 @@ - + @@ -207,7 +207,7 @@ - + bar @@ -217,7 +217,7 @@ - + @@ -225,7 +225,7 @@ - + bar @@ -234,7 +234,7 @@ - + @@ -243,7 +243,7 @@ - + one @@ -252,7 +252,7 @@ - + java.lang.String @@ -261,7 +261,7 @@ - + 0 diff --git a/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-parent.xml b/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-parent.xml index 5fc26275c136..83fc1bc7d491 100644 --- a/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-parent.xml +++ b/spring-context/src/test/resources/org/springframework/context/access/ContextJndiBeanFactoryLocatorTests-parent.xml @@ -3,7 +3,7 @@ - + parent 1 @@ -13,11 +13,11 @@ 1 - + parent 2 - + diff --git a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties index 3184784ef563..6c65636918cc 100644 --- a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties +++ b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties @@ -1 +1 @@ -propertiesDeclaredBean.(class)=org.springframework.beans.test.fixtures.beans.TestBean \ No newline at end of file +propertiesDeclaredBean.(class)=org.springframework.beans.testfixture.beans.TestBean \ No newline at end of file diff --git a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml index 1fcb8662b2bf..015651eeb7ff 100644 --- a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml +++ b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlWithAopNamespace-context.xml b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlWithAopNamespace-context.xml index d81a474dd281..85d3501181c8 100644 --- a/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlWithAopNamespace-context.xml +++ b/spring-context/src/test/resources/org/springframework/context/annotation/configuration/ImportXmlWithAopNamespace-context.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-context/src/test/resources/org/springframework/context/support/simpleThreadScopeTests.xml b/spring-context/src/test/resources/org/springframework/context/support/simpleThreadScopeTests.xml index 62d21b908f9a..a8200730794d 100644 --- a/spring-context/src/test/resources/org/springframework/context/support/simpleThreadScopeTests.xml +++ b/spring-context/src/test/resources/org/springframework/context/support/simpleThreadScopeTests.xml @@ -14,34 +14,34 @@ - + + business-interface="org.springframework.beans.testfixture.beans.ITestBean"/> @@ -54,15 +54,15 @@ + business-interface="org.springframework.beans.testfixture.beans.ITestBean"/> foo=bar @@ -71,8 +71,8 @@ + business-interface="org.springframework.beans.testfixture.beans.ITestBean" lazy-init="true" /> + business-interface="org.springframework.beans.testfixture.beans.ITestBean" lazy-init="true" /> diff --git a/spring-context/src/test/resources/org/springframework/scripting/bsh/MessengerImpl.bsh b/spring-context/src/test/resources/org/springframework/scripting/bsh/MessengerImpl.bsh index 7129a63d5440..2878b713b558 100644 --- a/spring-context/src/test/resources/org/springframework/scripting/bsh/MessengerImpl.bsh +++ b/spring-context/src/test/resources/org/springframework/scripting/bsh/MessengerImpl.bsh @@ -1,4 +1,4 @@ -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.scripting.TestBeanAwareMessenger; public class MyMessenger implements TestBeanAwareMessenger { diff --git a/spring-context/src/test/resources/org/springframework/scripting/bsh/bsh-with-xsd.xml b/spring-context/src/test/resources/org/springframework/scripting/bsh/bsh-with-xsd.xml index 5c45b921de8b..44311c2c14df 100644 --- a/spring-context/src/test/resources/org/springframework/scripting/bsh/bsh-with-xsd.xml +++ b/spring-context/src/test/resources/org/springframework/scripting/bsh/bsh-with-xsd.xml @@ -35,7 +35,7 @@ autowire="byName" init-method="init" destroy-method="destroy"> - + diff --git a/spring-context/src/test/resources/org/springframework/scripting/groovy/ScriptBean.groovy b/spring-context/src/test/resources/org/springframework/scripting/groovy/ScriptBean.groovy index d65f08fe37be..a3d64aa0f319 100644 --- a/spring-context/src/test/resources/org/springframework/scripting/groovy/ScriptBean.groovy +++ b/spring-context/src/test/resources/org/springframework/scripting/groovy/ScriptBean.groovy @@ -1,6 +1,6 @@ package org.springframework.scripting.groovy; -import org.springframework.beans.test.fixtures.beans.TestBean +import org.springframework.beans.testfixture.beans.TestBean import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware import org.springframework.scripting.ContextScriptBean diff --git a/spring-context/src/test/resources/org/springframework/scripting/groovy/groovy-multiple-properties.xml b/spring-context/src/test/resources/org/springframework/scripting/groovy/groovy-multiple-properties.xml index 26760d2997ef..4f663dd3e35f 100644 --- a/spring-context/src/test/resources/org/springframework/scripting/groovy/groovy-multiple-properties.xml +++ b/spring-context/src/test/resources/org/springframework/scripting/groovy/groovy-multiple-properties.xml @@ -19,6 +19,6 @@ - + diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/AbstractApplicationContextTests.java b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/AbstractApplicationContextTests.java index dd7baafac3c1..929c804943b5 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/AbstractApplicationContextTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/AbstractApplicationContextTests.java @@ -26,9 +26,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.test.fixtures.beans.LifecycleBean; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.factory.xml.AbstractListableBeanFactoryTests; +import org.springframework.beans.testfixture.beans.LifecycleBean; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.factory.xml.AbstractListableBeanFactoryTests; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java index 2031d4acf8b8..dd849029b9d7 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.jdbc.datasource.SingleConnectionDataSource; import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java index b95761476f64..7abd2fc56a8a 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java index da9652683479..36ecd71bc49e 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; @@ -49,7 +49,7 @@ public void testValid() throws Exception { given(resultSet.next()).willReturn(true, true, false); given(resultSet.getString(1)).willReturn("one", "one"); given(resultSet.getString(2)).willReturn("(class)", "age"); - given(resultSet.getString(3)).willReturn("org.springframework.beans.test.fixtures.beans.TestBean", "53"); + given(resultSet.getString(3)).willReturn("org.springframework.beans.testfixture.beans.TestBean", "53"); Statement statement = mock(Statement.class); given(statement.executeQuery(sql)).willReturn(resultSet); diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java index 86920c2c52b2..ec5d566222fa 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java @@ -38,7 +38,7 @@ import org.springframework.beans.factory.parsing.PassThroughSourceExtractor; import org.springframework.beans.factory.parsing.ReaderEventListener; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.Phased; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.jca.endpoint.GenericMessageEndpointManager; diff --git a/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java b/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java index e85f771cb89b..49ce0eeb6b92 100644 --- a/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java @@ -35,8 +35,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.jms.support.converter.MessageConversionException; import org.springframework.jms.support.converter.SimpleMessageConverter; import org.springframework.remoting.RemoteTimeoutException; diff --git a/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml b/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml index 79711ceb07fa..46d15b9eef58 100644 --- a/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml +++ b/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml @@ -76,9 +76,9 @@ - + - + diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/domain/Person.java b/spring-orm/src/test/java/org/springframework/orm/jpa/domain/Person.java index df2e48fdc103..1586a2c25017 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/domain/Person.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/domain/Person.java @@ -27,7 +27,7 @@ import javax.persistence.JoinColumn; import javax.persistence.OneToOne; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; /** diff --git a/spring-orm/src/test/resources/org/springframework/orm/jpa/domain/persistence-multi.xml b/spring-orm/src/test/resources/org/springframework/orm/jpa/domain/persistence-multi.xml index 082a1b1932a8..7a78f215ab21 100644 --- a/spring-orm/src/test/resources/org/springframework/orm/jpa/domain/persistence-multi.xml +++ b/spring-orm/src/test/resources/org/springframework/orm/jpa/domain/persistence-multi.xml @@ -9,7 +9,7 @@ - org.springframework.beans.test.fixtures.beans.TestBean + org.springframework.beans.testfixture.beans.TestBean diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests.java index 793ae833f225..3f61e2daec69 100644 --- a/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextLoader; import org.springframework.test.context.junit4.PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests; diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests.java b/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests.java index 8faf721a1dfd..1e6dd9f3abcd 100644 --- a/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextLoader; import org.springframework.test.context.junit4.PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests; diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ActiveProfilesInterfaceTests.java b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ActiveProfilesInterfaceTests.java index e12e08f6215a..cd825484f763 100644 --- a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ActiveProfilesInterfaceTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ActiveProfilesInterfaceTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationInterfaceTests.java b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationInterfaceTests.java index f1fdd2530d23..fc8b8c9353ef 100644 --- a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationInterfaceTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationInterfaceTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationTestInterface.java b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationTestInterface.java index 2032969f925a..8ef86beafa29 100644 --- a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationTestInterface.java +++ b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/ContextConfigurationTestInterface.java @@ -16,7 +16,7 @@ package org.springframework.test.context.configuration.interfaces; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.configuration.interfaces.ContextConfigurationTestInterface.Config; diff --git a/spring-test/src/test/java/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTests.java index ad183ac27b90..a4752ecfc9b7 100644 --- a/spring-test/src/test/java/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTests.java @@ -19,8 +19,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java b/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java index 62bc6b646bbf..aa713d62c593 100644 --- a/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java @@ -18,8 +18,8 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.context.support.GenericGroovyApplicationContext; diff --git a/spring-test/src/test/java/org/springframework/test/context/groovy/GroovySpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/groovy/GroovySpringContextTests.java index 69b6398b51aa..ae020512502a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/groovy/GroovySpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/groovy/GroovySpringContextTests.java @@ -24,8 +24,8 @@ import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/spring-test/src/test/java/org/springframework/test/context/groovy/MixedXmlAndGroovySpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/groovy/MixedXmlAndGroovySpringContextTests.java index a6f9da717483..9acb59688d37 100644 --- a/spring-test/src/test/java/org/springframework/test/context/groovy/MixedXmlAndGroovySpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/groovy/MixedXmlAndGroovySpringContextTests.java @@ -20,8 +20,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java index 1c0a5ebec49c..5112f3770d35 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java @@ -25,8 +25,8 @@ import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/CustomDefaultContextLoaderClassSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/CustomDefaultContextLoaderClassSpringRunnerTests.java index 44630b7c30ac..64b0391b8964 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/CustomDefaultContextLoaderClassSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/CustomDefaultContextLoaderClassSpringRunnerTests.java @@ -20,7 +20,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.BootstrapWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextLoader; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java index 6bb02c2bb383..20b2307ab83c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java @@ -28,8 +28,8 @@ import org.junit.runners.Parameterized.Parameters; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestContextManager; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests.java index d857b3efba0e..9dfacdea5457 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests.java @@ -22,7 +22,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.support.GenericPropertiesContextLoader; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java index 4b9a30782cd6..4f17e973e110 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java @@ -28,8 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/BeanOverridingDefaultConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/BeanOverridingDefaultConfigClassesInheritedTests.java index 76e976a4d8ef..9e0b2378dd97 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/BeanOverridingDefaultConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/BeanOverridingDefaultConfigClassesInheritedTests.java @@ -18,7 +18,7 @@ import org.junit.Test; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesBaseTests.java index 3379b6dac9db..557e37eaeeae 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesBaseTests.java @@ -20,7 +20,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesInheritedTests.java index 94a39e042711..9604c8f520f3 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultConfigClassesInheritedTests.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderBeanOverridingDefaultConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderBeanOverridingDefaultConfigClassesInheritedTests.java index af2e2fbd4fb7..e530a99ee48b 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderBeanOverridingDefaultConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderBeanOverridingDefaultConfigClassesInheritedTests.java @@ -18,7 +18,7 @@ import org.junit.Test; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesBaseTests.java index 5a83e9743aa5..b032b6e4bca2 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesBaseTests.java @@ -20,7 +20,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesInheritedTests.java index 6b8ef56dc2c4..780791bdc441 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderDefaultConfigClassesInheritedTests.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesBaseTests.java index be882d7fe112..aa0d8ab54a1d 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesBaseTests.java @@ -20,7 +20,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DelegatingSmartContextLoader; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesInheritedTests.java index 1c8534d762e7..3166a6e0b30a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/DefaultLoaderExplicitConfigClassesInheritedTests.java @@ -20,7 +20,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DelegatingSmartContextLoader; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesBaseTests.java index fb84053a80cc..8660f67e9547 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesBaseTests.java @@ -20,7 +20,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesInheritedTests.java index db8f9dceeeb1..3e48c6f6c3d5 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/ExplicitConfigClassesInheritedTests.java @@ -20,7 +20,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/PojoAndStringConfig.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/PojoAndStringConfig.java index 35f923e33f63..8de202408efd 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/PojoAndStringConfig.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/PojoAndStringConfig.java @@ -16,8 +16,8 @@ package org.springframework.test.context.junit4.annotation; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/meta/ConfigClassesAndProfilesWithCustomDefaultsMetaConfigWithOverridesTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/meta/ConfigClassesAndProfilesWithCustomDefaultsMetaConfigWithOverridesTests.java index 2e55003a3596..d305da8a769b 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/meta/ConfigClassesAndProfilesWithCustomDefaultsMetaConfigWithOverridesTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/annotation/meta/ConfigClassesAndProfilesWithCustomDefaultsMetaConfigWithOverridesTests.java @@ -20,8 +20,8 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.annotation.PojoAndStringConfig; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileAnnotationConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileAnnotationConfigTests.java index d55bd479d952..6e6fed937dc1 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileAnnotationConfigTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileAnnotationConfigTests.java @@ -20,8 +20,8 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileConfig.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileConfig.java index 3fc8d23c5b8d..67fefb771999 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileConfig.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DefaultProfileConfig.java @@ -16,7 +16,7 @@ package org.springframework.test.context.junit4.profile.annotation; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileConfig.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileConfig.java index c0a1bcf87b1c..c8a964ce7acd 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileConfig.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileConfig.java @@ -16,7 +16,7 @@ package org.springframework.test.context.junit4.profile.annotation; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileAnnotationConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileAnnotationConfigTests.java index 4492b9edca75..73b57ef93d19 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileAnnotationConfigTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileAnnotationConfigTests.java @@ -20,8 +20,8 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileConfig.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileConfig.java index a37a9172a554..f07511b8943c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileConfig.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/importresource/DefaultProfileConfig.java @@ -16,7 +16,7 @@ package org.springframework.test.context.junit4.profile.importresource; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests.java index 8663a2fb3c5a..d9effe2223ff 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests.java @@ -20,8 +20,8 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/rules/ParameterizedSpringRuleTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/rules/ParameterizedSpringRuleTests.java index 0b36a0aaeaf7..05fd6a6b966a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/rules/ParameterizedSpringRuleTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/rules/ParameterizedSpringRuleTests.java @@ -29,8 +29,8 @@ import org.junit.runners.Parameterized.Parameters; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests.java index 5d9cc7397575..53237025c6a3 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests.java @@ -20,7 +20,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests.java index 10b0a0f8b31c..3c395d52fb21 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsBaseTests.java index 0ef3e0837197..ec9dafbbc918 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsBaseTests.java @@ -20,7 +20,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsInheritedTests.java index 5471e91fea7b..3bdd96fb2d50 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/ExplicitLocationsInheritedTests.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java index 6c53bf67946b..e31eb93fbf1d 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java @@ -24,7 +24,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.test.annotation.DirtiesContext; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java index d549cadee217..12fa85b60392 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java @@ -20,7 +20,7 @@ import org.junit.Before; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java index 013073531f69..2be7df700411 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java @@ -20,7 +20,7 @@ import org.junit.Before; -import org.springframework.beans.test.fixtures.beans.Employee; +import org.springframework.beans.testfixture.beans.Employee; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.java index 5cbbcc10e18c..f36352cc9ffe 100644 --- a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.java @@ -19,8 +19,8 @@ import org.testng.annotations.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java index 76b8df9b0aa8..eadcee96e89f 100644 --- a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java @@ -25,8 +25,8 @@ import org.testng.annotations.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.DataSourceTransactionManager; diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java index d4ec8757dbfe..3da61007d1ee 100644 --- a/spring-test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java @@ -27,8 +27,8 @@ import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.Employee; -import org.springframework.beans.test.fixtures.beans.Pet; +import org.springframework.beans.testfixture.beans.Employee; +import org.springframework.beans.testfixture.beans.Pet; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; diff --git a/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java b/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java index 6ef0062c2503..70568f3e78bc 100644 --- a/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpSession; import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; diff --git a/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests-context.properties b/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests-context.properties index ffd5b893819c..3ad2eceb30a6 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests-context.properties +++ b/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests-context.properties @@ -1,4 +1,4 @@ -dog.(class)=org.springframework.beans.test.fixtures.beans.Pet +dog.(class)=org.springframework.beans.testfixture.beans.Pet dog.$0=Fido testString2.(class)=java.lang.String diff --git a/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests-context.properties b/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests-context.properties index ffd5b893819c..3ad2eceb30a6 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests-context.properties +++ b/spring-test/src/test/resources/org/springframework/test/context/configuration/ContextConfigurationWithPropertiesExtendingPropertiesTests-context.properties @@ -1,4 +1,4 @@ -dog.(class)=org.springframework.beans.test.fixtures.beans.Pet +dog.(class)=org.springframework.beans.testfixture.beans.Pet dog.$0=Fido testString2.(class)=java.lang.String diff --git a/spring-test/src/test/resources/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTestsContext.groovy b/spring-test/src/test/resources/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTestsContext.groovy index a74895df75f4..0de7dbfe4c82 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTestsContext.groovy +++ b/spring-test/src/test/resources/org/springframework/test/context/groovy/DefaultScriptDetectionGroovySpringContextTestsContext.groovy @@ -16,8 +16,8 @@ package org.springframework.test.context.groovy -import org.springframework.beans.test.fixtures.beans.Employee -import org.springframework.beans.test.fixtures.beans.Pet +import org.springframework.beans.testfixture.beans.Employee +import org.springframework.beans.testfixture.beans.Pet /** * Groovy script for defining Spring beans for integration tests. diff --git a/spring-test/src/test/resources/org/springframework/test/context/groovy/context.groovy b/spring-test/src/test/resources/org/springframework/test/context/groovy/context.groovy index a74895df75f4..0de7dbfe4c82 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/groovy/context.groovy +++ b/spring-test/src/test/resources/org/springframework/test/context/groovy/context.groovy @@ -16,8 +16,8 @@ package org.springframework.test.context.groovy -import org.springframework.beans.test.fixtures.beans.Employee -import org.springframework.beans.test.fixtures.beans.Pet +import org.springframework.beans.testfixture.beans.Employee +import org.springframework.beans.testfixture.beans.Pet /** * Groovy script for defining Spring beans for integration tests. diff --git a/spring-test/src/test/resources/org/springframework/test/context/groovy/contextB.xml b/spring-test/src/test/resources/org/springframework/test/context/groovy/contextB.xml index aedba0f9a28c..aaf978b355b5 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/groovy/contextB.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/groovy/contextB.xml @@ -2,13 +2,13 @@ - + - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests-context.xml index 2fc9fd86f63a..d014ce74d121 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests-context.xml @@ -10,13 +10,13 @@ - + - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context1.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context1.xml index ab039802a106..2a360ce41952 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context1.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context1.xml @@ -2,7 +2,7 @@ - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context2.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context2.xml index 9a6cc4f6ffea..fba7a99f223e 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context2.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context2.xml @@ -2,7 +2,7 @@ - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests-context.xml index 8f84022054da..8a9092812582 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests-context.xml @@ -2,19 +2,19 @@ - + - + - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests-context.properties b/spring-test/src/test/resources/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests-context.properties index 064e834d125b..dc2eae729a92 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests-context.properties +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests-context.properties @@ -1,4 +1,4 @@ -cat.(class)=org.springframework.beans.test.fixtures.beans.Pet +cat.(class)=org.springframework.beans.testfixture.beans.Pet cat.$0=Garfield testString.(class)=java.lang.String diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml index 79c065761763..5a836a426415 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml @@ -2,13 +2,13 @@ - + - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/importresource/import.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/importresource/import.xml index 76ae2046a3ba..46fb94224792 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/importresource/import.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/importresource/import.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests-context.xml index c1d81ead0116..f295ce7c84a1 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/profile/xml/DefaultProfileXmlConfigTests-context.xml @@ -2,12 +2,12 @@ - + - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests-context.xml index dcbba34d81be..63b0cfb65c5b 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests-context.xml @@ -2,7 +2,7 @@ - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests-context.xml index ab039802a106..2a360ce41952 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsBaseTests-context.xml @@ -2,7 +2,7 @@ - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests-context.xml index 9a6cc4f6ffea..fba7a99f223e 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/junit4/spr3896/DefaultLocationsInheritedTests-context.xml @@ -2,7 +2,7 @@ - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests-context.xml index 6888e059d76d..211e20f09d5f 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests-context.xml @@ -5,10 +5,10 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/jdbc https://www.springframework.org/schema/jdbc/spring-jdbc.xsd"> - - + diff --git a/spring-test/src/test/resources/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests-context.xml b/spring-test/src/test/resources/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests-context.xml index 73ba0a7094d1..b2e9e61c20b3 100644 --- a/spring-test/src/test/resources/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests-context.xml +++ b/spring-test/src/test/resources/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests-context.xml @@ -2,10 +2,10 @@ - + - + diff --git a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java index 5dab797e05a9..8d35509b2a1c 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java @@ -23,7 +23,7 @@ import org.springframework.beans.factory.parsing.ComponentDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener; +import org.springframework.beans.testfixture.beans.CollectingReaderEventListener; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java index e2eb6431db88..f3fd77f005b4 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.tests.transaction.CallCountingTransactionManager; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java index 33394fa04b7f..b478a6b8ec64 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.transaction.CannotCreateTransactionException; import org.springframework.transaction.MockCallbackPreferringTransactionManager; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java index bbb8a99b5f55..bf2f8012d0aa 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java @@ -31,9 +31,9 @@ import org.springframework.beans.FatalBeanException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.lang.Nullable; import org.springframework.tests.transaction.CallCountingTransactionManager; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java index d36b8d935268..9d39ed7c3159 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java @@ -16,7 +16,7 @@ package org.springframework.transaction.interceptor; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; /** * Test for CGLIB proxying that implements no interfaces diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java index 7b28446f7ada..c99774c71675 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java @@ -23,8 +23,8 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.GenericBeanDefinition; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; import org.springframework.tests.transaction.CallCountingTransactionManager; diff --git a/spring-tx/src/test/resources/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml b/spring-tx/src/test/resources/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml index 7be655a7962f..dba83011242a 100644 --- a/spring-tx/src/test/resources/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml +++ b/spring-tx/src/test/resources/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml @@ -4,7 +4,7 @@ - + custom 666 diff --git a/spring-tx/src/test/resources/org/springframework/transaction/interceptor/transactionalBeanFactory.xml b/spring-tx/src/test/resources/org/springframework/transaction/interceptor/transactionalBeanFactory.xml index d932173756f4..452024b92efa 100644 --- a/spring-tx/src/test/resources/org/springframework/transaction/interceptor/transactionalBeanFactory.xml +++ b/spring-tx/src/test/resources/org/springframework/transaction/interceptor/transactionalBeanFactory.xml @@ -3,12 +3,12 @@ - + dependency - + custom 666 @@ -22,16 +22,16 @@ - org.springframework.beans.test.fixtures.beans.ITestBean.s*=PROPAGATION_MANDATORY - org.springframework.beans.test.fixtures.beans.AgeHolder.setAg*=PROPAGATION_REQUIRED - org.springframework.beans.test.fixtures.beans.ITestBean.set*= PROPAGATION_SUPPORTS , readOnly + org.springframework.beans.testfixture.beans.ITestBean.s*=PROPAGATION_MANDATORY + org.springframework.beans.testfixture.beans.AgeHolder.setAg*=PROPAGATION_REQUIRED + org.springframework.beans.testfixture.beans.ITestBean.set*= PROPAGATION_SUPPORTS , readOnly - org.springframework.beans.test.fixtures.beans.ITestBean + org.springframework.beans.testfixture.beans.ITestBean diff --git a/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml b/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml index 414adf58af5d..8e3b2411fdae 100644 --- a/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml +++ b/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml @@ -28,6 +28,6 @@ - + diff --git a/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java b/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java index 6d1291e43359..58d1846bcf4a 100644 --- a/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java +++ b/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java @@ -24,8 +24,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.remoting.RemoteAccessException; import org.springframework.util.SocketUtils; diff --git a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java index 39625545d809..cbb8eda58ffa 100644 --- a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java +++ b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java @@ -37,8 +37,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanClassLoaderAware; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.remoting.RemoteAccessException; diff --git a/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java b/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java index 91926d3f1612..80e098ba1301 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.validation.BindException; import org.springframework.validation.Errors; import org.springframework.validation.FieldError; diff --git a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java index b3cbcd011df4..3a2c729fc3ee 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java @@ -25,8 +25,8 @@ import org.springframework.beans.PropertyValue; import org.springframework.beans.PropertyValues; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java index 276696053f60..57382b940705 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java @@ -26,8 +26,8 @@ import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java index 74b534489809..62dc077ad024 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java @@ -27,8 +27,8 @@ import org.springframework.beans.PropertyValue; import org.springframework.beans.PropertyValues; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockMultipartFile; import org.springframework.mock.web.test.MockMultipartHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java index 182f152de290..322ca97a63a5 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.StaticWebApplicationContext; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java index ac6227ce96f3..37a98e46c8ed 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java @@ -25,8 +25,8 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.expression.StandardBeanExpressionResolver; import org.springframework.core.io.ClassPathResource; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java index 970064bc0bb2..6c705e3d9dff 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java @@ -24,10 +24,10 @@ import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; -import org.springframework.beans.test.fixtures.beans.factory.DummyFactory; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.beans.testfixture.beans.factory.DummyFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java index da0d226b9a2c..908c4db4242b 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java @@ -28,8 +28,8 @@ import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java index 28bd6d1a2c0f..6fffbb6c3a25 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.GenericBeanDefinition; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.context.ContextCleanupListener; diff --git a/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java b/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java index 05be6033aa5e..a03dac5a6bbb 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java @@ -21,8 +21,8 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigUtils; import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.context.WebApplicationContext; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java index 446eb39f12bc..7171fdd7e290 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java index 8a81bf01757e..269fc9dc8304 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.SessionAttributes; diff --git a/spring-web/src/test/resources/org/springframework/web/context/request/requestScopeTests.xml b/spring-web/src/test/resources/org/springframework/web/context/request/requestScopeTests.xml index cbc20b6107f6..826c5a87c411 100644 --- a/spring-web/src/test/resources/org/springframework/web/context/request/requestScopeTests.xml +++ b/spring-web/src/test/resources/org/springframework/web/context/request/requestScopeTests.xml @@ -4,35 +4,35 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> - + - + - + - + - + - + - + - + - + diff --git a/spring-web/src/test/resources/org/springframework/web/context/request/requestScopedProxyTests.xml b/spring-web/src/test/resources/org/springframework/web/context/request/requestScopedProxyTests.xml index e766b1f6f5b4..cafedde77d96 100644 --- a/spring-web/src/test/resources/org/springframework/web/context/request/requestScopedProxyTests.xml +++ b/spring-web/src/test/resources/org/springframework/web/context/request/requestScopedProxyTests.xml @@ -5,47 +5,47 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - + - + - + - + - + - + - + - + - + - + diff --git a/spring-web/src/test/resources/org/springframework/web/context/request/sessionScopeTests.xml b/spring-web/src/test/resources/org/springframework/web/context/request/sessionScopeTests.xml index 45f87fa263cf..42dde8fce71a 100644 --- a/spring-web/src/test/resources/org/springframework/web/context/request/sessionScopeTests.xml +++ b/spring-web/src/test/resources/org/springframework/web/context/request/sessionScopeTests.xml @@ -3,8 +3,8 @@ - + - + diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java index 13e3c3c4d9ac..d0fd055ce50b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.server.MockWebSession; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.SessionAttributes; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java index 0e3c1fe78d05..6e3717fb7efa 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java @@ -28,7 +28,7 @@ import reactor.core.publisher.Mono; import reactor.test.StepVerifier; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.http.MediaType; import org.springframework.lang.Nullable; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java index ce6ae9151712..e660183ff55d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; diff --git a/spring-webmvc/src/test/java/org/springframework/context/LifecycleContextBean.java b/spring-webmvc/src/test/java/org/springframework/context/LifecycleContextBean.java index c6e1fe0b1942..1f04eb182ccc 100644 --- a/spring-webmvc/src/test/java/org/springframework/context/LifecycleContextBean.java +++ b/spring-webmvc/src/test/java/org/springframework/context/LifecycleContextBean.java @@ -18,7 +18,7 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.test.fixtures.beans.LifecycleBean; +import org.springframework.beans.testfixture.beans.LifecycleBean; /** * Simple bean to test ApplicationContext lifecycle methods for beans diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java index c9f96dfdd3e4..dc713f1141f4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java @@ -29,8 +29,8 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.LifecycleBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.LifecycleBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.ApplicationContextInitializer; diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java index 52d9278ec215..731997455caa 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java @@ -28,7 +28,7 @@ import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.NoSuchMessageException; import org.springframework.context.test.fixtures.AbstractApplicationContextTests; diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java index 4fffbccb8a7b..98b4f0393d97 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java @@ -27,7 +27,7 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.BeanCreationException; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.Resource; import org.springframework.mock.web.test.MockServletContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java index 713e6541e2b3..c30dd13348a9 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java @@ -32,7 +32,7 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.PropertyValue; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.ConfigurableEnvironment; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java index d03a02418a07..c363455a04c0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java @@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.Ordered; import org.springframework.core.convert.converter.Converter; import org.springframework.core.io.FileSystemResourceLoader; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java index cc7a89378df5..6d12cf8be67e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.TypeMismatchException; -import org.springframework.beans.test.fixtures.beans.ITestBean; +import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.support.StaticMessageSource; import org.springframework.core.annotation.AliasFor; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java index 23baef133096..c3a70e71687d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.bind.ServletRequestDataBinder; import org.springframework.web.bind.WebDataBinder; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java index 86e85f82efe5..95972e4f958a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.ui.ExtendedModelMap; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java index a4f5e0a24797..bb9f4a9193d0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java @@ -41,7 +41,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.propertyeditors.CustomDateEditor; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.MethodParameter; import org.springframework.http.CacheControl; import org.springframework.http.HttpEntity; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index 374c3516bed3..4896ef437b13 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -70,10 +70,10 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.propertyeditors.CustomDateEditor; -import org.springframework.beans.test.fixtures.beans.DerivedTestBean; -import org.springframework.beans.test.fixtures.beans.GenericBean; -import org.springframework.beans.test.fixtures.beans.ITestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.GenericBean; +import org.springframework.beans.testfixture.beans.ITestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigUtils; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.core.MethodParameter; @@ -288,7 +288,7 @@ public void typeNestedSetBinding() throws Exception { request.addParameter("testBeanSet", "1", "2"); MockHttpServletResponse response = new MockHttpServletResponse(); getServlet().service(request, response); - assertThat(response.getContentAsString()).isEqualTo("[1, 2]-org.springframework.beans.test.fixtures.beans.TestBean"); + assertThat(response.getContentAsString()).isEqualTo("[1, 2]-org.springframework.beans.testfixture.beans.TestBean"); } @Test // SPR-12903 diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java index 125bdeaad653..a5b24086142d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.MethodParameter; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java index 2ff58d4947b6..167d6cfee194 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java @@ -24,7 +24,7 @@ import org.springframework.beans.ConversionNotSupportedException; import org.springframework.beans.TypeMismatchException; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.MethodParameter; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageNotReadableException; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java index f0c932b0dfb6..9e8da5248e67 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.convert.converter.Converter; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.format.support.FormattingConversionService; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java index aa45d57d2c0a..d8f92d4de72e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java @@ -30,9 +30,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.CustomDateEditor; -import org.springframework.beans.test.fixtures.beans.IndexedTestBean; -import org.springframework.beans.test.fixtures.beans.NestedTestBean; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.IndexedTestBean; +import org.springframework.beans.testfixture.beans.NestedTestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.validation.BindException; import org.springframework.validation.BindingResult; import org.springframework.validation.DataBinder; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractFormTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractFormTagTests.java index 96d8e54b199e..3422b0140424 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractFormTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractFormTagTests.java @@ -18,7 +18,7 @@ import javax.servlet.jsp.JspException; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockPageContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java index 261f88888957..02a4fe580040 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java index 7a793ed95776..fc138af091e1 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java @@ -34,9 +34,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringTrimmerEditor; -import org.springframework.beans.test.fixtures.beans.Colour; -import org.springframework.beans.test.fixtures.beans.Pet; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.Colour; +import org.springframework.beans.testfixture.beans.Pet; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java index 3d7b5ee82faf..b9a1f5e83e58 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java @@ -38,9 +38,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringTrimmerEditor; -import org.springframework.beans.test.fixtures.beans.Colour; -import org.springframework.beans.test.fixtures.beans.Pet; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.Colour; +import org.springframework.beans.testfixture.beans.Pet; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.format.Formatter; import org.springframework.format.support.FormattingConversionService; import org.springframework.util.ObjectUtils; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java index 37083841dff1..e0e5a0747691 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.MockBodyContent; import org.springframework.mock.web.test.MockPageContext; import org.springframework.validation.BeanPropertyBindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java index 2e26d9c1a7d5..29c95bda5590 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java index 4ccbd0da4438..a68de172d710 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.web.servlet.support.BindStatus; import org.springframework.web.servlet.tags.BindTag; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java index ed99587c23ea..714b71030b52 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.MockPageContext; import org.springframework.web.servlet.tags.NestedPathTag; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java index 128d99cb98dd..d3783cf3e1fd 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.CustomEnum; -import org.springframework.beans.test.fixtures.beans.GenericBean; +import org.springframework.beans.testfixture.beans.CustomEnum; +import org.springframework.beans.testfixture.beans.GenericBean; import org.springframework.web.servlet.support.BindStatus; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java index 0cb39f93e37e..a1144ddc087d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java @@ -28,8 +28,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringArrayPropertyEditor; -import org.springframework.beans.test.fixtures.beans.Colour; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.Colour; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.MockBodyContent; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.util.StringUtils; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java index 8150e9980c8a..3e463443debc 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java @@ -34,7 +34,7 @@ import org.dom4j.io.SAXReader; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockPageContext; import org.springframework.validation.BeanPropertyBindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java index 4c0141ec9006..f8f258627eae 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java @@ -28,8 +28,8 @@ import org.dom4j.io.SAXReader; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.Pet; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.Pet; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java index 550afd614f32..e358e6782483 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java @@ -37,9 +37,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringTrimmerEditor; -import org.springframework.beans.test.fixtures.beans.Colour; -import org.springframework.beans.test.fixtures.beans.Pet; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.Colour; +import org.springframework.beans.testfixture.beans.Pet; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java index c2b8f6e8372f..7f9b8435c129 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java @@ -41,7 +41,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.CustomCollectionEditor; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.format.Formatter; import org.springframework.format.support.FormattingConversionService; import org.springframework.validation.BeanPropertyBindingResult; @@ -351,7 +351,7 @@ public void withInvalidList() throws Exception { assertThatExceptionOfType(JspException.class).as("use a non-Collection typed value as the value of 'items'").isThrownBy( this.tag::doStartTag) .withMessageContaining("items") - .withMessageContaining("org.springframework.beans.test.fixtures.beans.TestBean"); + .withMessageContaining("org.springframework.beans.testfixture.beans.TestBean"); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestBeanWithRealCountry.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestBeanWithRealCountry.java index b6e19fee69e4..486777de0065 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestBeanWithRealCountry.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestBeanWithRealCountry.java @@ -16,7 +16,7 @@ package org.springframework.web.servlet.tags.form; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; /** * @author Juergen Hoeller diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java index 4887d25c5afd..2289023528b2 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java index 42e3a52c90d8..9f3e89696a39 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.http.HttpStatus; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java index 6ba42c614b8b..03f2fddaf8ae 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java @@ -36,7 +36,7 @@ import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.PropertyValue; import org.springframework.beans.factory.BeanDefinitionStoreException; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java index d57b19d5e86c..d11e49e6035a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java @@ -32,7 +32,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.test.fixtures.beans.TestBean; +import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml index 40deeea4b155..0979cd397289 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml index 2bf1093f519c..b0d94377dd96 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml @@ -9,7 +9,7 @@ - + - + dummy @@ -45,7 +45,7 @@ Tests of lifecycle callbacks --> + class="org.springframework.beans.testfixture.beans.MustBeInitialized"> 31 - + - + Kerry 34 - + typeMismatch 34x @@ -31,20 +31,20 @@ + class="org.springframework.beans.testfixture.beans.factory.DummyFactory"> + class="org.springframework.beans.testfixture.beans.factory.DummyFactory"> false - + listenerVeto 66 - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/contextInclude.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/contextInclude.xml index 5d3eb6c8c9f8..37614538bc28 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/contextInclude.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/contextInclude.xml @@ -1,6 +1,6 @@ - + yetanotherdummy diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/sessionContext.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/sessionContext.xml index 8d2db6fb21ad..bf6fec590f56 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/sessionContext.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/sessionContext.xml @@ -3,12 +3,12 @@ - + - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml index 4f444b9176b8..78ae8e35af44 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml @@ -15,7 +15,7 @@ - + Rod 31 @@ -28,32 +28,32 @@ 31 - + - + Kerry 34 - + typeMismatch 34x - + - + false - + listenerVeto 66 - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/testNamespace.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/testNamespace.xml index 519b5d89821f..b898c51cc6dc 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/testNamespace.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/testNamespace.xml @@ -3,12 +3,12 @@ - + Rod 31 - + Kerry 34 From 726b1bb1d015ca2889f6261d067a4a2b8e7071c8 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 29 Dec 2019 17:41:00 +0100 Subject: [PATCH 0246/2315] Rename test fixture package in spring-context See gh-23550 --- .../build/testsources/TestSourcesPlugin.java | 15 +++++++++++++++ .../aspectj/AbstractCacheAnnotationTests.java | 2 +- .../AspectJEnableCachingIsolatedTests.java | 12 ++++++------ .../cache/aspectj/AspectJEnableCachingTests.java | 6 +++--- .../cache/config/annotation-cache-aspectj.xml | 4 ++-- .../cache/caffeine/CaffeineCacheTests.java | 2 +- .../cache/ehcache/EhCacheCacheTests.java | 2 +- .../jcache/JCacheEhCacheAnnotationTests.java | 10 +++++----- .../cache/jcache/JCacheEhCacheApiTests.java | 2 +- .../jcache/config/JCacheJavaConfigTests.java | 2 +- .../aop/framework/ProxyFactoryBeanTests.java | 2 +- .../aop/scope/ScopedProxyTests.java | 2 +- .../cache/concurrent/ConcurrentMapCacheTests.java | 2 +- .../config/AnnotationDrivenCacheConfigTests.java | 2 +- .../config/AnnotationNamespaceDrivenTests.java | 2 +- .../cache/config/CacheAdviceNamespaceTests.java | 2 +- .../cache/config/CustomInterceptorTests.java | 6 +++--- .../config/EnableCachingIntegrationTests.java | 6 +++--- .../cache/config/EnableCachingTests.java | 14 +++++++------- .../CacheResolverCustomizationTests.java | 6 +++--- .../cache/interceptor/CacheSyncFailureTests.java | 2 +- ...lassPathFactoryBeanDefinitionScannerTests.java | 2 +- ...thScanningCandidateComponentProviderTests.java | 2 +- .../CommonAnnotationBeanPostProcessorTests.java | 2 +- .../ComponentScanAnnotationIntegrationTests.java | 2 +- .../ComponentScanParserScopedProxyTests.java | 2 +- .../event/ApplicationContextEventTests.java | 4 ++-- .../event/EventPublicationInterceptorTests.java | 2 +- .../CandidateComponentsIndexLoaderTests.java | 2 +- .../StaticApplicationContextMulticasterTests.java | 6 +++--- .../support/StaticApplicationContextTests.java | 6 +++--- .../context/support/StaticMessageSourceTests.java | 6 +++--- .../jndi/JndiObjectFactoryBeanTests.java | 2 +- .../jndi/JndiPropertySourceTests.java | 2 +- .../cache/config/annotationDrivenCacheConfig.xml | 8 ++++---- .../config/annotationDrivenCacheNamespace.xml | 8 ++++---- .../springframework/cache/config/cache-advice.xml | 8 ++++---- .../jmx/export/propertyPlaceholderConfigurer.xml | 2 +- .../AbstractApplicationContextTests.java | 8 ++++---- .../fixtures => testfixture}/SimpleMapScope.java | 2 +- .../fixtures => testfixture}/beans/ACATester.java | 2 +- .../beans/BeanThatBroadcasts.java | 2 +- .../beans/BeanThatListens.java | 2 +- .../beans/TestApplicationListener.java | 2 +- .../cache/AbstractCacheAnnotationTests.java | 8 ++++---- .../cache/AbstractCacheTests.java | 2 +- .../cache/AbstractValueAdaptingCacheTests.java | 2 +- .../cache/CacheTestUtils.java | 2 +- .../cache/SomeCustomKeyGenerator.java | 2 +- .../cache/SomeKeyGenerator.java | 2 +- .../beans/AnnotatedClassCacheableService.java | 2 +- .../cache/beans/CacheableService.java | 2 +- .../cache/beans/DefaultCacheableService.java | 2 +- .../cache/beans/TestEntity.java | 2 +- .../index/CandidateComponentsTestClassLoader.java | 2 +- .../jndi/ExpectedLookupTemplate.java | 4 ++-- .../jndi/SimpleNamingContext.java | 4 ++-- .../jndi/SimpleNamingContextBuilder.java | 2 +- .../DefaultPersistenceUnitManagerTests.java | 2 +- .../PersistenceXmlParsingTests.java | 2 +- .../jpa/support/PersistenceInjectionTests.java | 4 ++-- .../JndiJtaTransactionManagerTests.java | 2 +- .../jta/WebSphereUowTransactionManagerTests.java | 2 +- .../JtaTransactionManagerSerializationTests.java | 2 +- .../support/StandardServletEnvironmentTests.java | 2 +- .../context/XmlWebApplicationContextTests.java | 6 +++--- .../web/context/WEB-INF/applicationContext.xml | 4 ++-- .../web/context/WEB-INF/context-addition.xml | 6 +++--- .../web/context/WEB-INF/test-servlet.xml | 6 +++--- 69 files changed, 139 insertions(+), 124 deletions(-) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/AbstractApplicationContextTests.java (96%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/SimpleMapScope.java (97%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/beans/ACATester.java (96%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/beans/BeanThatBroadcasts.java (95%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/beans/BeanThatListens.java (96%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/beans/TestApplicationListener.java (95%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/cache/AbstractCacheAnnotationTests.java (98%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/cache/AbstractCacheTests.java (99%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/cache/AbstractValueAdaptingCacheTests.java (96%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/cache/CacheTestUtils.java (97%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/cache/SomeCustomKeyGenerator.java (96%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/cache/SomeKeyGenerator.java (92%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/cache/beans/AnnotatedClassCacheableService.java (99%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/cache/beans/CacheableService.java (96%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/cache/beans/DefaultCacheableService.java (99%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/cache/beans/TestEntity.java (95%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/index/CandidateComponentsTestClassLoader.java (98%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/jndi/ExpectedLookupTemplate.java (93%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/jndi/SimpleNamingContext.java (98%) rename spring-context/src/testFixtures/java/org/springframework/context/{test/fixtures => testfixture}/jndi/SimpleNamingContextBuilder.java (99%) diff --git a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java index afe853b2845f..5bfbd3c3c236 100644 --- a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java +++ b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java @@ -60,11 +60,26 @@ public class TestSourcesPlugin implements Plugin { *

    This is used to assist with the migration to Gradle test fixtures. */ private static final List excludedProjects = Arrays.asList( + // "integration-tests", "spring-beans", "spring-context", "spring-context-indexer", "spring-context-support", "spring-core" + // "spring-expression", + // "spring-instrument", + // "spring-jcl", + // "spring-jdbc", + // "spring-jms", + // "spring-messaging", + // "spring-orm", + // "spring-oxm", + // "spring-test", + // "spring-tx", + // "spring-web", + // "spring-webflux", + // "spring-webmvc", + // "spring-websocket" ); diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java index 24fd8a30b9ac..eed37f21ec04 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java @@ -31,7 +31,7 @@ import org.springframework.cache.config.CacheableService; import org.springframework.cache.config.TestEntity; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator; +import org.springframework.context.testfixture.cache.SomeCustomKeyGenerator; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java index 686acc548515..7ca1037efbc4 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java @@ -36,12 +36,12 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.test.fixtures.cache.CacheTestUtils; -import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator; -import org.springframework.context.test.fixtures.cache.SomeKeyGenerator; -import org.springframework.context.test.fixtures.cache.beans.AnnotatedClassCacheableService; -import org.springframework.context.test.fixtures.cache.beans.CacheableService; -import org.springframework.context.test.fixtures.cache.beans.DefaultCacheableService; +import org.springframework.context.testfixture.cache.CacheTestUtils; +import org.springframework.context.testfixture.cache.SomeCustomKeyGenerator; +import org.springframework.context.testfixture.cache.SomeKeyGenerator; +import org.springframework.context.testfixture.cache.beans.AnnotatedClassCacheableService; +import org.springframework.context.testfixture.cache.beans.CacheableService; +import org.springframework.context.testfixture.cache.beans.DefaultCacheableService; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java index 8fc14ff04523..7e693d6ea13a 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java @@ -30,9 +30,9 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.test.fixtures.cache.CacheTestUtils; -import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator; -import org.springframework.context.test.fixtures.cache.SomeKeyGenerator; +import org.springframework.context.testfixture.cache.CacheTestUtils; +import org.springframework.context.testfixture.cache.SomeCustomKeyGenerator; +import org.springframework.context.testfixture.cache.SomeKeyGenerator; /** * @author Stephane Nicoll diff --git a/spring-aspects/src/test/resources/org/springframework/cache/config/annotation-cache-aspectj.xml b/spring-aspects/src/test/resources/org/springframework/cache/config/annotation-cache-aspectj.xml index f9df2c29bf75..1a283f6f6d83 100644 --- a/spring-aspects/src/test/resources/org/springframework/cache/config/annotation-cache-aspectj.xml +++ b/spring-aspects/src/test/resources/org/springframework/cache/config/annotation-cache-aspectj.xml @@ -22,7 +22,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java index 07af88796fb4..48e1fd5a9393 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; -import org.springframework.context.test.fixtures.cache.AbstractValueAdaptingCacheTests; +import org.springframework.context.testfixture.cache.AbstractValueAdaptingCacheTests; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java index eff54703337d..b9bb1cc8542a 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.context.test.fixtures.cache.AbstractCacheTests; +import org.springframework.context.testfixture.cache.AbstractCacheTests; import org.springframework.core.testfixture.EnabledForTestGroups; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java index bb7741478f1c..16bf56235483 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java @@ -34,11 +34,11 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.test.fixtures.cache.AbstractCacheAnnotationTests; -import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator; -import org.springframework.context.test.fixtures.cache.beans.AnnotatedClassCacheableService; -import org.springframework.context.test.fixtures.cache.beans.CacheableService; -import org.springframework.context.test.fixtures.cache.beans.DefaultCacheableService; +import org.springframework.context.testfixture.cache.AbstractCacheAnnotationTests; +import org.springframework.context.testfixture.cache.SomeCustomKeyGenerator; +import org.springframework.context.testfixture.cache.beans.AnnotatedClassCacheableService; +import org.springframework.context.testfixture.cache.beans.CacheableService; +import org.springframework.context.testfixture.cache.beans.DefaultCacheableService; import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.support.TransactionTemplate; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java index 4f9adba6ee8a..b826e2a3fb37 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.springframework.context.test.fixtures.cache.AbstractValueAdaptingCacheTests; +import org.springframework.context.testfixture.cache.AbstractValueAdaptingCacheTests; /** * @author Stephane Nicoll diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java index e8c4275823f4..9288994fc6f0 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java @@ -42,7 +42,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.test.fixtures.cache.SomeKeyGenerator; +import org.springframework.context.testfixture.cache.SomeKeyGenerator; import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnotationTests; import org.springframework.contextsupport.testfixture.jcache.JCacheableService; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java index dd8e884664d9..af7507470a16 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java @@ -50,7 +50,7 @@ import org.springframework.beans.testfixture.beans.SideEffectBean; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationListener; -import org.springframework.context.test.fixtures.beans.TestApplicationListener; +import org.springframework.context.testfixture.beans.TestApplicationListener; import org.springframework.core.io.ClassPathResource; import org.springframework.core.testfixture.TimeStamped; import org.springframework.core.testfixture.io.SerializationTestUtils; diff --git a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java index 7b6cb703a7bd..7ef136b9827b 100644 --- a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java @@ -28,7 +28,7 @@ import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.context.test.fixtures.SimpleMapScope; +import org.springframework.context.testfixture.SimpleMapScope; import org.springframework.core.io.ClassPathResource; import org.springframework.core.testfixture.io.SerializationTestUtils; diff --git a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java index e933a9bf028e..5ac1d4b225ef 100644 --- a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java +++ b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.context.test.fixtures.cache.AbstractValueAdaptingCacheTests; +import org.springframework.context.testfixture.cache.AbstractValueAdaptingCacheTests; import org.springframework.core.serializer.support.SerializationDelegate; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/cache/config/AnnotationDrivenCacheConfigTests.java b/spring-context/src/test/java/org/springframework/cache/config/AnnotationDrivenCacheConfigTests.java index 1e99b6f79658..7940c65b25d5 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/AnnotationDrivenCacheConfigTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/AnnotationDrivenCacheConfigTests.java @@ -18,7 +18,7 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; -import org.springframework.context.test.fixtures.cache.AbstractCacheAnnotationTests; +import org.springframework.context.testfixture.cache.AbstractCacheAnnotationTests; /** * @author Costin Leau diff --git a/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java b/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java index e032e3674222..230337961b8f 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java @@ -22,7 +22,7 @@ import org.springframework.cache.interceptor.CacheInterceptor; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; -import org.springframework.context.test.fixtures.cache.AbstractCacheAnnotationTests; +import org.springframework.context.testfixture.cache.AbstractCacheAnnotationTests; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java b/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java index 5b679a3269e8..f15aa696f16c 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java @@ -21,7 +21,7 @@ import org.springframework.cache.interceptor.CacheInterceptor; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; -import org.springframework.context.test.fixtures.cache.AbstractCacheAnnotationTests; +import org.springframework.context.testfixture.cache.AbstractCacheAnnotationTests; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java b/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java index b94b3811de45..1d83c6d00b31 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java @@ -32,9 +32,9 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.test.fixtures.cache.CacheTestUtils; -import org.springframework.context.test.fixtures.cache.beans.CacheableService; -import org.springframework.context.test.fixtures.cache.beans.DefaultCacheableService; +import org.springframework.context.testfixture.cache.CacheTestUtils; +import org.springframework.context.testfixture.cache.beans.CacheableService; +import org.springframework.context.testfixture.cache.beans.DefaultCacheableService; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java index 2b1de9a12f18..0d55805af6c3 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java @@ -33,13 +33,13 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.context.test.fixtures.cache.CacheTestUtils; +import org.springframework.context.testfixture.cache.CacheTestUtils; import org.springframework.core.env.Environment; import org.springframework.mock.env.MockEnvironment; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.context.test.fixtures.cache.CacheTestUtils.assertCacheHit; -import static org.springframework.context.test.fixtures.cache.CacheTestUtils.assertCacheMiss; +import static org.springframework.context.testfixture.cache.CacheTestUtils.assertCacheHit; +import static org.springframework.context.testfixture.cache.CacheTestUtils.assertCacheMiss; /** * Tests that represent real use cases with advanced configuration. diff --git a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java index 551b28c50fd4..fae93b5a59d1 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java @@ -34,13 +34,13 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.test.fixtures.cache.AbstractCacheAnnotationTests; -import org.springframework.context.test.fixtures.cache.CacheTestUtils; -import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator; -import org.springframework.context.test.fixtures.cache.SomeKeyGenerator; -import org.springframework.context.test.fixtures.cache.beans.AnnotatedClassCacheableService; -import org.springframework.context.test.fixtures.cache.beans.CacheableService; -import org.springframework.context.test.fixtures.cache.beans.DefaultCacheableService; +import org.springframework.context.testfixture.cache.AbstractCacheAnnotationTests; +import org.springframework.context.testfixture.cache.CacheTestUtils; +import org.springframework.context.testfixture.cache.SomeCustomKeyGenerator; +import org.springframework.context.testfixture.cache.SomeKeyGenerator; +import org.springframework.context.testfixture.cache.beans.AnnotatedClassCacheableService; +import org.springframework.context.testfixture.cache.beans.CacheableService; +import org.springframework.context.testfixture.cache.beans.DefaultCacheableService; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java index 45e3d575327f..ca2e76fc36ff 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java @@ -35,15 +35,15 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.test.fixtures.cache.CacheTestUtils; +import org.springframework.context.testfixture.cache.CacheTestUtils; import org.springframework.lang.Nullable; import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.springframework.context.test.fixtures.cache.CacheTestUtils.assertCacheHit; -import static org.springframework.context.test.fixtures.cache.CacheTestUtils.assertCacheMiss; +import static org.springframework.context.testfixture.cache.CacheTestUtils.assertCacheHit; +import static org.springframework.context.testfixture.cache.CacheTestUtils.assertCacheMiss; /** * Provides various {@link CacheResolver} customisations scenario diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java index cc5ffb063440..2a3eccc6db7b 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java @@ -32,7 +32,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.test.fixtures.cache.CacheTestUtils; +import org.springframework.context.testfixture.cache.CacheTestUtils; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java index a15cc4c76877..09498371ab7e 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java @@ -28,7 +28,7 @@ import org.springframework.context.annotation4.FactoryMethodComponent; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.context.test.fixtures.SimpleMapScope; +import org.springframework.context.testfixture.SimpleMapScope; import org.springframework.util.ClassUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java index 949fbd356d17..7b63c97ad847 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java @@ -42,7 +42,7 @@ import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.context.test.fixtures.index.CandidateComponentsTestClassLoader; +import org.springframework.context.testfixture.index.CandidateComponentsTestClassLoader; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.StandardEnvironment; import org.springframework.core.io.ClassPathResource; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java index 7c1fa7016aa8..631ca5644f91 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java @@ -41,7 +41,7 @@ import org.springframework.beans.testfixture.beans.NestedTestBean; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; +import org.springframework.context.testfixture.jndi.ExpectedLookupTemplate; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.jndi.support.SimpleJndiBeanFactory; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java index 25061f5a0451..9e203c4b631c 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java @@ -51,7 +51,7 @@ import org.springframework.context.annotation.componentscan.simple.ClassWithNestedComponents; import org.springframework.context.annotation.componentscan.simple.SimpleComponent; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.context.test.fixtures.SimpleMapScope; +import org.springframework.context.testfixture.SimpleMapScope; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Environment; import org.springframework.core.env.Profiles; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java index e0669373f71b..cea9f6af5d14 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java @@ -23,7 +23,7 @@ import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.context.test.fixtures.SimpleMapScope; +import org.springframework.context.testfixture.SimpleMapScope; import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java index 49cc3f85e971..2e92dbcaa19a 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java @@ -41,8 +41,8 @@ import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.support.StaticApplicationContext; import org.springframework.context.support.StaticMessageSource; -import org.springframework.context.test.fixtures.beans.BeanThatBroadcasts; -import org.springframework.context.test.fixtures.beans.BeanThatListens; +import org.springframework.context.testfixture.beans.BeanThatBroadcasts; +import org.springframework.context.testfixture.beans.BeanThatListens; import org.springframework.core.Ordered; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.Order; diff --git a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java index 72e593f7d4e4..ace9382ee7ff 100644 --- a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java @@ -28,7 +28,7 @@ import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.event.test.TestEvent; import org.springframework.context.support.StaticApplicationContext; -import org.springframework.context.test.fixtures.beans.TestApplicationListener; +import org.springframework.context.testfixture.beans.TestApplicationListener; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java index 402dc3cdb77a..2eac4a6688b8 100644 --- a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java +++ b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.context.test.fixtures.index.CandidateComponentsTestClassLoader; +import org.springframework.context.testfixture.index.CandidateComponentsTestClassLoader; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java index c3fbc6818a48..403bf613befa 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java @@ -28,9 +28,9 @@ import org.springframework.context.ApplicationEvent; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.event.SimpleApplicationEventMulticaster; -import org.springframework.context.test.fixtures.AbstractApplicationContextTests; -import org.springframework.context.test.fixtures.beans.ACATester; -import org.springframework.context.test.fixtures.beans.BeanThatListens; +import org.springframework.context.testfixture.AbstractApplicationContextTests; +import org.springframework.context.testfixture.beans.ACATester; +import org.springframework.context.testfixture.beans.BeanThatListens; import org.springframework.core.ResolvableType; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java index ac15f3bcaeee..91c06a88da48 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java @@ -26,9 +26,9 @@ import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.test.fixtures.AbstractApplicationContextTests; -import org.springframework.context.test.fixtures.beans.ACATester; -import org.springframework.context.test.fixtures.beans.BeanThatListens; +import org.springframework.context.testfixture.AbstractApplicationContextTests; +import org.springframework.context.testfixture.beans.ACATester; +import org.springframework.context.testfixture.beans.BeanThatListens; import org.springframework.core.io.ClassPathResource; /** diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java index 40771a9c6cac..d9c07360757c 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java @@ -29,9 +29,9 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.MessageSourceResolvable; import org.springframework.context.NoSuchMessageException; -import org.springframework.context.test.fixtures.AbstractApplicationContextTests; -import org.springframework.context.test.fixtures.beans.ACATester; -import org.springframework.context.test.fixtures.beans.BeanThatListens; +import org.springframework.context.testfixture.AbstractApplicationContextTests; +import org.springframework.context.testfixture.beans.ACATester; +import org.springframework.context.testfixture.beans.BeanThatListens; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java index f7660b858156..bf2e42a6c59a 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java @@ -25,7 +25,7 @@ import org.springframework.beans.testfixture.beans.DerivedTestBean; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.TestBean; -import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; +import org.springframework.context.testfixture.jndi.ExpectedLookupTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java index e2e55593ba58..9ece68cea27b 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.context.test.fixtures.jndi.SimpleNamingContext; +import org.springframework.context.testfixture.jndi.SimpleNamingContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml b/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml index 430783e5993e..0057278c4899 100644 --- a/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml +++ b/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml @@ -36,13 +36,13 @@ - + - + - + - + diff --git a/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml b/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml index 0b914d6a989a..9cffaef012cb 100644 --- a/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml +++ b/spring-context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml @@ -26,15 +26,15 @@ - + - + - + - + diff --git a/spring-context/src/test/resources/org/springframework/cache/config/cache-advice.xml b/spring-context/src/test/resources/org/springframework/cache/config/cache-advice.xml index dc68f1adfcf0..ea6901d7a269 100644 --- a/spring-context/src/test/resources/org/springframework/cache/config/cache-advice.xml +++ b/spring-context/src/test/resources/org/springframework/cache/config/cache-advice.xml @@ -112,9 +112,9 @@ - + - + @@ -126,7 +126,7 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/jmx/export/propertyPlaceholderConfigurer.xml b/spring-context/src/test/resources/org/springframework/jmx/export/propertyPlaceholderConfigurer.xml index 39e7db19653b..40d1791c6d09 100644 --- a/spring-context/src/test/resources/org/springframework/jmx/export/propertyPlaceholderConfigurer.xml +++ b/spring-context/src/test/resources/org/springframework/jmx/export/propertyPlaceholderConfigurer.xml @@ -17,7 +17,7 @@ - + diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/AbstractApplicationContextTests.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/AbstractApplicationContextTests.java similarity index 96% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/AbstractApplicationContextTests.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/AbstractApplicationContextTests.java index 929c804943b5..e3ba64f369f5 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/AbstractApplicationContextTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/AbstractApplicationContextTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures; +package org.springframework.context.testfixture; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -33,9 +33,9 @@ import org.springframework.context.ApplicationEvent; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.NoSuchMessageException; -import org.springframework.context.test.fixtures.beans.ACATester; -import org.springframework.context.test.fixtures.beans.BeanThatListens; -import org.springframework.context.test.fixtures.beans.TestApplicationListener; +import org.springframework.context.testfixture.beans.ACATester; +import org.springframework.context.testfixture.beans.BeanThatListens; +import org.springframework.context.testfixture.beans.TestApplicationListener; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/SimpleMapScope.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/SimpleMapScope.java similarity index 97% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/SimpleMapScope.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/SimpleMapScope.java index 089c75932fd9..9365c2b319b9 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/SimpleMapScope.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/SimpleMapScope.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures; +package org.springframework.context.testfixture; import java.io.Serializable; import java.util.HashMap; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/ACATester.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/ACATester.java similarity index 96% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/ACATester.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/ACATester.java index 995b84b6a8da..4d0fbd5d743c 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/ACATester.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/ACATester.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.beans; +package org.springframework.context.testfixture.beans; import java.util.Locale; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatBroadcasts.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/BeanThatBroadcasts.java similarity index 95% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatBroadcasts.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/BeanThatBroadcasts.java index 3a50975f33e9..cc8e13832da5 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatBroadcasts.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/BeanThatBroadcasts.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.beans; +package org.springframework.context.testfixture.beans; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatListens.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/BeanThatListens.java similarity index 96% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatListens.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/BeanThatListens.java index c7079188f9d0..f54e74c9aeca 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/BeanThatListens.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/BeanThatListens.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.beans; +package org.springframework.context.testfixture.beans; import java.util.Map; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/TestApplicationListener.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/TestApplicationListener.java similarity index 95% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/TestApplicationListener.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/TestApplicationListener.java index a43e534ddec6..63749d326f9f 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/beans/TestApplicationListener.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/beans/TestApplicationListener.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.beans; +package org.springframework.context.testfixture.beans; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheAnnotationTests.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheAnnotationTests.java similarity index 98% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheAnnotationTests.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheAnnotationTests.java index d94cacb17a2a..85f99eacce8d 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheAnnotationTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheAnnotationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.cache; +package org.springframework.context.testfixture.cache; import java.util.Collection; import java.util.UUID; @@ -28,9 +28,9 @@ import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.test.fixtures.cache.beans.AnnotatedClassCacheableService; -import org.springframework.context.test.fixtures.cache.beans.CacheableService; -import org.springframework.context.test.fixtures.cache.beans.TestEntity; +import org.springframework.context.testfixture.cache.beans.AnnotatedClassCacheableService; +import org.springframework.context.testfixture.cache.beans.CacheableService; +import org.springframework.context.testfixture.cache.beans.TestEntity; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheTests.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheTests.java similarity index 99% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheTests.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheTests.java index ab8490bd5361..e01074417a15 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractCacheTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.cache; +package org.springframework.context.testfixture.cache; import java.util.List; import java.util.UUID; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractValueAdaptingCacheTests.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractValueAdaptingCacheTests.java similarity index 96% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractValueAdaptingCacheTests.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractValueAdaptingCacheTests.java index ccaa6ffe8e78..5f0809deb187 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/AbstractValueAdaptingCacheTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractValueAdaptingCacheTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.cache; +package org.springframework.context.testfixture.cache; import org.junit.jupiter.api.Test; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/CacheTestUtils.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/CacheTestUtils.java similarity index 97% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/CacheTestUtils.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/CacheTestUtils.java index 1150a45a8f91..459c3bf95fa6 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/CacheTestUtils.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/CacheTestUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.cache; +package org.springframework.context.testfixture.cache; import java.util.ArrayList; import java.util.List; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeCustomKeyGenerator.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/SomeCustomKeyGenerator.java similarity index 96% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeCustomKeyGenerator.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/SomeCustomKeyGenerator.java index 296e3cd3a2cd..c9c476349e11 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeCustomKeyGenerator.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/SomeCustomKeyGenerator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.cache; +package org.springframework.context.testfixture.cache; import java.lang.reflect.Method; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeKeyGenerator.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/SomeKeyGenerator.java similarity index 92% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeKeyGenerator.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/SomeKeyGenerator.java index b4555262675b..791d9f769c65 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/SomeKeyGenerator.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/SomeKeyGenerator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.cache; +package org.springframework.context.testfixture.cache; import org.springframework.cache.interceptor.SimpleKeyGenerator; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/AnnotatedClassCacheableService.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/AnnotatedClassCacheableService.java similarity index 99% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/AnnotatedClassCacheableService.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/AnnotatedClassCacheableService.java index 8441ed9baa15..aaf8fb68815d 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/AnnotatedClassCacheableService.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/AnnotatedClassCacheableService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.cache.beans; +package org.springframework.context.testfixture.cache.beans; import java.io.IOException; import java.util.concurrent.atomic.AtomicLong; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/CacheableService.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/CacheableService.java similarity index 96% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/CacheableService.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/CacheableService.java index fbbb1fc572e1..06afcea22f4d 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/CacheableService.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/CacheableService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.cache.beans; +package org.springframework.context.testfixture.cache.beans; /** * Basic service interface for caching tests. diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/DefaultCacheableService.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/DefaultCacheableService.java similarity index 99% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/DefaultCacheableService.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/DefaultCacheableService.java index 3c5a5d666546..017a719173f8 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/DefaultCacheableService.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/DefaultCacheableService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.cache.beans; +package org.springframework.context.testfixture.cache.beans; import java.io.IOException; import java.util.concurrent.atomic.AtomicLong; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/TestEntity.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/TestEntity.java similarity index 95% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/TestEntity.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/TestEntity.java index db221313732c..77c9e067b3a3 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/cache/beans/TestEntity.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/beans/TestEntity.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.cache.beans; +package org.springframework.context.testfixture.cache.beans; import org.springframework.util.ObjectUtils; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/index/CandidateComponentsTestClassLoader.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/index/CandidateComponentsTestClassLoader.java similarity index 98% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/index/CandidateComponentsTestClassLoader.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/index/CandidateComponentsTestClassLoader.java index 02c91ed3d2bf..7b6ad75257fd 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/index/CandidateComponentsTestClassLoader.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/index/CandidateComponentsTestClassLoader.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.index; +package org.springframework.context.testfixture.index; import java.io.IOException; import java.net.URL; diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/ExpectedLookupTemplate.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/ExpectedLookupTemplate.java similarity index 93% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/ExpectedLookupTemplate.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/ExpectedLookupTemplate.java index c5e575d22c9c..007f1e5e9c10 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/ExpectedLookupTemplate.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/ExpectedLookupTemplate.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.jndi; +package org.springframework.context.testfixture.jndi; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -24,7 +24,7 @@ import org.springframework.jndi.JndiTemplate; /** - * Copy of the standard {@link org.springframework.context.test.fixtures.jndi.jndi.ExpectedLookupTemplate} + * Copy of the standard {@link org.springframework.context.testfixture.jndi.jndi.ExpectedLookupTemplate} * for testing purposes. * *

    Simple extension of the JndiTemplate class that always returns a given object. diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContext.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/SimpleNamingContext.java similarity index 98% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContext.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/SimpleNamingContext.java index f2f5450c84ba..7eeaea2f2493 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContext.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/SimpleNamingContext.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.jndi; +package org.springframework.context.testfixture.jndi; import java.util.HashMap; import java.util.Hashtable; @@ -156,7 +156,7 @@ public Object lookupLink(String name) throws NameNotFoundException { * Note: Not intended for direct use by applications * if setting up a JVM-level JNDI environment. * Use SimpleNamingContextBuilder to set up JNDI bindings then. - * @see org.springframework.context.test.fixtures.jndi.SimpleNamingContextBuilder#bind + * @see org.springframework.context.testfixture.jndi.SimpleNamingContextBuilder#bind */ @Override public void bind(String name, Object obj) { diff --git a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContextBuilder.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/SimpleNamingContextBuilder.java similarity index 99% rename from spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContextBuilder.java rename to spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/SimpleNamingContextBuilder.java index 08deabe11055..d686261d1a57 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/test/fixtures/jndi/SimpleNamingContextBuilder.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/SimpleNamingContextBuilder.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.context.test.fixtures.jndi; +package org.springframework.context.testfixture.jndi; import java.util.Hashtable; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java index 2dac01aab891..db1ed3966290 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.context.test.fixtures.index.CandidateComponentsTestClassLoader; +import org.springframework.context.testfixture.index.CandidateComponentsTestClassLoader; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.orm.jpa.domain.Person; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java index 3e3da8b68d62..d7a78f9e87b8 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.springframework.context.test.fixtures.jndi.SimpleNamingContextBuilder; +import org.springframework.context.testfixture.jndi.SimpleNamingContextBuilder; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.core.io.UrlResource; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java index 9409e437cece..3114573ed027 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java @@ -37,8 +37,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.context.test.fixtures.SimpleMapScope; -import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; +import org.springframework.context.testfixture.SimpleMapScope; +import org.springframework.context.testfixture.jndi.ExpectedLookupTemplate; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.lang.Nullable; import org.springframework.orm.jpa.AbstractEntityManagerFactoryBeanTests; diff --git a/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java b/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java index fe6bc1d24567..2319d34261fc 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; +import org.springframework.context.testfixture.jndi.ExpectedLookupTemplate; import org.springframework.transaction.jta.JtaTransactionManager; import org.springframework.transaction.jta.UserTransactionAdapter; import org.springframework.transaction.support.TransactionCallbackWithoutResult; diff --git a/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java b/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java index bc0599b7f969..06b4675f3a54 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java @@ -25,7 +25,7 @@ import com.ibm.wsspi.uow.UOWManager; import org.junit.jupiter.api.Test; -import org.springframework.context.test.fixtures.jndi.ExpectedLookupTemplate; +import org.springframework.context.testfixture.jndi.ExpectedLookupTemplate; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.transaction.IllegalTransactionStateException; import org.springframework.transaction.NestedTransactionNotSupportedException; diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java index be9f8e6b43d5..579b7670b12a 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.context.test.fixtures.jndi.SimpleNamingContextBuilder; +import org.springframework.context.testfixture.jndi.SimpleNamingContextBuilder; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.transaction.jta.JtaTransactionManager; diff --git a/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java b/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java index 750cbf55817b..3a792efed78d 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.context.test.fixtures.jndi.SimpleNamingContextBuilder; +import org.springframework.context.testfixture.jndi.SimpleNamingContextBuilder; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java index 731997455caa..a15153cadf75 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java @@ -31,8 +31,8 @@ import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.NoSuchMessageException; -import org.springframework.context.test.fixtures.AbstractApplicationContextTests; -import org.springframework.context.test.fixtures.beans.TestApplicationListener; +import org.springframework.context.testfixture.AbstractApplicationContextTests; +import org.springframework.context.testfixture.beans.TestApplicationListener; import org.springframework.mock.web.test.MockServletContext; import org.springframework.util.Assert; import org.springframework.web.context.support.XmlWebApplicationContext; @@ -96,7 +96,7 @@ public void environmentMerge() { /** * Overridden as we can't trust superclass method - * @see org.springframework.context.test.fixtures.AbstractApplicationContextTests#testEvents() + * @see org.springframework.context.testfixture.AbstractApplicationContextTests#testEvents() */ @Override protected void doTestEvents(TestApplicationListener listener, TestApplicationListener parentListener, diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml index b0d94377dd96..06b45bb167dd 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/applicationContext.xml @@ -25,9 +25,9 @@ --> - + - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/context-addition.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/context-addition.xml index 88b23df2cc8d..0cc0be7ffcd7 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/context-addition.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/context-addition.xml @@ -3,11 +3,11 @@ - + - + - + Roderick diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml index 78ae8e35af44..2ad17cf51378 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-servlet.xml @@ -11,9 +11,9 @@ org/springframework/web/context/WEB-INF/test- - + - + Rod @@ -21,7 +21,7 @@ - + Roderick From 94f8ef08e201da291efbb86a31b34fa56e47e44e Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 29 Dec 2019 18:20:14 +0100 Subject: [PATCH 0247/2315] Move common TestPrincipal to spring-core test fixtures See gh-23550 --- .../build/testsources/TestSourcesPlugin.java | 18 +++--- .../DefaultListableBeanFactoryTests.java | 33 +---------- .../security/CallbacksSecurityTests.java | 32 +---------- .../testfixture/security}/TestPrincipal.java | 6 +- .../simp/SimpMessageHeaderAccessorTests.java | 2 + .../SimpleBrokerMessageHandlerTests.java | 2 +- .../StompBrokerRelayMessageHandlerTests.java | 2 +- .../DefaultUserDestinationResolverTests.java | 2 +- .../UserDestinationMessageHandlerTests.java | 2 +- ...nnotationControllerHandlerMethodTests.java | 11 +--- .../jetty/JettyWebSocketSessionTests.java | 2 +- .../StandardWebSocketSessionTests.java | 2 +- .../web/socket/handler/TestPrincipal.java | 56 ------------------- .../DefaultSimpUserRegistryTests.java | 18 +----- .../StompSubProtocolHandlerTests.java | 2 +- .../handler/DefaultSockJsServiceTests.java | 2 +- 16 files changed, 28 insertions(+), 164 deletions(-) rename {spring-messaging/src/test/java/org/springframework/messaging/simp => spring-core/src/testFixtures/java/org/springframework/core/testfixture/security}/TestPrincipal.java (89%) delete mode 100644 spring-websocket/src/test/java/org/springframework/web/socket/handler/TestPrincipal.java diff --git a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java index 5bfbd3c3c236..0248464cc189 100644 --- a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java +++ b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java @@ -60,18 +60,20 @@ public class TestSourcesPlugin implements Plugin { *

    This is used to assist with the migration to Gradle test fixtures. */ private static final List excludedProjects = Arrays.asList( - // "integration-tests", + "integration-tests", + "kotlin-coroutines", + // "spring-aop", "spring-beans", "spring-context", "spring-context-indexer", "spring-context-support", - "spring-core" - // "spring-expression", - // "spring-instrument", - // "spring-jcl", - // "spring-jdbc", - // "spring-jms", - // "spring-messaging", + "spring-core", + "spring-expression", + "spring-instrument", + "spring-jcl", + "spring-jdbc", + "spring-jms", + "spring-messaging" // "spring-orm", // "spring-oxm", // "spring-test", diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java index 689dc04547a9..1a7e67dbd9d8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java @@ -98,6 +98,7 @@ import org.springframework.core.testfixture.EnabledForTestGroups; import org.springframework.core.testfixture.TestGroup; import org.springframework.core.testfixture.io.SerializationTestUtils; +import org.springframework.core.testfixture.security.TestPrincipal; import org.springframework.lang.Nullable; import org.springframework.util.StopWatch; import org.springframework.util.StringValueResolver; @@ -3252,38 +3253,6 @@ public Object convertIfNecessary(Object value, @Nullable Class requiredType, @Nu } - private static class TestPrincipal implements Principal { - - private String name; - - public TestPrincipal(String name) { - this.name = name; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof TestPrincipal)) { - return false; - } - TestPrincipal p = (TestPrincipal) obj; - return this.name.equals(p.name); - } - - @Override - public int hashCode() { - return this.name.hashCode(); - } - } - - @SuppressWarnings("unused") private static class TestSecuredBean { diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java index df5071cf632e..84cb04da5994 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java @@ -55,6 +55,7 @@ import org.springframework.core.NestedRuntimeException; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.Resource; +import org.springframework.core.testfixture.security.TestPrincipal; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -252,37 +253,6 @@ public String run() { }); } - private static class TestPrincipal implements Principal { - - private String name; - - public TestPrincipal(String name) { - this.name = name; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof TestPrincipal)) { - return false; - } - TestPrincipal p = (TestPrincipal) obj; - return this.name.equals(p.name); - } - - @Override - public int hashCode() { - return this.name.hashCode(); - } - } - public CallbacksSecurityTests() { // setup security if (System.getSecurityManager() == null) { diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/TestPrincipal.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/security/TestPrincipal.java similarity index 89% rename from spring-messaging/src/test/java/org/springframework/messaging/simp/TestPrincipal.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/security/TestPrincipal.java index f9fb11691f42..78c60b067b30 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/TestPrincipal.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/security/TestPrincipal.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2019 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.messaging.simp; +package org.springframework.core.testfixture.security; import java.security.Principal; @@ -25,7 +25,7 @@ */ public class TestPrincipal implements Principal { - private String name; + private final String name; public TestPrincipal(String name) { this.name = name; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageHeaderAccessorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageHeaderAccessorTests.java index 99d166fa02f6..774576cc43e9 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageHeaderAccessorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageHeaderAccessorTests.java @@ -22,6 +22,8 @@ import org.junit.jupiter.api.Test; +import org.springframework.core.testfixture.security.TestPrincipal; + import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java index 456bd9f1d21f..72807d3e600e 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java @@ -29,13 +29,13 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.core.testfixture.security.TestPrincipal; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.SubscribableChannel; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.messaging.simp.SimpMessageType; -import org.springframework.messaging.simp.TestPrincipal; import org.springframework.messaging.support.MessageBuilder; import org.springframework.scheduling.TaskScheduler; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java index 4b67d290fb52..daf146fe2421 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java @@ -26,13 +26,13 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; +import org.springframework.core.testfixture.security.TestPrincipal; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.StubMessageChannel; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.messaging.simp.SimpMessageType; -import org.springframework.messaging.simp.TestPrincipal; import org.springframework.messaging.support.MessageBuilder; import org.springframework.messaging.support.MessageHeaderAccessor; import org.springframework.messaging.tcp.ReconnectStrategy; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java index 888afe23960e..020aa2b1bdc3 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java @@ -21,10 +21,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.core.testfixture.security.TestPrincipal; import org.springframework.messaging.Message; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.messaging.simp.SimpMessageType; -import org.springframework.messaging.simp.TestPrincipal; import org.springframework.messaging.support.MessageBuilder; import org.springframework.util.StringUtils; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java index 78c8dd3a5f34..121429b41199 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java @@ -22,12 +22,12 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mockito; +import org.springframework.core.testfixture.security.TestPrincipal; import org.springframework.messaging.Message; import org.springframework.messaging.StubMessageChannel; import org.springframework.messaging.SubscribableChannel; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.messaging.simp.SimpMessageType; -import org.springframework.messaging.simp.TestPrincipal; import org.springframework.messaging.simp.stomp.StompCommand; import org.springframework.messaging.simp.stomp.StompHeaderAccessor; import org.springframework.messaging.support.MessageBuilder; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index 4896ef437b13..42f6b87e42ef 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -79,6 +79,7 @@ import org.springframework.core.MethodParameter; import org.springframework.core.convert.converter.Converter; import org.springframework.core.testfixture.io.SerializationTestUtils; +import org.springframework.core.testfixture.security.TestPrincipal; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.format.support.FormattingConversionServiceFactoryBean; @@ -2643,7 +2644,7 @@ public TestBean getTestBean() { @ModelAttribute public Principal getPrincipal() { - return new TestPrincipal(); + return new TestPrincipal("test"); } @RequestMapping("/myPath") @@ -2661,14 +2662,6 @@ public void handle(@ModelAttribute TestBean testBean, } } - static class TestPrincipal implements Principal { - - @Override - public String getName() { - return "test"; - } - } - static class OtherPrincipal implements Principal { @Override diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSessionTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSessionTests.java index ab4c6e927a4a..c717017d654b 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSessionTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSessionTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import org.springframework.web.socket.handler.TestPrincipal; +import org.springframework.core.testfixture.security.TestPrincipal; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSessionTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSessionTests.java index 0843e46365b3..a16948cb4b1c 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSessionTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSessionTests.java @@ -24,8 +24,8 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import org.springframework.core.testfixture.security.TestPrincipal; import org.springframework.http.HttpHeaders; -import org.springframework.web.socket.handler.TestPrincipal; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/handler/TestPrincipal.java b/spring-websocket/src/test/java/org/springframework/web/socket/handler/TestPrincipal.java deleted file mode 100644 index 95f7f95d3851..000000000000 --- a/spring-websocket/src/test/java/org/springframework/web/socket/handler/TestPrincipal.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2002-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.web.socket.handler; - -import java.security.Principal; - -/** - * An implementation of {@link Principal} for testing. - * - * @author Rossen Stoyanchev - */ -public class TestPrincipal implements Principal { - - private String name; - - public TestPrincipal(String name) { - this.name = name; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof TestPrincipal)) { - return false; - } - TestPrincipal p = (TestPrincipal) obj; - return this.name.equals(p.name); - } - - @Override - public int hashCode() { - return this.name.hashCode(); - } - -} diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistryTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistryTests.java index 30f31fd2ae0d..d7fa58dcff08 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistryTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistryTests.java @@ -16,7 +16,6 @@ package org.springframework.web.socket.messaging; -import java.security.Principal; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; @@ -24,6 +23,7 @@ import org.junit.jupiter.api.Test; +import org.springframework.core.testfixture.security.TestPrincipal; import org.springframework.messaging.Message; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.messaging.simp.SimpMessageType; @@ -191,20 +191,4 @@ private Message createMessage(SimpMessageType type, String sessionId, St return MessageBuilder.createMessage(new byte[0], accessor.getMessageHeaders()); } - - private static class TestPrincipal implements Principal { - - private String name; - - public TestPrincipal(String name) { - this.name = name; - } - - @Override - public String getName() { - return this.name; - } - - } - } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java index 96b70e62f66a..6744cbc3d873 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java @@ -33,6 +33,7 @@ import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.PayloadApplicationEvent; +import org.springframework.core.testfixture.security.TestPrincipal; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageHandler; @@ -41,7 +42,6 @@ import org.springframework.messaging.simp.SimpAttributesContextHolder; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.messaging.simp.SimpMessageType; -import org.springframework.messaging.simp.TestPrincipal; import org.springframework.messaging.simp.stomp.StompCommand; import org.springframework.messaging.simp.stomp.StompEncoder; import org.springframework.messaging.simp.stomp.StompHeaderAccessor; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java index baa480592e10..083e105c0175 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java @@ -27,11 +27,11 @@ import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +import org.springframework.core.testfixture.security.TestPrincipal; import org.springframework.http.HttpHeaders; import org.springframework.scheduling.TaskScheduler; import org.springframework.web.socket.AbstractHttpRequestTests; import org.springframework.web.socket.WebSocketHandler; -import org.springframework.web.socket.handler.TestPrincipal; import org.springframework.web.socket.server.HandshakeHandler; import org.springframework.web.socket.server.support.OriginHandshakeInterceptor; import org.springframework.web.socket.sockjs.transport.SockJsSessionFactory; From 57b771ba92aede2205ab9e39f0d13dde88472755 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 31 Dec 2019 16:03:56 +0100 Subject: [PATCH 0248/2315] Move common FactoryMethods to spring-beans test fixtures See gh-23550 --- .../beans/factory/xml/FactoryMethodTests.java | 1 + .../beans/factory/xml/InstanceFactory.java | 1 + .../beans/factory/xml/factory-methods.xml | 30 +++--- .../testfixture/beans}/FactoryMethods.java | 8 +- .../aop/config/PrototypeProxyTests.java | 7 +- .../factory/xml/XmlBeanFactoryTestTypes.java | 101 +----------------- .../factory/xml/XmlBeanFactoryTests.java | 1 + .../tests/sample/beans/FactoryMethods.java | 33 ------ .../config/PrototypeProxyTests-context.xml | 2 - ...lBeanFactoryTests-constructorOverrides.xml | 2 +- ...toryTests-invalidOverridesNoSuchMethod.xml | 2 +- ...mlBeanFactoryTests-noSuchFactoryMethod.xml | 2 +- 12 files changed, 30 insertions(+), 160 deletions(-) rename spring-beans/src/{test/java/org/springframework/beans/factory/xml => testFixtures/java/org/springframework/beans/testfixture/beans}/FactoryMethods.java (91%) delete mode 100644 spring-context/src/test/java/org/springframework/tests/sample/beans/FactoryMethods.java diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java index 3ae92e3c8e8a..034a3aca50be 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.testfixture.beans.FactoryMethods; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java index 3dd4cbd1467a..af7f2f718b19 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java @@ -16,6 +16,7 @@ package org.springframework.beans.factory.xml; +import org.springframework.beans.testfixture.beans.FactoryMethods; import org.springframework.beans.testfixture.beans.TestBean; /** diff --git a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml index dc328aa88847..93f338b00178 100644 --- a/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml +++ b/spring-beans/src/test/resources/org/springframework/beans/factory/xml/factory-methods.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - setterString @@ -21,48 +21,48 @@ - - - setterString - 27 gotcha - 27 - 27 - 27 - @@ -72,31 +72,31 @@ - setterString - testBeanOnlyPrototypeDISetterString - - 27 gotcha - 27 @@ -104,7 +104,7 @@ bogus - diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/FactoryMethods.java similarity index 91% rename from spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java rename to spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/FactoryMethods.java index 88b5321b893c..98b26798a2c8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/FactoryMethods.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2019 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. @@ -14,13 +14,11 @@ * limitations under the License. */ -package org.springframework.beans.factory.xml; +package org.springframework.beans.testfixture.beans; import java.util.Collections; import java.util.List; -import org.springframework.beans.testfixture.beans.TestBean; - /** * Test class for Spring's ability to create objects using static * factory methods, rather than constructors. @@ -47,7 +45,7 @@ public static FactoryMethods newInstance(TestBean tb) { return new FactoryMethods(tb, "default", 0); } - protected static FactoryMethods newInstance(TestBean tb, int num, String name) { + public static FactoryMethods newInstance(TestBean tb, int num, String name) { if (name == null) { throw new IllegalStateException("Should never be called with null value"); } diff --git a/spring-context/src/test/java/org/springframework/aop/config/PrototypeProxyTests.java b/spring-context/src/test/java/org/springframework/aop/config/PrototypeProxyTests.java index ca304fbec7b2..9093cb62a85d 100644 --- a/spring-context/src/test/java/org/springframework/aop/config/PrototypeProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/config/PrototypeProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2019 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. @@ -24,10 +24,11 @@ * @author Juergen Hoeller * @author Chris Beams */ -public class PrototypeProxyTests { +class PrototypeProxyTests { @Test - public void testInjectionBeforeWrappingCheckDoesNotKickInForPrototypeProxy() { + @SuppressWarnings("resource") + void injectionBeforeWrappingCheckDoesNotKickInForPrototypeProxy() { new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); } diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java index 1ac5e555bad1..0d846d9d1243 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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. @@ -20,8 +20,6 @@ import java.io.Serializable; import java.lang.reflect.Method; import java.util.Collection; -import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.Set; @@ -33,6 +31,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.support.MethodReplacer; +import org.springframework.beans.testfixture.beans.FactoryMethods; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.IndexedTestBean; import org.springframework.beans.testfixture.beans.TestBean; @@ -305,102 +304,6 @@ public TestBean getTestBean2() { } -/** - * Test class for Spring's ability to create objects using static - * factory methods, rather than constructors. - * - * @author Rod Johnson - * @author Juergen Hoeller - */ -@SuppressWarnings("unused") -class FactoryMethods { - - public static FactoryMethods nullInstance() { - return null; - } - - public static FactoryMethods defaultInstance() { - TestBean tb = new TestBean(); - tb.setName("defaultInstance"); - return new FactoryMethods(tb, "default", 0); - } - - /** - * Note that overloaded methods are supported. - */ - public static FactoryMethods newInstance(TestBean tb) { - return new FactoryMethods(tb, "default", 0); - } - - protected static FactoryMethods newInstance(TestBean tb, int num, String name) { - if (name == null) { - throw new IllegalStateException("Should never be called with null value"); - } - return new FactoryMethods(tb, name, num); - } - - static FactoryMethods newInstance(TestBean tb, int num, Integer something) { - if (something != null) { - throw new IllegalStateException("Should never be called with non-null value"); - } - return new FactoryMethods(tb, null, num); - } - - private static List listInstance() { - return Collections.EMPTY_LIST; - } - - private int num = 0; - private String name = "default"; - private TestBean tb; - private String stringValue; - - /** - * Constructor is private: not for use outside this class, - * even by IoC container. - */ - private FactoryMethods(TestBean tb, String name, int num) { - this.tb = tb; - this.name = name; - this.num = num; - } - - public void setStringValue(String stringValue) { - this.stringValue = stringValue; - } - - public String getStringValue() { - return this.stringValue; - } - - public TestBean getTestBean() { - return this.tb; - } - - protected TestBean protectedGetTestBean() { - return this.tb; - } - - private TestBean privateGetTestBean() { - return this.tb; - } - - public int getNum() { - return num; - } - - public String getName() { - return name; - } - - /** - * Set via Setter Injection once instance is created. - */ - public void setName(String name) { - this.name = name; - } -} - /** * Fixed method replacer for String return types * @author Rod Johnson diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java index 4a66ed91ef03..0fed592d03ca 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java @@ -53,6 +53,7 @@ import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.testfixture.beans.DependenciesBean; import org.springframework.beans.testfixture.beans.DerivedTestBean; +import org.springframework.beans.testfixture.beans.FactoryMethods; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.IndexedTestBean; import org.springframework.beans.testfixture.beans.TestBean; diff --git a/spring-context/src/test/java/org/springframework/tests/sample/beans/FactoryMethods.java b/spring-context/src/test/java/org/springframework/tests/sample/beans/FactoryMethods.java deleted file mode 100644 index 534f23de4198..000000000000 --- a/spring-context/src/test/java/org/springframework/tests/sample/beans/FactoryMethods.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2002-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.tests.sample.beans; - -/** - * Test class for Spring's ability to create objects using static - * factory methods, rather than constructors. - * - * @author Rod Johnson - * @author Juergen Hoeller - * @author Chris Beams - */ -public class FactoryMethods { - - public static FactoryMethods nullInstance() { - return null; - } - -} diff --git a/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml index 9d25bab05948..62900b1c4173 100644 --- a/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/config/PrototypeProxyTests-context.xml @@ -15,8 +15,6 @@ - - diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml index 0c2fc310727f..a39f9c0268de 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-constructorOverrides.xml @@ -25,7 +25,7 @@ diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml index e88d1667d3c7..02f14e6fa8c5 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-invalidOverridesNoSuchMethod.xml @@ -16,7 +16,7 @@ 30 - diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-noSuchFactoryMethod.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-noSuchFactoryMethod.xml index 68c29936feec..40ac4309ce46 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-noSuchFactoryMethod.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-noSuchFactoryMethod.xml @@ -4,7 +4,7 @@ - setterString From 5581f3b77b8d1f0b274f23a27a4409a90147594b Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 29 Dec 2019 18:38:33 +0100 Subject: [PATCH 0249/2315] Use Gradle test fixture support for spring-tx See gh-23550 --- .../build/testsources/TestSourcesPlugin.java | 8 ++++---- integration-tests/integration-tests.gradle | 1 + .../AdvisorAutoProxyCreatorIntegrationTests.java | 2 +- ...heduledAndTransactionalAnnotationIntegrationTests.java | 2 +- .../EnableTransactionManagementIntegrationTests.java | 2 +- .../AdvisorAutoProxyCreatorIntegrationTests-context.xml | 2 +- spring-aspects/spring-aspects.gradle | 1 + .../transaction/aspectj/JtaTransactionAspectsTests.java | 2 +- .../transaction/aspectj/TransactionAspectTests.java | 2 +- spring-context-support/spring-context-support.gradle | 1 + .../cache/jcache/JCacheEhCacheAnnotationTests.java | 2 +- .../transaction/TransactionAwareCacheDecoratorTests.java | 2 +- spring-jms/spring-jms.gradle | 1 + .../jms/config/jmsNamespaceHandlerTests.xml | 2 +- spring-test/spring-test.gradle | 1 + ...ookUpTxMgrViaTransactionManagementConfigurerTests.java | 2 +- .../junit4/spr9645/LookUpNonexistentTxMgrTests.java | 2 +- .../spr9645/LookUpTxMgrByTypeAndDefaultNameTests.java | 2 +- .../junit4/spr9645/LookUpTxMgrByTypeAndNameTests.java | 2 +- .../LookUpTxMgrByTypeAndQualifierAtClassLevelTests.java | 2 +- .../LookUpTxMgrByTypeAndQualifierAtMethodLevelTests.java | 2 +- .../context/junit4/spr9645/LookUpTxMgrByTypeTests.java | 2 +- .../transaction/JtaTransactionManagerTests.java | 1 - .../{tests => }/transaction/MockJtaTransaction.java | 2 +- .../transaction/TxNamespaceHandlerTests.java | 2 +- .../AnnotationTransactionAttributeSourceTests.java | 2 +- .../annotation/AnnotationTransactionInterceptorTests.java | 2 +- .../AnnotationTransactionNamespaceHandlerTests.java | 2 +- .../annotation/EnableTransactionManagementTests.java | 2 +- .../transaction/config/AnnotationDrivenTests.java | 2 +- .../transaction/config/NoSynchTransactionManager.java | 2 +- .../transaction/config/SynchTransactionManager.java | 2 +- .../config/TransactionManagerConfiguration.java | 2 +- .../event/TransactionalEventListenerTests.java | 2 +- .../interceptor/BeanFactoryTransactionTests.java | 2 +- .../transaction/support/SimpleTransactionScopeTests.java | 2 +- .../annotationTransactionNamespaceHandlerTests.xml | 2 +- .../config/annotationDrivenProxyTargetClassTests.xml | 4 ++-- .../transaction/txNamespaceHandlerTests.xml | 2 +- .../testfixture}/CallCountingTransactionManager.java | 4 ++-- 40 files changed, 44 insertions(+), 40 deletions(-) rename spring-tx/src/test/java/org/springframework/{tests => }/transaction/MockJtaTransaction.java (96%) rename spring-tx/src/{test/java/org/springframework/tests/transaction => testFixtures/java/org/springframework/transaction/testfixture}/CallCountingTransactionManager.java (93%) diff --git a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java index 0248464cc189..c2ced0a4e90a 100644 --- a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java +++ b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java @@ -73,11 +73,11 @@ public class TestSourcesPlugin implements Plugin { "spring-jcl", "spring-jdbc", "spring-jms", - "spring-messaging" - // "spring-orm", - // "spring-oxm", + "spring-messaging", + "spring-orm", + "spring-oxm", // "spring-test", - // "spring-tx", + "spring-tx" // "spring-web", // "spring-webflux", // "spring-webmvc", diff --git a/integration-tests/integration-tests.gradle b/integration-tests/integration-tests.gradle index 539c743372d8..add7b601218b 100644 --- a/integration-tests/integration-tests.gradle +++ b/integration-tests/integration-tests.gradle @@ -9,6 +9,7 @@ dependencies { testCompile(project(":spring-core")) testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-core"))) + testCompile(testFixtures(project(":spring-tx"))) testCompile(project(":spring-expression")) testCompile(project(":spring-jdbc")) testCompile(project(":spring-orm")) diff --git a/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java b/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java index 987c643a65cd..ed77a4519385 100644 --- a/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java @@ -34,9 +34,9 @@ import org.springframework.tests.aop.advice.CountingBeforeAdvice; import org.springframework.tests.aop.advice.MethodCounter; import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.NoTransactionException; import org.springframework.transaction.interceptor.TransactionInterceptor; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java b/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java index af771522f825..8b49193b8630 100644 --- a/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java @@ -32,10 +32,10 @@ import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.dao.support.PersistenceExceptionTranslator; import org.springframework.stereotype.Repository; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java b/integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java index 20dfe81d2f86..8ba437386b04 100644 --- a/integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java @@ -40,9 +40,9 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.stereotype.Repository; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml b/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml index ab6309ff35be..504b77040094 100644 --- a/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml +++ b/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml @@ -34,7 +34,7 @@ - + diff --git a/spring-aspects/spring-aspects.gradle b/spring-aspects/spring-aspects.gradle index 26bd68f88212..d9b42ea4f712 100644 --- a/spring-aspects/spring-aspects.gradle +++ b/spring-aspects/spring-aspects.gradle @@ -27,6 +27,7 @@ dependencies { testCompile(testFixtures(project(":spring-context"))) testCompile(testFixtures(project(":spring-context-support"))) testCompile(testFixtures(project(":spring-core"))) + testCompile(testFixtures(project(":spring-tx"))) testCompile("javax.mail:javax.mail-api") testCompileOnly("org.aspectj:aspectjrt") } diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java index aa478ba43c49..e0bd918a72ea 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java @@ -27,7 +27,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import org.springframework.tests.transaction.CallCountingTransactionManager; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java index 978b2e2da700..722c357d20e2 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.tests.transaction.CallCountingTransactionManager; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context-support/spring-context-support.gradle b/spring-context-support/spring-context-support.gradle index 47ad91ccfad3..f8a8631293ad 100644 --- a/spring-context-support/spring-context-support.gradle +++ b/spring-context-support/spring-context-support.gradle @@ -18,6 +18,7 @@ dependencies { testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-context"))) testCompile(testFixtures(project(":spring-core"))) + testCompile(testFixtures(project(":spring-tx"))) testCompile("org.hsqldb:hsqldb") testCompile("org.hibernate:hibernate-validator") testCompile("javax.annotation:javax.annotation-api") diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java index 16bf56235483..188cc293c974 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java @@ -39,8 +39,8 @@ import org.springframework.context.testfixture.cache.beans.AnnotatedClassCacheableService; import org.springframework.context.testfixture.cache.beans.CacheableService; import org.springframework.context.testfixture.cache.beans.DefaultCacheableService; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.support.TransactionTemplate; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; /** * @author Stephane Nicoll diff --git a/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java b/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java index 74337eb76e48..66369edfe6c0 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java @@ -20,8 +20,8 @@ import org.springframework.cache.Cache; import org.springframework.cache.concurrent.ConcurrentMapCache; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.support.TransactionTemplate; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-jms/spring-jms.gradle b/spring-jms/spring-jms.gradle index e47e9458ce5a..784aead7da80 100644 --- a/spring-jms/spring-jms.gradle +++ b/spring-jms/spring-jms.gradle @@ -13,5 +13,6 @@ dependencies { optional("javax.transaction:javax.transaction-api") optional("com.fasterxml.jackson.core:jackson-databind") testCompile(testFixtures(project(":spring-beans"))) + testCompile(testFixtures(project(":spring-tx"))) testImplementation("javax.jms:javax.jms-api") } diff --git a/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml b/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml index 46d15b9eef58..e932080e2e4c 100644 --- a/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml +++ b/spring-jms/src/test/resources/org/springframework/jms/config/jmsNamespaceHandlerTests.xml @@ -68,7 +68,7 @@ - + diff --git a/spring-test/spring-test.gradle b/spring-test/spring-test.gradle index 053ab77e3bdf..ec8708a8854e 100644 --- a/spring-test/spring-test.gradle +++ b/spring-test/spring-test.gradle @@ -45,6 +45,7 @@ dependencies { testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-context"))) testCompile(testFixtures(project(":spring-core"))) + testCompile(testFixtures(project(":spring-tx"))) testCompile("javax.annotation:javax.annotation-api") testCompile("javax.cache:cache-api") testCompile("javax.ejb:javax.ejb-api") diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9604/LookUpTxMgrViaTransactionManagementConfigurerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9604/LookUpTxMgrViaTransactionManagementConfigurerTests.java index 732275e3842d..c1bcfec1e2f3 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9604/LookUpTxMgrViaTransactionManagementConfigurerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9604/LookUpTxMgrViaTransactionManagementConfigurerTests.java @@ -25,10 +25,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.TransactionManagementConfigurer; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpNonexistentTxMgrTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpNonexistentTxMgrTests.java index e32f9117b283..5958079e45b4 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpNonexistentTxMgrTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpNonexistentTxMgrTests.java @@ -23,8 +23,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndDefaultNameTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndDefaultNameTests.java index a832dd62157e..6f2b0915045b 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndDefaultNameTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndDefaultNameTests.java @@ -25,9 +25,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndNameTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndNameTests.java index 544158a6710b..f14ffe106cc5 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndNameTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndNameTests.java @@ -25,9 +25,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndQualifierAtClassLevelTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndQualifierAtClassLevelTests.java index 5823fc4f188f..9f507a992398 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndQualifierAtClassLevelTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndQualifierAtClassLevelTests.java @@ -25,9 +25,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndQualifierAtMethodLevelTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndQualifierAtMethodLevelTests.java index 9c576c824631..b3aef4e781c1 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndQualifierAtMethodLevelTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndQualifierAtMethodLevelTests.java @@ -25,9 +25,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeTests.java index ebbab9f6103e..835a911a72fd 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeTests.java @@ -25,9 +25,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java b/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java index 2bb3a64b199a..ef2b461a21cf 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java @@ -30,7 +30,6 @@ import org.junit.jupiter.api.Test; import org.springframework.dao.OptimisticLockingFailureException; -import org.springframework.tests.transaction.MockJtaTransaction; import org.springframework.transaction.jta.JtaTransactionManager; import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.transaction.support.TransactionCallbackWithoutResult; diff --git a/spring-tx/src/test/java/org/springframework/tests/transaction/MockJtaTransaction.java b/spring-tx/src/test/java/org/springframework/transaction/MockJtaTransaction.java similarity index 96% rename from spring-tx/src/test/java/org/springframework/tests/transaction/MockJtaTransaction.java rename to spring-tx/src/test/java/org/springframework/transaction/MockJtaTransaction.java index 8569ef31896c..2adbfa549bce 100644 --- a/spring-tx/src/test/java/org/springframework/tests/transaction/MockJtaTransaction.java +++ b/spring-tx/src/test/java/org/springframework/transaction/MockJtaTransaction.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.transaction; +package org.springframework.transaction; import javax.transaction.Status; import javax.transaction.Synchronization; diff --git a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java index f3fd77f005b4..65367a1df7e8 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java @@ -25,10 +25,10 @@ import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.interceptor.TransactionAttribute; import org.springframework.transaction.interceptor.TransactionAttributeSource; import org.springframework.transaction.interceptor.TransactionInterceptor; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java index bb869e84744f..cf1de5525bf2 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java @@ -32,12 +32,12 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.testfixture.io.SerializationTestUtils; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.interceptor.NoRollbackRuleAttribute; import org.springframework.transaction.interceptor.RollbackRuleAttribute; import org.springframework.transaction.interceptor.RuleBasedTransactionAttribute; import org.springframework.transaction.interceptor.TransactionAttribute; import org.springframework.transaction.interceptor.TransactionInterceptor; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java index 561c41d6e768..c7477db01575 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java @@ -20,9 +20,9 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.interceptor.TransactionInterceptor; import org.springframework.transaction.support.TransactionSynchronizationManager; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java index a485250e9a1e..3f4814bd9e24 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java @@ -32,9 +32,9 @@ import org.springframework.jmx.export.annotation.ManagedOperation; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.stereotype.Service; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.config.TransactionManagementConfigUtils; import org.springframework.transaction.event.TransactionalEventListenerFactory; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java index be89cce0bff5..e2016f106729 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java @@ -33,10 +33,10 @@ import org.springframework.context.annotation.ConfigurationCondition; import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.stereotype.Service; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.config.TransactionManagementConfigUtils; import org.springframework.transaction.event.TransactionalEventListenerFactory; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java b/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java index 5760d3b351a0..2d19c185e574 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java @@ -28,8 +28,8 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.testfixture.io.SerializationTestUtils; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.support.TransactionSynchronizationManager; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-tx/src/test/java/org/springframework/transaction/config/NoSynchTransactionManager.java b/spring-tx/src/test/java/org/springframework/transaction/config/NoSynchTransactionManager.java index a4e6ec1b548c..a537a1a50af1 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/config/NoSynchTransactionManager.java +++ b/spring-tx/src/test/java/org/springframework/transaction/config/NoSynchTransactionManager.java @@ -16,7 +16,7 @@ package org.springframework.transaction.config; -import org.springframework.tests.transaction.CallCountingTransactionManager; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; /** * @author Juergen Hoeller diff --git a/spring-tx/src/test/java/org/springframework/transaction/config/SynchTransactionManager.java b/spring-tx/src/test/java/org/springframework/transaction/config/SynchTransactionManager.java index a09e1582df3e..7969ec56204e 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/config/SynchTransactionManager.java +++ b/spring-tx/src/test/java/org/springframework/transaction/config/SynchTransactionManager.java @@ -17,7 +17,7 @@ package org.springframework.transaction.config; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.tests.transaction.CallCountingTransactionManager; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; /** * @author Juergen Hoeller diff --git a/spring-tx/src/test/java/org/springframework/transaction/config/TransactionManagerConfiguration.java b/spring-tx/src/test/java/org/springframework/transaction/config/TransactionManagerConfiguration.java index af0e5a351cbc..638f40248db8 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/config/TransactionManagerConfiguration.java +++ b/spring-tx/src/test/java/org/springframework/transaction/config/TransactionManagerConfiguration.java @@ -19,8 +19,8 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; /** * @author Juergen Hoeller diff --git a/spring-tx/src/test/java/org/springframework/transaction/event/TransactionalEventListenerTests.java b/spring-tx/src/test/java/org/springframework/transaction/event/TransactionalEventListenerTests.java index edb5a8494f48..98b3b22318f7 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/event/TransactionalEventListenerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/event/TransactionalEventListenerTests.java @@ -38,13 +38,13 @@ import org.springframework.context.event.EventListener; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionSynchronizationAdapter; import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionTemplate; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java index bf2f8012d0aa..0f49ea78350b 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java @@ -36,11 +36,11 @@ import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.lang.Nullable; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionException; import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java index c99774c71675..0f3d0f3772ab 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java @@ -26,7 +26,7 @@ import org.springframework.beans.testfixture.beans.DerivedTestBean; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.tests.transaction.CallCountingTransactionManager; +import org.springframework.transaction.testfixture.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-tx/src/test/resources/org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml b/spring-tx/src/test/resources/org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml index 868ac0c6d902..e76c84e45997 100644 --- a/spring-tx/src/test/resources/org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml +++ b/spring-tx/src/test/resources/org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml @@ -9,7 +9,7 @@ - + diff --git a/spring-tx/src/test/resources/org/springframework/transaction/config/annotationDrivenProxyTargetClassTests.xml b/spring-tx/src/test/resources/org/springframework/transaction/config/annotationDrivenProxyTargetClassTests.xml index fc59ae34b5bf..69ff36c4ae75 100644 --- a/spring-tx/src/test/resources/org/springframework/transaction/config/annotationDrivenProxyTargetClassTests.xml +++ b/spring-tx/src/test/resources/org/springframework/transaction/config/annotationDrivenProxyTargetClassTests.xml @@ -12,11 +12,11 @@ - + - + diff --git a/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml b/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml index 8e3b2411fdae..5214570c815b 100644 --- a/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml +++ b/spring-tx/src/test/resources/org/springframework/transaction/txNamespaceHandlerTests.xml @@ -26,7 +26,7 @@ - + diff --git a/spring-tx/src/test/java/org/springframework/tests/transaction/CallCountingTransactionManager.java b/spring-tx/src/testFixtures/java/org/springframework/transaction/testfixture/CallCountingTransactionManager.java similarity index 93% rename from spring-tx/src/test/java/org/springframework/tests/transaction/CallCountingTransactionManager.java rename to spring-tx/src/testFixtures/java/org/springframework/transaction/testfixture/CallCountingTransactionManager.java index fd6acbad77f3..8295522e8435 100644 --- a/spring-tx/src/test/java/org/springframework/tests/transaction/CallCountingTransactionManager.java +++ b/spring-tx/src/testFixtures/java/org/springframework/transaction/testfixture/CallCountingTransactionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2019 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.tests.transaction; +package org.springframework.transaction.testfixture; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.support.AbstractPlatformTransactionManager; From 8a371c76697a596ff409cb63c6cadde6660e140c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 29 Dec 2019 19:15:23 +0100 Subject: [PATCH 0250/2315] Use Gradle test fixture support for spring-aop See gh-23550 --- .../build/testsources/TestSourcesPlugin.java | 3 +- integration-tests/integration-tests.gradle | 1 + ...visorAutoProxyCreatorIntegrationTests.java | 6 ++-- ...toProxyCreatorIntegrationTests-context.xml | 2 +- spring-aop/spring-aop.gradle | 1 + .../aop/framework/ProxyFactoryTests.java | 30 ++----------------- .../adapter/ThrowsAdviceInterceptorTests.java | 24 +-------------- .../aop/support/AopUtilsTests.java | 2 +- .../aop/support/ControlFlowPointcutTests.java | 2 +- ...elegatingIntroductionInterceptorTests.java | 2 +- .../support/NameMatchMethodPointcutTests.java | 4 +-- ...MethodPointcutAdvisorIntegrationTests.java | 4 +-- .../target/HotSwappableTargetSourceTests.java | 2 +- ...poseInvocationInterceptorTests-context.xml | 4 +-- ...ointcutAdvisorIntegrationTests-context.xml | 2 +- .../PrototypeTargetSourceTests-context.xml | 2 +- .../ThreadLocalTargetSourceTests-context.xml | 2 +- .../advice/CountingAfterReturningAdvice.java | 4 +-- .../advice/CountingBeforeAdvice.java | 4 +-- .../testfixture}/advice/MethodCounter.java | 4 +-- .../testfixture}/advice/MyThrowsHandler.java | 5 +++- .../advice/TimestampIntroductionAdvisor.java | 4 +-- .../interceptor/NopInterceptor.java | 2 +- .../SerializableNopInterceptor.java | 2 +- .../TimestampIntroductionInterceptor.java | 2 +- spring-context/spring-context.gradle | 1 + .../aop/config/AopNamespaceHandlerTests.java | 2 +- .../aop/framework/AbstractAopProxyTests.java | 14 ++++----- .../aop/framework/CglibProxyTests.java | 4 +-- .../aop/framework/ProxyFactoryBeanTests.java | 8 ++--- .../AdvisorAutoProxyCreatorTests.java | 4 +-- .../BeanNameAutoProxyCreatorTests.java | 4 +-- .../support/CustomNamespaceHandlerTests.java | 2 +- .../jmx/export/MBeanExporterTests.java | 2 +- .../AbstractMetadataAssemblerTests.java | 2 +- ...pNamespaceHandlerAdviceTypeTests-error.xml | 4 +-- .../AopNamespaceHandlerAdviceTypeTests-ok.xml | 4 +-- ...AopNamespaceHandlerArgNamesTests-error.xml | 4 +-- .../AopNamespaceHandlerArgNamesTests-ok.xml | 4 +-- ...ceHandlerProxyTargetClassTests-context.xml | 4 +-- ...opNamespaceHandlerReturningTests-error.xml | 4 +-- .../AopNamespaceHandlerReturningTests-ok.xml | 4 +-- .../AopNamespaceHandlerTests-context.xml | 4 +-- ...AopNamespaceHandlerThrowingTests-error.xml | 4 +-- .../AopNamespaceHandlerThrowingTests-ok.xml | 4 +-- .../ProxyFactoryBeanTests-autowiring.xml | 2 +- .../ProxyFactoryBeanTests-context.xml | 2 +- ...xyFactoryBeanTests-double-targetsource.xml | 2 +- .../ProxyFactoryBeanTests-frozen.xml | 2 +- ...roxyFactoryBeanTests-inner-bean-target.xml | 2 +- ...yFactoryBeanTests-notlast-targetsource.xml | 2 +- .../ProxyFactoryBeanTests-prototype.xml | 2 +- .../ProxyFactoryBeanTests-serialization.xml | 4 +-- .../ProxyFactoryBeanTests-targetsource.xml | 4 +-- .../ProxyFactoryBeanTests-throws-advice.xml | 6 ++-- ...oProxyCreatorTests-common-interceptors.xml | 4 +-- ...AdvisorAutoProxyCreatorTests-optimized.xml | 2 +- .../BeanNameAutoProxyCreatorTests-context.xml | 8 ++--- .../CommonsPool2TargetSourceTests-context.xml | 4 +-- 59 files changed, 105 insertions(+), 144 deletions(-) rename spring-aop/src/{test/java/org/springframework/tests/aop => testFixtures/java/org/springframework/aop/testfixture}/advice/CountingAfterReturningAdvice.java (90%) rename spring-aop/src/{test/java/org/springframework/tests/aop => testFixtures/java/org/springframework/aop/testfixture}/advice/CountingBeforeAdvice.java (90%) rename spring-aop/src/{test/java/org/springframework/tests/aop => testFixtures/java/org/springframework/aop/testfixture}/advice/MethodCounter.java (94%) rename spring-aop/src/{test/java/org/springframework/tests/aop => testFixtures/java/org/springframework/aop/testfixture}/advice/MyThrowsHandler.java (95%) rename spring-aop/src/{test/java/org/springframework/tests/aop => testFixtures/java/org/springframework/aop/testfixture}/advice/TimestampIntroductionAdvisor.java (88%) rename spring-aop/src/{test/java/org/springframework/tests/aop => testFixtures/java/org/springframework/aop/testfixture}/interceptor/NopInterceptor.java (96%) rename spring-aop/src/{test/java/org/springframework/tests/aop => testFixtures/java/org/springframework/aop/testfixture}/interceptor/SerializableNopInterceptor.java (95%) rename spring-aop/src/{test/java/org/springframework/tests/aop => testFixtures/java/org/springframework/aop/testfixture}/interceptor/TimestampIntroductionInterceptor.java (95%) diff --git a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java index c2ced0a4e90a..130a5cac22e3 100644 --- a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java +++ b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java @@ -62,7 +62,8 @@ public class TestSourcesPlugin implements Plugin { private static final List excludedProjects = Arrays.asList( "integration-tests", "kotlin-coroutines", - // "spring-aop", + "spring-aop", + "spring-aspects", "spring-beans", "spring-context", "spring-context-indexer", diff --git a/integration-tests/integration-tests.gradle b/integration-tests/integration-tests.gradle index add7b601218b..5e18462c1e84 100644 --- a/integration-tests/integration-tests.gradle +++ b/integration-tests/integration-tests.gradle @@ -7,6 +7,7 @@ dependencies { testCompile(project(":spring-beans")) testCompile(project(":spring-context")) testCompile(project(":spring-core")) + testCompile(testFixtures(project(":spring-aop"))) testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-core"))) testCompile(testFixtures(project(":spring-tx"))) diff --git a/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java b/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java index ed77a4519385..cf067e01415c 100644 --- a/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java @@ -26,14 +26,14 @@ import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; +import org.springframework.aop.testfixture.advice.CountingBeforeAdvice; +import org.springframework.aop.testfixture.advice.MethodCounter; +import org.springframework.aop.testfixture.interceptor.NopInterceptor; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.lang.Nullable; -import org.springframework.tests.aop.advice.CountingBeforeAdvice; -import org.springframework.tests.aop.advice.MethodCounter; -import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.transaction.NoTransactionException; import org.springframework.transaction.interceptor.TransactionInterceptor; import org.springframework.transaction.testfixture.CallCountingTransactionManager; diff --git a/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml b/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml index 504b77040094..90ea7dc1f663 100644 --- a/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml +++ b/integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml @@ -85,7 +85,7 @@ org.springframework.beans.testfixture.beans.ITestBean.getName - + 4 diff --git a/spring-aop/spring-aop.gradle b/spring-aop/spring-aop.gradle index 64c8fc6ef607..73bb378f39a7 100644 --- a/spring-aop/spring-aop.gradle +++ b/spring-aop/spring-aop.gradle @@ -8,4 +8,5 @@ dependencies { optional("com.jamonapi:jamon") testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-core"))) + testFixturesImplementation(testFixtures(project(":spring-core"))) } diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java index 033824508e26..2ae1d635116d 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java @@ -33,15 +33,15 @@ import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.DefaultIntroductionAdvisor; import org.springframework.aop.support.DefaultPointcutAdvisor; -import org.springframework.aop.support.DelegatingIntroductionInterceptor; +import org.springframework.aop.testfixture.advice.CountingBeforeAdvice; +import org.springframework.aop.testfixture.interceptor.NopInterceptor; +import org.springframework.aop.testfixture.interceptor.TimestampIntroductionInterceptor; import org.springframework.beans.testfixture.beans.IOther; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.Order; import org.springframework.core.testfixture.TimeStamped; -import org.springframework.tests.aop.advice.CountingBeforeAdvice; -import org.springframework.tests.aop.interceptor.NopInterceptor; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -371,30 +371,6 @@ public void testInterceptorWithoutJoinpoint() { } - @SuppressWarnings("serial") - private static class TimestampIntroductionInterceptor extends DelegatingIntroductionInterceptor - implements TimeStamped { - - private long ts; - - public TimestampIntroductionInterceptor() { - } - - public TimestampIntroductionInterceptor(long ts) { - this.ts = ts; - } - - public void setTime(long ts) { - this.ts = ts; - } - - @Override - public long getTimeStamp() { - return ts; - } - } - - @Order(2) public static class A implements Runnable { diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java index a836bcc00314..2c1060274e74 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java @@ -17,16 +17,13 @@ package org.springframework.aop.framework.adapter; import java.io.FileNotFoundException; -import java.io.IOException; -import java.lang.reflect.Method; import java.rmi.ConnectException; import java.rmi.RemoteException; import org.aopalliance.intercept.MethodInvocation; import org.junit.jupiter.api.Test; -import org.springframework.aop.ThrowsAdvice; -import org.springframework.tests.aop.advice.MethodCounter; +import org.springframework.aop.testfixture.advice.MyThrowsHandler; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -128,23 +125,4 @@ public void afterThrowing(RemoteException ex) throws Throwable { assertThat(th.getCalls("remoteException")).isEqualTo(1); } - - @SuppressWarnings("serial") - static class MyThrowsHandler extends MethodCounter implements ThrowsAdvice { - - // Full method signature - public void afterThrowing(Method m, Object[] args, Object target, IOException ex) { - count("ioException"); - } - - public void afterThrowing(RemoteException ex) throws Throwable { - count("remoteException"); - } - - /** Not valid, wrong number of arguments */ - public void afterThrowing(Method m, Exception ex) throws Throwable { - throw new UnsupportedOperationException("Shouldn't be called"); - } - } - } diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java index eeeedd8efb96..dc5437e6cd67 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java @@ -25,10 +25,10 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.target.EmptyTargetSource; +import org.springframework.aop.testfixture.interceptor.NopInterceptor; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.testfixture.io.SerializationTestUtils; import org.springframework.lang.Nullable; -import org.springframework.tests.aop.interceptor.NopInterceptor; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java index 69251aaebc43..f86c6e7ca9f1 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java @@ -20,9 +20,9 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.framework.ProxyFactory; +import org.springframework.aop.testfixture.interceptor.NopInterceptor; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.TestBean; -import org.springframework.tests.aop.interceptor.NopInterceptor; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java index b0330ff68214..4325e582704f 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java @@ -24,6 +24,7 @@ import org.springframework.aop.IntroductionAdvisor; import org.springframework.aop.IntroductionInterceptor; import org.springframework.aop.framework.ProxyFactory; +import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor; import org.springframework.beans.testfixture.beans.INestedTestBean; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.NestedTestBean; @@ -32,7 +33,6 @@ import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.testfixture.TimeStamped; import org.springframework.core.testfixture.io.SerializationTestUtils; -import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java index e344536e21ac..98f7ca29a97e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java @@ -21,11 +21,11 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; +import org.springframework.aop.testfixture.interceptor.NopInterceptor; +import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor; import org.springframework.beans.testfixture.beans.Person; import org.springframework.beans.testfixture.beans.SerializablePerson; import org.springframework.core.testfixture.io.SerializationTestUtils; -import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java index 00021faeb8ff..de3886ef85ee 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java @@ -19,6 +19,8 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; +import org.springframework.aop.testfixture.interceptor.NopInterceptor; +import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.testfixture.beans.ITestBean; @@ -26,8 +28,6 @@ import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.Resource; import org.springframework.core.testfixture.io.SerializationTestUtils; -import org.springframework.tests.aop.interceptor.NopInterceptor; -import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java index ca10d0f1b93d..a3354a5587f7 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java @@ -23,13 +23,13 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.support.DefaultPointcutAdvisor; +import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.testfixture.beans.Person; import org.springframework.beans.testfixture.beans.SerializablePerson; import org.springframework.beans.testfixture.beans.SideEffectBean; import org.springframework.core.testfixture.io.SerializationTestUtils; -import org.springframework.tests.aop.interceptor.SerializableNopInterceptor; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/resources/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests-context.xml index 1bfd0c2814b7..a5bf0f37d9c1 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests-context.xml @@ -6,7 +6,7 @@ --> - + @@ -15,7 +15,7 @@ INSTANCE - + diff --git a/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml index b4e8fec10d26..967e42b6868a 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml @@ -9,7 +9,7 @@ 666 - + diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml index 9689ba92e8fc..53513ecf1df6 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml @@ -16,7 +16,7 @@ prototypeTest - + debugInterceptor,test diff --git a/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml b/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml index 40f77d3f9799..778c8c1d7f0e 100644 --- a/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml +++ b/spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml @@ -11,7 +11,7 @@ prototypeTest - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml index b7eaa18ef82c..a8a77341e528 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml @@ -9,7 +9,7 @@ 666 - + org.springframework.beans.testfixture.beans.ITestBean diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-double-targetsource.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-double-targetsource.xml index 3fb58b993c86..4738c1abc5ce 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-double-targetsource.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-double-targetsource.xml @@ -27,7 +27,7 @@ - + - + - + - + serializableNopInterceptor diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml index 46fb7b112d34..0bc1a3eb4877 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-targetsource.xml @@ -13,11 +13,11 @@ Adam - + - + - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml index b5db44fbac4c..7819d2c86dbc 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml @@ -17,7 +17,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml index 20adb97333cc..a3da2c1bb2ba 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml @@ -7,7 +7,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml index 3a228ff01db5..95f25cdedb96 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml @@ -59,7 +59,7 @@ - + - + From 7b6d83a106a0e2267f40d57d2aa24503196533af Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 31 Dec 2019 14:58:51 +0100 Subject: [PATCH 0251/2315] Use Gradle test fixture support for spring-web See gh-23550 --- .../build/testsources/TestSourcesPlugin.java | 8 +- spring-orm/spring-orm.gradle | 1 + .../support/OpenEntityManagerInViewTests.java | 12 +- spring-test/spring-test.gradle | 1 + .../server/samples/bind/HttpServerTests.java | 2 +- .../setup/StandaloneMockMvcBuilderTests.java | 2 +- spring-web/spring-web.gradle | 6 + .../codec/CancelWithoutDemandCodecTests.java | 1 + .../codec/EncoderHttpMessageWriterTests.java | 2 +- .../codec/FormHttpMessageReaderTests.java | 2 +- .../codec/FormHttpMessageWriterTests.java | 2 +- .../codec/ResourceHttpMessageWriterTests.java | 6 +- ...ServerSentEventHttpMessageReaderTests.java | 3 +- ...ServerSentEventHttpMessageWriterTests.java | 3 +- .../codec/cbor/Jackson2CborDecoderTests.java | 2 +- .../codec/cbor/Jackson2CborEncoderTests.java | 2 +- .../codec/json/Jackson2JsonDecoderTests.java | 2 +- .../codec/json/Jackson2JsonEncoderTests.java | 2 +- .../codec/json/Jackson2SmileDecoderTests.java | 2 +- .../codec/json/Jackson2SmileEncoderTests.java | 2 +- .../MultipartHttpMessageWriterTests.java | 4 +- ...SynchronossPartHttpMessageReaderTests.java | 4 +- .../http/codec/xml/Jaxb2XmlDecoderTests.java | 2 +- .../http/codec/xml/Jaxb2XmlEncoderTests.java | 2 +- ...jectToStringHttpMessageConverterTests.java | 4 +- .../server/ServletServerHttpRequestTests.java | 2 +- .../ServletServerHttpResponseTests.java | 2 +- .../reactive/AsyncIntegrationTests.java | 3 +- .../ContextPathCompositeHandlerTests.java | 4 +- .../reactive/CookieIntegrationTests.java | 3 +- .../reactive/EchoHandlerIntegrationTests.java | 3 +- .../ErrorHandlerIntegrationTests.java | 3 +- .../HttpHeadResponseDecoratorTests.java | 2 +- .../reactive/MultipartIntegrationTests.java | 3 +- .../RandomHandlerIntegrationTests.java | 3 +- .../ServerHttpRequestIntegrationTests.java | 3 +- .../reactive/ServerHttpRequestTests.java | 8 +- .../ServerHttpsRequestIntegrationTests.java | 4 +- .../WriteOnlyHandlerIntegrationTests.java | 3 +- .../reactive/ZeroCopyIntegrationTests.java | 24 ++-- .../reactive/bootstrap/package-info.java | 5 - .../httpinvoker/HttpInvokerTests.java | 4 +- ...entNegotiationManagerFactoryBeanTests.java | 4 +- ...HeaderContentNegotiationStrategyTests.java | 2 +- ...ensionContentNegotiationStrategyTests.java | 2 +- .../bind/ServletRequestDataBinderTests.java | 2 +- .../web/bind/ServletRequestUtilsTests.java | 2 +- .../support/WebExchangeDataBinderTests.java | 8 +- .../support/WebRequestDataBinderTests.java | 6 +- .../ContextLoaderInitializerTests.java | 2 +- .../RequestAndSessionScopedBeanTests.java | 2 +- .../request/RequestContextListenerTests.java | 4 +- .../context/request/RequestScopeTests.java | 2 +- .../request/RequestScopedProxyTests.java | 2 +- .../ServletRequestAttributesTests.java | 4 +- .../ServletWebRequestHttpMethodsTests.java | 4 +- .../request/ServletWebRequestTests.java | 4 +- .../context/request/SessionScopeTests.java | 4 +- .../WebApplicationContextScopeTests.java | 4 +- .../StandardServletAsyncWebRequestTests.java | 6 +- .../async/WebAsyncManagerErrorTests.java | 6 +- .../request/async/WebAsyncManagerTests.java | 2 +- .../async/WebAsyncManagerTimeoutTests.java | 6 +- .../web/context/support/ResourceTests.java | 2 +- .../web/context/support/Spr8510Tests.java | 2 +- .../SpringBeanAutowiringSupportTests.java | 2 +- .../web/cors/CorsUtilsTests.java | 2 +- .../web/cors/DefaultCorsProcessorTests.java | 4 +- .../UrlBasedCorsConfigurationSourceTests.java | 2 +- .../web/cors/reactive/CorsUtilsTests.java | 8 +- .../web/cors/reactive/CorsWebFilterTests.java | 4 +- .../reactive/DefaultCorsProcessorTests.java | 4 +- .../UrlBasedCorsConfigurationSourceTests.java | 4 +- .../filter/CharacterEncodingFilterTests.java | 6 +- .../web/filter/CompositeFilterTests.java | 8 +- .../web/filter/CorsFilterTests.java | 4 +- .../filter/DelegatingFilterProxyTests.java | 8 +- .../web/filter/FormContentFilterTests.java | 6 +- .../filter/ForwardedHeaderFilterTests.java | 6 +- .../filter/HiddenHttpMethodFilterTests.java | 4 +- .../web/filter/OncePerRequestFilterTests.java | 6 +- .../filter/RelativeRedirectFilterTests.java | 6 +- .../web/filter/RequestContextFilterTests.java | 8 +- .../web/filter/RequestLoggingFilterTests.java | 6 +- .../filter/ShallowEtagHeaderFilterTests.java | 4 +- .../reactive/HiddenHttpMethodFilterTests.java | 4 +- .../ServerWebExchangeContextFilterTests.java | 4 +- ...ookieValueMethodArgumentResolverTests.java | 4 +- .../ErrorsMethodArgumentResolverTests.java | 2 +- ...ssionValueMethodArgumentResolverTests.java | 4 +- .../InitBinderDataBinderFactoryTests.java | 2 +- .../annotation/MapMethodProcessorTests.java | 4 +- .../ModelAttributeMethodProcessorTests.java | 2 +- .../annotation/ModelFactoryOrderingTests.java | 4 +- .../method/annotation/ModelFactoryTests.java | 2 +- .../annotation/ModelMethodProcessorTests.java | 2 +- ...tHeaderMapMethodArgumentResolverTests.java | 4 +- ...uestHeaderMethodArgumentResolverTests.java | 4 +- ...stParamMapMethodArgumentResolverTests.java | 14 +-- ...questParamMethodArgumentResolverTests.java | 16 +-- .../SessionAttributesHandlerTests.java | 2 +- .../WebArgumentResolverAdapterTests.java | 2 +- .../support/InvocableHandlerMethodTests.java | 6 +- .../CommonsMultipartResolverTests.java | 10 +- ...faultMultipartHttpServletRequestTests.java | 2 +- ...uestPartServletServerHttpRequestTests.java | 4 +- ...ndardMultipartHttpServletRequestTests.java | 4 +- ...erverWebExchangeCheckNotModifiedTests.java | 6 +- .../DefaultServerWebExchangeTests.java | 4 +- .../ForwardedHeaderTransformerTests.java | 2 +- .../adapter/WebHttpHandlerBuilderTests.java | 4 +- .../ExceptionHandlingWebHandlerTests.java | 4 +- .../handler/FilteringWebHandlerTests.java | 6 +- .../ResponseStatusExceptionHandlerTests.java | 87 +------------- ...cceptHeaderLocaleContextResolverTests.java | 4 +- .../i18n/FixedLocaleContextResolverTests.java | 4 +- .../CookieWebSessionIdResolverTests.java | 4 +- .../DefaultWebSessionManagerTests.java | 4 +- .../HeaderWebSessionIdResolverTests.java | 4 +- .../session/WebSessionIntegrationTests.java | 4 +- .../ContentCachingRequestWrapperTests.java | 2 +- .../ServletContextPropertyUtilsTests.java | 2 +- .../web/util/UriComponentsBuilderTests.java | 2 +- .../web/util/UrlPathHelperTests.java | 2 +- .../web/util/WebUtilsTests.java | 6 +- ...tParamMethodArgumentResolverKotlinTests.kt | 8 +- .../{http/server/reactive => web}/spring.png | Bin .../reactive}/MockClientHttpRequest.java | 2 +- .../reactive}/MockClientHttpResponse.java | 2 +- .../reactive}/MockServerHttpRequest.java | 2 +- .../reactive}/MockServerHttpResponse.java | 2 +- .../AbstractHttpHandlerIntegrationTests.java | 10 +- .../bootstrap/AbstractHttpServer.java | 2 +- .../server/reactive/bootstrap/HttpServer.java | 2 +- .../reactive/bootstrap/JettyHttpServer.java | 2 +- .../reactive/bootstrap/ReactorHttpServer.java | 2 +- .../bootstrap/ReactorHttpsServer.java | 2 +- .../reactive/bootstrap/TomcatHttpServer.java | 2 +- .../bootstrap/UndertowHttpServer.java | 2 +- .../reactive/bootstrap/package-info.java | 6 + .../http/server/reactive}/package-info.java | 2 +- .../method/MvcAnnotationPredicates.java | 6 +- .../testfixture}/method/ResolvableMethod.java | 12 +- .../server/MockServerWebExchange.java | 6 +- .../testfixture}/server/MockWebSession.java | 2 +- ...ctResponseStatusExceptionHandlerTests.java | 113 ++++++++++++++++++ .../web/testfixture}/server/package-info.java | 2 +- .../DelegatingServletInputStream.java | 2 +- .../DelegatingServletOutputStream.java | 2 +- .../servlet}/HeaderValueHolder.java | 2 +- .../servlet}/MockAsyncContext.java | 2 +- .../testfixture/servlet}/MockBodyContent.java | 2 +- .../web/testfixture/servlet}/MockCookie.java | 2 +- .../servlet}/MockExpressionEvaluator.java | 2 +- .../testfixture/servlet}/MockFilterChain.java | 2 +- .../servlet}/MockFilterConfig.java | 2 +- .../servlet}/MockHttpServletRequest.java | 2 +- .../servlet}/MockHttpServletResponse.java | 2 +- .../testfixture/servlet}/MockHttpSession.java | 2 +- .../testfixture/servlet}/MockJspWriter.java | 2 +- .../servlet}/MockMultipartFile.java | 2 +- .../MockMultipartHttpServletRequest.java | 2 +- .../testfixture/servlet}/MockPageContext.java | 2 +- .../web/testfixture/servlet}/MockPart.java | 2 +- .../servlet}/MockRequestDispatcher.java | 2 +- .../servlet}/MockServletConfig.java | 2 +- .../servlet}/MockServletContext.java | 2 +- .../servlet}/MockSessionCookieConfig.java | 2 +- .../servlet}/PassThroughFilterChain.java | 2 +- .../web/testfixture/xml}/Pojo.java | 2 +- .../http/codec/multipart/foo.txt | 0 spring-webflux/spring-webflux.gradle | 1 + .../reactive/DispatcherHandlerErrorTests.java | 4 +- .../web/reactive/DispatcherHandlerTests.java | 6 +- .../reactive/FlushingIntegrationTests.java | 4 +- .../HeaderContentTypeResolverTests.java | 4 +- .../ParameterContentTypeResolverTests.java | 4 +- ...uestedContentTypeResolverBuilderTests.java | 4 +- .../config/ResourceHandlerRegistryTests.java | 4 +- .../WebFluxConfigurationSupportTests.java | 4 +- .../function/BodyExtractorsTests.java | 4 +- .../reactive/function/BodyInsertersTests.java | 6 +- .../function/MultipartIntegrationTests.java | 2 +- .../DefaultClientRequestBuilderTests.java | 2 +- .../client/WebClientIntegrationTests.java | 2 +- ...bstractRouterFunctionIntegrationTests.java | 2 +- .../DefaultEntityResponseBuilderTests.java | 6 +- .../server/DefaultRenderingResponseTests.java | 6 +- .../DefaultServerRequestBuilderTests.java | 4 +- .../server/DefaultServerRequestTests.java | 4 +- .../DefaultServerResponseBuilderTests.java | 6 +- .../DispatcherHandlerIntegrationTests.java | 4 +- .../InvalidHttpMethodIntegrationTests.java | 2 +- ...LocaleContextResolverIntegrationTests.java | 2 +- .../server/NestedRouteIntegrationTests.java | 2 +- ...lisherHandlerFunctionIntegrationTests.java | 2 +- .../RenderingResponseIntegrationTests.java | 2 +- .../RequestPredicateAttributesTests.java | 4 +- .../server/ResourceHandlerFunctionTests.java | 6 +- .../function/server/RouterFunctionsTests.java | 4 +- .../SseHandlerFunctionIntegrationTests.java | 2 +- .../DispatcherHandlerIntegrationTests.java | 4 +- .../support/RouterFunctionMappingTests.java | 4 +- .../handler/CorsUrlHandlerMappingTests.java | 4 +- .../handler/SimpleUrlHandlerMappingTests.java | 4 +- ...uxResponseStatusExceptionHandlerTests.java | 4 +- .../AppCacheManifestTransformerTests.java | 4 +- .../CachingResourceResolverTests.java | 4 +- .../CssLinkResourceTransformerTests.java | 4 +- .../EncodedResourceResolverTests.java | 4 +- .../ResourceTransformerSupportTests.java | 4 +- .../resource/ResourceUrlProviderTests.java | 6 +- .../resource/ResourceWebHandlerTests.java | 6 +- .../VersionResourceResolverTests.java | 4 +- .../WebJarsResourceResolverTests.java | 4 +- .../result/HandlerResultHandlerTests.java | 4 +- ...mpleUrlHandlerMappingIntegrationTests.java | 4 +- .../CompositeRequestConditionTests.java | 4 +- .../ConsumesRequestConditionTests.java | 4 +- .../HeadersRequestConditionTests.java | 4 +- .../ParamsRequestConditionTests.java | 4 +- .../PatternsRequestConditionTests.java | 4 +- .../ProducesRequestConditionTests.java | 4 +- .../RequestConditionHolderTests.java | 4 +- .../condition/RequestMappingInfoTests.java | 4 +- .../RequestMethodsRequestConditionTests.java | 4 +- .../method/HandlerMethodMappingTests.java | 4 +- .../method/InvocableHandlerMethodTests.java | 8 +- ...RequestMappingInfoHandlerMappingTests.java | 18 +-- ...bstractRequestMappingIntegrationTests.java | 2 +- .../ContextPathIntegrationTests.java | 4 +- .../annotation/ControllerAdviceTests.java | 4 +- .../ControllerInputIntegrationTests.java | 2 +- .../ControllerMethodResolverTests.java | 2 +- ...ookieValueMethodArgumentResolverTests.java | 4 +- ...CrossOriginAnnotationIntegrationTests.java | 2 +- .../ErrorsMethodArgumentResolverTests.java | 6 +- ...ssionValueMethodArgumentResolverTests.java | 4 +- .../GlobalCorsConfigIntegrationTests.java | 2 +- ...HttpEntityMethodArgumentResolverTests.java | 6 +- .../InitBinderBindingContextTests.java | 4 +- .../JacksonHintsIntegrationTests.java | 2 +- .../JacksonStreamingIntegrationTests.java | 4 +- ...riablesMapMethodArgumentResolverTests.java | 8 +- ...xVariablesMethodArgumentResolverTests.java | 8 +- .../MessageReaderArgumentResolverTests.java | 8 +- .../MessageWriterResultHandlerTests.java | 6 +- ...lAttributeMethodArgumentResolverTests.java | 6 +- .../annotation/ModelInitializerTests.java | 6 +- .../ModelMethodArgumentResolverTests.java | 6 +- .../annotation/MultipartIntegrationTests.java | 8 +- ...ariableMapMethodArgumentResolverTests.java | 4 +- ...thVariableMethodArgumentResolverTests.java | 4 +- .../PrincipalMethodArgumentResolverTests.java | 6 +- .../annotation/ProtobufIntegrationTests.java | 2 +- ...tAttributeMethodArgumentResolverTests.java | 8 +- ...equestBodyMethodArgumentResolverTests.java | 8 +- ...tHeaderMapMethodArgumentResolverTests.java | 4 +- ...uestHeaderMethodArgumentResolverTests.java | 4 +- ...estMappingDataBindingIntegrationTests.java | 2 +- ...pingExceptionHandlingIntegrationTests.java | 2 +- .../RequestMappingIntegrationTests.java | 2 +- ...pingMessageConversionIntegrationTests.java | 5 +- ...MappingViewResolutionIntegrationTests.java | 2 +- ...stParamMapMethodArgumentResolverTests.java | 8 +- ...questParamMethodArgumentResolverTests.java | 8 +- ...equestPartMethodArgumentResolverTests.java | 10 +- .../ResponseBodyResultHandlerTests.java | 2 +- .../ResponseEntityResultHandlerTests.java | 6 +- ...ebExchangeMethodArgumentResolverTests.java | 6 +- ...nAttributeMethodArgumentResolverTests.java | 4 +- .../SessionAttributesHandlerTests.java | 2 +- .../annotation/SseIntegrationTests.java | 12 +- ...WebSessionMethodArgumentResolverTests.java | 6 +- .../result/view/AbstractViewTests.java | 4 +- .../view/HttpMessageWriterViewTests.java | 4 +- ...LocaleContextResolverIntegrationTests.java | 2 +- .../result/view/RedirectViewTests.java | 4 +- .../result/view/RequestContextTests.java | 4 +- .../ViewResolutionResultHandlerTests.java | 8 +- .../view/freemarker/FreeMarkerMacroTests.java | 4 +- .../view/freemarker/FreeMarkerViewTests.java | 4 +- .../view/script/JRubyScriptTemplateTests.java | 6 +- .../script/JythonScriptTemplateTests.java | 6 +- .../script/KotlinScriptTemplateTests.java | 6 +- .../script/NashornScriptTemplateTests.java | 6 +- .../AbstractWebSocketIntegrationTests.java | 10 +- .../socket/WebSocketIntegrationTests.java | 2 +- .../HandshakeWebSocketServiceTests.java | 6 +- .../KotlinInvocableHandlerMethodTests.kt | 4 +- .../annotation/CoroutinesIntegrationTests.kt | 2 +- ...tParamMethodArgumentResolverKotlinTests.kt | 4 +- .../springframework/web/reactive/spring.png | Bin 0 -> 951 bytes spring-webmvc/spring-webmvc.gradle | 1 + .../web/servlet/mvc/Controller.java | 4 +- .../web/context/ContextLoaderTests.java | 4 +- .../ServletContextAwareProcessorTests.java | 4 +- .../XmlWebApplicationContextTests.java | 2 +- .../support/HttpRequestHandlerTests.java | 8 +- .../support/ServletContextSupportTests.java | 2 +- .../WebApplicationObjectSupportTests.java | 2 +- .../web/servlet/DispatcherServletTests.java | 8 +- .../servlet/HandlerExecutionChainTests.java | 4 +- .../web/servlet/config/MvcNamespaceTests.java | 8 +- .../ContentNegotiationConfigurerTests.java | 2 +- .../DefaultServletHandlerConfigurerTests.java | 8 +- ...ngWebMvcConfigurationIntegrationTests.java | 2 +- .../annotation/InterceptorRegistryTests.java | 4 +- .../ResourceHandlerRegistryTests.java | 6 +- .../ViewControllerRegistryTests.java | 4 +- .../ViewResolutionIntegrationTests.java | 8 +- ...MvcConfigurationSupportExtensionTests.java | 4 +- .../WebMvcConfigurationSupportTests.java | 6 +- .../DefaultEntityResponseBuilderTests.java | 4 +- .../DefaultRenderingResponseTests.java | 4 +- .../DefaultServerRequestBuilderTests.java | 2 +- .../function/DefaultServerRequestTests.java | 4 +- .../DefaultServerResponseBuilderTests.java | 4 +- .../PathResourceLookupFunctionTests.java | 2 +- .../function/RequestPredicateTests.java | 2 +- .../function/RequestPredicatesTests.java | 2 +- .../ResourceHandlerFunctionTests.java | 4 +- .../function/RouterFunctionBuilderTests.java | 2 +- .../servlet/function/RouterFunctionTests.java | 2 +- .../function/RouterFunctionsTests.java | 2 +- .../BeanNameUrlHandlerMappingTests.java | 4 +- .../CorsAbstractHandlerMappingTests.java | 2 +- .../HandlerMappingIntrospectorTests.java | 2 +- .../servlet/handler/HandlerMappingTests.java | 2 +- .../handler/HandlerMethodMappingTests.java | 2 +- .../PathMatchingUrlHandlerMappingTests.java | 4 +- .../SimpleMappingExceptionResolverTests.java | 4 +- .../handler/SimpleUrlHandlerMappingTests.java | 4 +- .../i18n/AcceptHeaderLocaleResolverTests.java | 2 +- .../i18n/CookieLocaleResolverTests.java | 4 +- .../web/servlet/i18n/LocaleResolverTests.java | 6 +- .../i18n/SessionLocaleResolverTests.java | 4 +- .../web/servlet/mvc/ControllerTests.java | 4 +- .../ParameterizableViewControllerTests.java | 4 +- .../mvc/UrlFilenameViewControllerTests.java | 4 +- .../mvc/WebContentInterceptorTests.java | 4 +- .../annotation/CglibProxyControllerTests.java | 6 +- .../annotation/JdkProxyControllerTests.java | 6 +- .../ResponseStatusExceptionResolverTests.java | 4 +- .../CompositeRequestConditionTests.java | 2 +- .../ConsumesRequestConditionTests.java | 2 +- .../HeadersRequestConditionTests.java | 2 +- .../ParamsRequestConditionTests.java | 2 +- .../PatternsRequestConditionTests.java | 2 +- .../ProducesRequestConditionTests.java | 2 +- .../RequestConditionHolderTests.java | 2 +- .../RequestMethodsRequestConditionTests.java | 2 +- ...RequestMappingInfoHandlerMappingTests.java | 2 +- .../mvc/method/RequestMappingInfoTests.java | 2 +- ...equestAttributesArgumentResolverTests.java | 4 +- .../AbstractServletHandlerMethodTests.java | 2 +- .../method/annotation/CrossOriginTests.java | 2 +- ...DeferredResultReturnValueHandlerTests.java | 6 +- ...xceptionHandlerExceptionResolverTests.java | 4 +- ...ExtendedServletRequestDataBinderTests.java | 2 +- ...HandlerMethodAnnotationDetectionTests.java | 4 +- .../HttpEntityMethodProcessorMockTests.java | 4 +- .../HttpEntityMethodProcessorTests.java | 4 +- ...riablesMapMethodArgumentResolverTests.java | 8 +- ...xVariablesMethodArgumentResolverTests.java | 8 +- ...lAndViewMethodReturnValueHandlerTests.java | 2 +- ...ResolverMethodReturnValueHandlerTests.java | 2 +- .../MvcUriComponentsBuilderTests.java | 8 +- ...ariableMapMethodArgumentResolverTests.java | 4 +- ...thVariableMethodArgumentResolverTests.java | 4 +- .../annotation/ReactiveTypeHandlerTests.java | 6 +- ...MappingHandlerAdapterIntegrationTests.java | 8 +- .../RequestMappingHandlerAdapterTests.java | 4 +- .../RequestMappingHandlerMappingTests.java | 2 +- ...equestPartMethodArgumentResolverTests.java | 10 +- .../RequestResponseBodyAdviceChainTests.java | 4 +- ...tResponseBodyMethodProcessorMockTests.java | 4 +- ...questResponseBodyMethodProcessorTests.java | 4 +- ...copedControllerAdviceIntegrationTests.java | 2 +- ...nseBodyEmitterReturnValueHandlerTests.java | 8 +- .../ResponseEntityExceptionHandlerTests.java | 6 +- ...nnotationControllerHandlerMethodTests.java | 12 +- ...ookieValueMethodArgumentResolverTests.java | 4 +- .../ServletInvocableHandlerMethodTests.java | 4 +- ...letModelAttributeMethodProcessorTests.java | 2 +- ...letRequestMethodArgumentResolverTests.java | 6 +- ...etResponseMethodArgumentResolverTests.java | 4 +- ...ngResponseBodyReturnValueHandlerTests.java | 4 +- ...ntsBuilderMethodArgumentResolverTests.java | 2 +- ...nnotationControllerHandlerMethodTests.java | 4 +- .../ViewMethodReturnValueHandlerTests.java | 2 +- ...ViewNameMethodReturnValueHandlerTests.java | 2 +- .../DefaultHandlerExceptionResolverTests.java | 4 +- .../ParameterizableViewControllerTests.java | 4 +- .../AppCacheManifestTransformerTests.java | 2 +- .../CachingResourceResolverTests.java | 2 +- .../CssLinkResourceTransformerTests.java | 2 +- .../EncodedResourceResolverTests.java | 2 +- .../resource/PathResourceResolverTests.java | 4 +- .../ResourceHttpRequestHandlerTests.java | 6 +- .../ResourceTransformerSupportTests.java | 2 +- .../ResourceUrlEncodingFilterTests.java | 4 +- .../ResourceUrlProviderJavaConfigTests.java | 8 +- .../resource/ResourceUrlProviderTests.java | 4 +- .../VersionResourceResolverTests.java | 2 +- .../WebJarsResourceResolverTests.java | 2 +- ...nfigDispatcherServletInitializerTests.java | 4 +- .../DispatcherServletInitializerTests.java | 2 +- .../servlet/support/FlashMapManagerTests.java | 4 +- .../servlet/support/RequestContextTests.java | 6 +- .../ServletUriComponentsBuilderTests.java | 6 +- .../support/WebContentGeneratorTests.java | 2 +- .../web/servlet/tags/AbstractTagTests.java | 8 +- .../web/servlet/tags/ArgumentTagTests.java | 4 +- .../web/servlet/tags/EvalTagTests.java | 4 +- .../web/servlet/tags/HtmlEscapeTagTests.java | 2 +- .../web/servlet/tags/ParamTagTests.java | 4 +- .../web/servlet/tags/UrlTagTests.java | 4 +- .../tags/form/AbstractFormTagTests.java | 4 +- .../form/AbstractHtmlElementTagTests.java | 4 +- .../web/servlet/tags/form/ErrorsTagTests.java | 4 +- .../web/servlet/tags/form/FormTagTests.java | 2 +- .../web/servlet/tags/form/LabelTagTests.java | 2 +- .../web/servlet/tags/form/OptionTagTests.java | 4 +- .../servlet/tags/form/OptionsTagTests.java | 4 +- .../tags/form/TagIdGeneratorTests.java | 2 +- .../web/servlet/theme/ThemeResolverTests.java | 6 +- .../web/servlet/view/BaseViewTests.java | 6 +- .../ContentNegotiatingViewResolverTests.java | 6 +- ...faultRequestToViewNameTranslatorTests.java | 2 +- .../view/InternalResourceViewTests.java | 8 +- .../web/servlet/view/RedirectViewTests.java | 6 +- .../view/RedirectViewUriTemplateTests.java | 4 +- .../view/ResourceBundleViewResolverTests.java | 2 +- .../web/servlet/view/ViewResolverTests.java | 8 +- .../servlet/view/document/XlsViewTests.java | 4 +- .../servlet/view/feed/AtomFeedViewTests.java | 4 +- .../servlet/view/feed/RssFeedViewTests.java | 4 +- .../view/freemarker/FreeMarkerMacroTests.java | 6 +- .../view/freemarker/FreeMarkerViewTests.java | 6 +- .../view/groovy/GroovyMarkupViewTests.java | 6 +- .../json/MappingJackson2JsonViewTests.java | 4 +- .../view/script/JRubyScriptTemplateTests.java | 6 +- .../script/JythonScriptTemplateTests.java | 6 +- .../script/KotlinScriptTemplateTests.java | 6 +- .../script/NashornScriptTemplateTests.java | 6 +- .../view/script/ScriptTemplateViewTests.java | 6 +- .../view/tiles3/TilesConfigurerTests.java | 6 +- .../view/tiles3/TilesViewResolverTests.java | 2 +- .../servlet/view/tiles3/TilesViewTests.java | 6 +- .../view/xml/MappingJackson2XmlViewTests.java | 4 +- .../view/xml/MarshallingViewTests.java | 4 +- .../web/servlet/view/xslt/XsltViewTests.java | 4 +- .../function/RouterFunctionDslTests.kt | 2 +- ...ationControllerHandlerMethodKotlinTests.kt | 4 +- spring-websocket/spring-websocket.gradle | 1 + .../web/socket/AbstractHttpRequestTests.java | 4 +- ...essageBrokerBeanDefinitionParserTests.java | 2 +- .../standard/ServerEndpointExporterTests.java | 2 +- .../standard/SpringConfiguratorTests.java | 2 +- .../HttpSessionHandshakeInterceptorTests.java | 2 +- .../WebSocketHttpRequestHandlerTests.java | 4 +- .../session/HttpSockJsSessionTests.java | 4 +- 463 files changed, 1055 insertions(+), 1003 deletions(-) delete mode 100644 spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/package-info.java rename spring-web/src/test/resources/org/springframework/{http/server/reactive => web}/spring.png (100%) rename spring-web/src/{test/java/org/springframework/mock/http/client/reactive/test => testFixtures/java/org/springframework/web/testfixture/http/client/reactive}/MockClientHttpRequest.java (98%) rename spring-web/src/{test/java/org/springframework/mock/http/client/reactive/test => testFixtures/java/org/springframework/web/testfixture/http/client/reactive}/MockClientHttpResponse.java (98%) rename spring-web/src/{test/java/org/springframework/mock/http/server/reactive/test => testFixtures/java/org/springframework/web/testfixture/http/server/reactive}/MockServerHttpRequest.java (99%) rename spring-web/src/{test/java/org/springframework/mock/http/server/reactive/test => testFixtures/java/org/springframework/web/testfixture/http/server/reactive}/MockServerHttpResponse.java (98%) rename spring-web/src/{test/java/org/springframework/http/server/reactive => testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap}/AbstractHttpHandlerIntegrationTests.java (88%) rename spring-web/src/{test/java/org/springframework => testFixtures/java/org/springframework/web/testfixture}/http/server/reactive/bootstrap/AbstractHttpServer.java (98%) rename spring-web/src/{test/java/org/springframework => testFixtures/java/org/springframework/web/testfixture}/http/server/reactive/bootstrap/HttpServer.java (92%) rename spring-web/src/{test/java/org/springframework => testFixtures/java/org/springframework/web/testfixture}/http/server/reactive/bootstrap/JettyHttpServer.java (97%) rename spring-web/src/{test/java/org/springframework => testFixtures/java/org/springframework/web/testfixture}/http/server/reactive/bootstrap/ReactorHttpServer.java (96%) rename spring-web/src/{test/java/org/springframework => testFixtures/java/org/springframework/web/testfixture}/http/server/reactive/bootstrap/ReactorHttpsServer.java (96%) rename spring-web/src/{test/java/org/springframework => testFixtures/java/org/springframework/web/testfixture}/http/server/reactive/bootstrap/TomcatHttpServer.java (97%) rename spring-web/src/{test/java/org/springframework => testFixtures/java/org/springframework/web/testfixture}/http/server/reactive/bootstrap/UndertowHttpServer.java (95%) create mode 100644 spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/package-info.java rename spring-web/src/{test/java/org/springframework/mock/http/server/reactive/test => testFixtures/java/org/springframework/web/testfixture/http/server/reactive}/package-info.java (73%) rename spring-web/src/{test/java/org/springframework/web => testFixtures/java/org/springframework/web/testfixture}/method/MvcAnnotationPredicates.java (98%) rename spring-web/src/{test/java/org/springframework/web => testFixtures/java/org/springframework/web/testfixture}/method/ResolvableMethod.java (97%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture}/server/MockServerWebExchange.java (94%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture}/server/MockWebSession.java (98%) create mode 100644 spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/handler/AbstractResponseStatusExceptionHandlerTests.java rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture}/server/package-info.java (77%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/DelegatingServletInputStream.java (97%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/DelegatingServletOutputStream.java (97%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/HeaderValueHolder.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockAsyncContext.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockBodyContent.java (99%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockCookie.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockExpressionEvaluator.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockFilterChain.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockFilterConfig.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockHttpServletRequest.java (99%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockHttpServletResponse.java (99%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockHttpSession.java (99%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockJspWriter.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockMultipartFile.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockMultipartHttpServletRequest.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockPageContext.java (99%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockPart.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockRequestDispatcher.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockServletConfig.java (98%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockServletContext.java (99%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/MockSessionCookieConfig.java (97%) rename spring-web/src/{test/java/org/springframework/mock/web/test => testFixtures/java/org/springframework/web/testfixture/servlet}/PassThroughFilterChain.java (98%) rename spring-web/src/{test/java/org/springframework/http/codec => testFixtures/java/org/springframework/web/testfixture/xml}/Pojo.java (96%) rename spring-web/src/{test => testFixtures}/resources/org/springframework/http/codec/multipart/foo.txt (100%) create mode 100644 spring-webflux/src/test/resources/org/springframework/web/reactive/spring.png diff --git a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java index 130a5cac22e3..b05e08214c3d 100644 --- a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java +++ b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java @@ -78,11 +78,11 @@ public class TestSourcesPlugin implements Plugin { "spring-orm", "spring-oxm", // "spring-test", - "spring-tx" - // "spring-web", - // "spring-webflux", + "spring-tx", + "spring-web", + "spring-webflux", // "spring-webmvc", - // "spring-websocket" + "spring-websocket" ); diff --git a/spring-orm/spring-orm.gradle b/spring-orm/spring-orm.gradle index 06686d31d2c7..8a8ad57ac4c3 100644 --- a/spring-orm/spring-orm.gradle +++ b/spring-orm/spring-orm.gradle @@ -14,6 +14,7 @@ dependencies { testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-context"))) testCompile(testFixtures(project(":spring-core"))) + testCompile(testFixtures(project(":spring-web"))) testCompile("org.aspectj:aspectjweaver") testCompile("org.hsqldb:hsqldb") testRuntime("javax.xml.bind:jaxb-api") diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java index ef68907f2cbe..ad1a84e70f7c 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java @@ -34,12 +34,6 @@ import org.junit.jupiter.api.Test; import org.springframework.core.task.SimpleAsyncTaskExecutor; -import org.springframework.mock.web.test.MockAsyncContext; -import org.springframework.mock.web.test.MockFilterConfig; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.mock.web.test.MockServletContext; -import org.springframework.mock.web.test.PassThroughFilterChain; import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.request.ServletWebRequest; @@ -48,6 +42,12 @@ import org.springframework.web.context.request.async.WebAsyncManager; import org.springframework.web.context.request.async.WebAsyncUtils; import org.springframework.web.context.support.StaticWebApplicationContext; +import org.springframework.web.testfixture.servlet.MockAsyncContext; +import org.springframework.web.testfixture.servlet.MockFilterConfig; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockServletContext; +import org.springframework.web.testfixture.servlet.PassThroughFilterChain; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; diff --git a/spring-test/spring-test.gradle b/spring-test/spring-test.gradle index ec8708a8854e..e240001a1b66 100644 --- a/spring-test/spring-test.gradle +++ b/spring-test/spring-test.gradle @@ -46,6 +46,7 @@ dependencies { testCompile(testFixtures(project(":spring-context"))) testCompile(testFixtures(project(":spring-core"))) testCompile(testFixtures(project(":spring-tx"))) + testCompile(testFixtures(project(":spring-web"))) testCompile("javax.annotation:javax.annotation-api") testCompile("javax.cache:cache-api") testCompile("javax.ejb:javax.ejb-api") diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/HttpServerTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/HttpServerTests.java index 27f69a04b80b..d61fc416c228 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/HttpServerTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/HttpServerTests.java @@ -21,10 +21,10 @@ import org.junit.jupiter.api.Test; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.reactive.function.server.ServerResponse; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.ReactorHttpServer; import static org.springframework.web.reactive.function.server.RequestPredicates.GET; import static org.springframework.web.reactive.function.server.RouterFunctions.route; diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilderTests.java index dd85d0a4b3c8..078504557481 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilderTests.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test; import org.springframework.http.converter.json.SpringHandlerInstantiator; -import org.springframework.mock.web.test.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.context.WebApplicationContext; diff --git a/spring-web/spring-web.gradle b/spring-web/spring-web.gradle index bb86f10cc511..60c40ed4eeec 100644 --- a/spring-web/spring-web.gradle +++ b/spring-web/spring-web.gradle @@ -77,4 +77,10 @@ dependencies { testRuntime("com.sun.xml.bind:jaxb-impl") testRuntime("javax.json:javax.json-api") testRuntime("org.apache.johnzon:johnzon-jsonb") + testFixturesApi("javax.servlet:javax.servlet-api") + testFixturesApi("org.junit.jupiter:junit-jupiter-api") + testFixturesApi("org.junit.jupiter:junit-jupiter-params") + testFixturesImplementation("io.projectreactor:reactor-test") + testFixturesImplementation("org.apache.taglibs:taglibs-standard-jstlel") + testFixturesImplementation("org.assertj:assertj-core") } diff --git a/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java b/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java index 2bb2e8c6fa48..2935e9fa2337 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java @@ -46,6 +46,7 @@ import org.springframework.protobuf.Msg; import org.springframework.protobuf.SecondMsg; import org.springframework.util.MimeType; +import org.springframework.web.testfixture.xml.Pojo; /** * Test scenarios for data buffer leaks. diff --git a/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java index 5fbc2866d82f..c7133f3f28e4 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java @@ -37,10 +37,10 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; import org.springframework.util.ReflectionUtils; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static java.nio.charset.StandardCharsets.ISO_8859_1; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java index 161c467b5c02..5555d04e6b8f 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java @@ -32,9 +32,9 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java index 6a133141ce4d..04f4a889ec56 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java @@ -31,9 +31,9 @@ import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/codec/ResourceHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/ResourceHttpMessageWriterTests.java index 4ca926aaf1f4..b63e613be613 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/ResourceHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/ResourceHttpMessageWriterTests.java @@ -30,14 +30,14 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpRange; import org.springframework.http.HttpStatus; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.util.MimeTypeUtils; import org.springframework.util.StringUtils; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.http.MediaType.TEXT_PLAIN; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link ResourceHttpMessageWriter}. diff --git a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java index d6ef84b73f1e..01d9a34376fb 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java @@ -30,7 +30,8 @@ import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import org.springframework.http.MediaType; import org.springframework.http.codec.json.Jackson2JsonDecoder; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.xml.Pojo; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java index 2bd290d9b883..5411540c55b6 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java @@ -36,7 +36,8 @@ import org.springframework.http.MediaType; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.xml.Pojo; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.ResolvableType.forClass; diff --git a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java index b434b2fdd156..63eaf2488cfd 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java @@ -27,9 +27,9 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.testfixture.codec.AbstractDecoderTests; -import org.springframework.http.codec.Pojo; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.util.MimeType; +import org.springframework.web.testfixture.xml.Pojo; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java index b3ae238a8cab..a2ce8c51a3d1 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java @@ -28,10 +28,10 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; -import org.springframework.http.codec.Pojo; import org.springframework.http.codec.ServerSentEvent; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.util.MimeType; +import org.springframework.web.testfixture.xml.Pojo; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java index c1e0b61715da..dd2ba1334b27 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java @@ -39,10 +39,10 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.testfixture.codec.AbstractDecoderTests; import org.springframework.http.MediaType; -import org.springframework.http.codec.Pojo; import org.springframework.http.codec.json.JacksonViewBean.MyJacksonView1; import org.springframework.http.codec.json.JacksonViewBean.MyJacksonView3; import org.springframework.util.MimeType; +import org.springframework.web.testfixture.xml.Pojo; import static java.util.Arrays.asList; import static java.util.Collections.emptyMap; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java index 946b730f6c2e..718c928a7b11 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java @@ -36,12 +36,12 @@ import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.testfixture.codec.AbstractEncoderTests; import org.springframework.http.MediaType; -import org.springframework.http.codec.Pojo; import org.springframework.http.codec.ServerSentEvent; import org.springframework.http.codec.json.JacksonViewBean.MyJacksonView1; import org.springframework.http.codec.json.JacksonViewBean.MyJacksonView3; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; +import org.springframework.web.testfixture.xml.Pojo; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java index b672918fcb90..f02b19b72866 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java @@ -27,9 +27,9 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.testfixture.codec.AbstractDecoderTests; -import org.springframework.http.codec.Pojo; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.util.MimeType; +import org.springframework.web.testfixture.xml.Pojo; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.ResolvableType.forClass; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java index 7b39ac59f44a..ef2a9d84883a 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java @@ -31,10 +31,10 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.testfixture.codec.AbstractEncoderTests; import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; -import org.springframework.http.codec.Pojo; import org.springframework.http.codec.ServerSentEvent; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.util.MimeType; +import org.springframework.web.testfixture.xml.Pojo; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.io.buffer.DataBufferUtils.release; diff --git a/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java index 36bfc18302e7..497ad9559f37 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java @@ -40,9 +40,9 @@ import org.springframework.http.MediaType; import org.springframework.http.client.MultipartBodyBuilder; import org.springframework.http.codec.ClientCodecConfigurer; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.util.MultiValueMap; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java index 7d6661dfa9c7..bf60a6c7911f 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java @@ -42,9 +42,9 @@ import org.springframework.http.MediaType; import org.springframework.http.client.MultipartBodyBuilder; import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.mock.http.client.reactive.test.MockClientHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.util.MultiValueMap; +import org.springframework.web.testfixture.http.client.reactive.MockClientHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java index 7fda7067f20a..8e736de9e0a3 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java @@ -32,13 +32,13 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import org.springframework.http.MediaType; -import org.springframework.http.codec.Pojo; import org.springframework.http.codec.xml.jaxb.XmlRootElement; import org.springframework.http.codec.xml.jaxb.XmlRootElementWithName; import org.springframework.http.codec.xml.jaxb.XmlRootElementWithNameAndNamespace; import org.springframework.http.codec.xml.jaxb.XmlType; import org.springframework.http.codec.xml.jaxb.XmlTypeWithName; import org.springframework.http.codec.xml.jaxb.XmlTypeWithNameAndNamespace; +import org.springframework.web.testfixture.xml.Pojo; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java index 81d5767c15d9..8c22f80956a9 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java @@ -33,7 +33,7 @@ import org.springframework.core.testfixture.codec.AbstractEncoderTests; import org.springframework.core.testfixture.xml.XmlContent; import org.springframework.http.MediaType; -import org.springframework.http.codec.Pojo; +import org.springframework.web.testfixture.xml.Pojo; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/converter/ObjectToStringHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/ObjectToStringHttpMessageConverterTests.java index 77eed6999945..b212dc3668b0 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/ObjectToStringHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/ObjectToStringHttpMessageConverterTests.java @@ -31,8 +31,8 @@ import org.springframework.http.MediaType; import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.http.server.ServletServerHttpResponse; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java index 771d468ca26f..b0aa8e1cda06 100644 --- a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java @@ -28,8 +28,8 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.util.FileCopyUtils; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpResponseTests.java b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpResponseTests.java index 1048847e1052..4f37e8d193ba 100644 --- a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpResponseTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpResponseTests.java @@ -26,8 +26,8 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.util.FileCopyUtils; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/AsyncIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/AsyncIntegrationTests.java index dbe943e05221..44d757b61c69 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/AsyncIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/AsyncIntegrationTests.java @@ -28,8 +28,9 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ContextPathCompositeHandlerTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ContextPathCompositeHandlerTests.java index 26d5298dca99..0672f67b332c 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ContextPathCompositeHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ContextPathCompositeHandlerTests.java @@ -27,8 +27,8 @@ import reactor.core.publisher.Mono; import org.springframework.http.HttpStatus; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/CookieIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/CookieIntegrationTests.java index 7474abc09fbf..432a0ce6e5bc 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/CookieIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/CookieIntegrationTests.java @@ -27,8 +27,9 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseCookie; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/EchoHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/EchoHandlerIntegrationTests.java index d26b650a9ed9..83e7694309fa 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/EchoHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/EchoHandlerIntegrationTests.java @@ -23,8 +23,9 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java index 6cc09505b370..3e58088cd5e7 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java @@ -23,9 +23,10 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.client.ClientHttpResponse; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.ResponseErrorHandler; import org.springframework.web.client.RestTemplate; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java index 55695bca6463..a3d32c5f1391 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/HttpHeadResponseDecoratorTests.java @@ -25,7 +25,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.NettyDataBufferFactory; import org.springframework.core.testfixture.io.buffer.LeakAwareDataBufferFactory; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java index 3b763ba7296d..b5eac6a0b235 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java @@ -32,13 +32,14 @@ import org.springframework.http.codec.multipart.FilePart; import org.springframework.http.codec.multipart.FormFieldPart; import org.springframework.http.codec.multipart.Part; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebHandler; import org.springframework.web.server.adapter.HttpWebHandlerAdapter; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java index e8f03ee98688..7cbc1089c844 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java @@ -28,8 +28,9 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java index b108e797fa66..901180f5e182 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java @@ -23,8 +23,9 @@ import org.springframework.http.HttpStatus; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java index 8bd7b00b5ac3..c6917031bc0c 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java @@ -29,11 +29,11 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.HttpMethod; -import org.springframework.mock.web.test.DelegatingServletInputStream; -import org.springframework.mock.web.test.MockAsyncContext; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.util.MultiValueMap; +import org.springframework.web.testfixture.servlet.DelegatingServletInputStream; +import org.springframework.web.testfixture.servlet.MockAsyncContext; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java index cda8ce2b2129..0599911088eb 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java @@ -33,9 +33,9 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.http.server.reactive.bootstrap.HttpServer; -import org.springframework.http.server.reactive.bootstrap.ReactorHttpsServer; import org.springframework.web.client.RestTemplate; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.ReactorHttpsServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/WriteOnlyHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/WriteOnlyHandlerIntegrationTests.java index a7be114968c9..09ccb1272d95 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/WriteOnlyHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/WriteOnlyHandlerIntegrationTests.java @@ -26,8 +26,9 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java index ea045b8e86b4..79ba2eb64b49 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java @@ -27,10 +27,11 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.http.ZeroCopyHttpOutputMessage; -import org.springframework.http.server.reactive.bootstrap.HttpServer; -import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer; -import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer; import org.springframework.web.client.RestTemplate; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.ReactorHttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.UndertowHttpServer; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assumptions.assumeTrue; @@ -38,7 +39,9 @@ /** * @author Arjen Poutsma */ -public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTests { + + private static final Resource springLogoResource = new ClassPathResource("/org/springframework/web/spring.png"); private final ZeroCopyHandler handler = new ZeroCopyHandler(); @@ -50,9 +53,9 @@ protected HttpHandler createHttpHandler() { @ParameterizedHttpServerTest - public void zeroCopy(HttpServer httpServer) throws Exception { + void zeroCopy(HttpServer httpServer) throws Exception { assumeTrue(httpServer instanceof ReactorHttpServer || httpServer instanceof UndertowHttpServer, - "Zero-copy only does not support servlet"); + "Zero-copy does not support Servlet"); startServer(httpServer); @@ -60,11 +63,9 @@ public void zeroCopy(HttpServer httpServer) throws Exception { RequestEntity request = RequestEntity.get(url).build(); ResponseEntity response = new RestTemplate().exchange(request, byte[].class); - Resource logo = new ClassPathResource("spring.png", ZeroCopyIntegrationTests.class); - assertThat(response.hasBody()).isTrue(); - assertThat(response.getHeaders().getContentLength()).isEqualTo(logo.contentLength()); - assertThat(response.getBody().length).isEqualTo(logo.contentLength()); + assertThat(response.getHeaders().getContentLength()).isEqualTo(springLogoResource.contentLength()); + assertThat(response.getBody().length).isEqualTo(springLogoResource.contentLength()); assertThat(response.getHeaders().getContentType()).isEqualTo(MediaType.IMAGE_PNG); } @@ -75,8 +76,7 @@ private static class ZeroCopyHandler implements HttpHandler { public Mono handle(ServerHttpRequest request, ServerHttpResponse response) { try { ZeroCopyHttpOutputMessage zeroCopyResponse = (ZeroCopyHttpOutputMessage) response; - Resource logo = new ClassPathResource("spring.png", ZeroCopyIntegrationTests.class); - File logoFile = logo.getFile(); + File logoFile = springLogoResource.getFile(); zeroCopyResponse.getHeaders().setContentType(MediaType.IMAGE_PNG); zeroCopyResponse.getHeaders().setContentLength(logoFile.length()); return zeroCopyResponse.writeWith(logoFile, 0, logoFile.length()); diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/package-info.java b/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/package-info.java deleted file mode 100644 index 93e5dac54947..000000000000 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package contains temporary interfaces and classes for running embedded servers. - * They are expected to be replaced by an upcoming Spring Boot support. - */ -package org.springframework.http.server.reactive.bootstrap; diff --git a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java index cbb8eda58ffa..91981540b7e2 100644 --- a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java +++ b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java @@ -39,13 +39,13 @@ import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.TestBean; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.remoting.RemoteAccessException; import org.springframework.remoting.support.DefaultRemoteInvocationExecutor; import org.springframework.remoting.support.RemoteInvocation; import org.springframework.remoting.support.RemoteInvocationFactory; import org.springframework.remoting.support.RemoteInvocationResult; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java b/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java index b8443d9812f1..1b5ac13d795f 100644 --- a/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java +++ b/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java @@ -26,12 +26,12 @@ import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockServletContext; import org.springframework.util.StringUtils; import org.springframework.web.HttpMediaTypeNotAcceptableException; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockServletContext; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/accept/HeaderContentNegotiationStrategyTests.java b/spring-web/src/test/java/org/springframework/web/accept/HeaderContentNegotiationStrategyTests.java index 2ee89454f667..49f945cea1de 100644 --- a/spring-web/src/test/java/org/springframework/web/accept/HeaderContentNegotiationStrategyTests.java +++ b/spring-web/src/test/java/org/springframework/web/accept/HeaderContentNegotiationStrategyTests.java @@ -21,10 +21,10 @@ import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.HttpMediaTypeNotAcceptableException; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategyTests.java b/spring-web/src/test/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategyTests.java index 633e66add1da..5f394907da23 100644 --- a/spring-web/src/test/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategyTests.java +++ b/spring-web/src/test/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategyTests.java @@ -24,10 +24,10 @@ import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.HttpMediaTypeNotAcceptableException; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java index 3a2c729fc3ee..f6704d39e28c 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java @@ -27,7 +27,7 @@ import org.springframework.beans.PropertyValues; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.TestBean; -import org.springframework.mock.web.test.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java index c9a9553f255a..f567a8b4313b 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java @@ -19,8 +19,8 @@ import org.junit.jupiter.api.Test; import org.springframework.core.testfixture.EnabledForTestGroups; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.util.StopWatch; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java index 57382b940705..176397e5e39b 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java @@ -34,12 +34,12 @@ import org.springframework.http.codec.FormHttpMessageWriter; import org.springframework.http.codec.multipart.FilePart; import org.springframework.http.codec.multipart.MultipartHttpMessageWriter; -import org.springframework.mock.http.client.reactive.test.MockClientHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.client.reactive.MockClientHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.ResolvableType.forClass; @@ -198,7 +198,7 @@ public void testMultipart() throws Exception { data.add("someArray", "456"); data.add("part", new ClassPathResource("org/springframework/http/codec/multipart/foo.txt")); data.add("somePartList", new ClassPathResource("org/springframework/http/codec/multipart/foo.txt")); - data.add("somePartList", new ClassPathResource("org/springframework/http/server/reactive/spring.png")); + data.add("somePartList", new ClassPathResource("/org/springframework/web/spring.png")); binder.bind(exchangeMultipart(data)).block(Duration.ofMillis(5000)); assertThat(bean.getName()).isEqualTo("bar"); diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java index 62dc077ad024..b01cd408b983 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java @@ -29,12 +29,12 @@ import org.springframework.beans.PropertyValues; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.TestBean; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockMultipartFile; -import org.springframework.mock.web.test.MockMultipartHttpServletRequest; import org.springframework.web.bind.ServletRequestParameterPropertyValues; import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.multipart.support.StringMultipartFileEditor; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockMultipartFile; +import org.springframework.web.testfixture.servlet.MockMultipartHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/ContextLoaderInitializerTests.java b/spring-web/src/test/java/org/springframework/web/context/ContextLoaderInitializerTests.java index 099d250197ad..4c252fffd347 100644 --- a/spring-web/src/test/java/org/springframework/web/context/ContextLoaderInitializerTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/ContextLoaderInitializerTests.java @@ -24,9 +24,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.context.support.StaticWebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; +import org.springframework.web.testfixture.servlet.MockServletContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java index 322ca97a63a5..c413f2ca4103 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java @@ -23,9 +23,9 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.testfixture.beans.TestBean; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.StaticWebApplicationContext; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java index a8b4166151c8..4e4bdedb134c 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test; import org.springframework.core.task.MockRunnable; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockServletContext; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockServletContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java index 37a98e46c8ed..bd52c22d2775 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java @@ -29,7 +29,7 @@ import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.expression.StandardBeanExpressionResolver; import org.springframework.core.io.ClassPathResource; -import org.springframework.mock.web.test.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java index 6c705e3d9dff..af46e06b94c4 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java @@ -29,7 +29,7 @@ import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.beans.testfixture.beans.factory.DummyFactory; import org.springframework.core.io.ClassPathResource; -import org.springframework.mock.web.test.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java b/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java index 091f416a8887..579515d517f1 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java @@ -24,8 +24,8 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpSession; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpSession; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java index 4c1d0b7be27d..daac29918891 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java @@ -26,8 +26,8 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestTests.java b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestTests.java index ef5257ce2661..db295dc5a997 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestTests.java @@ -29,9 +29,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.web.multipart.MultipartRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java index 908c4db4242b..eb9d95807e05 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java @@ -32,8 +32,8 @@ import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.testfixture.io.SerializationTestUtils; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpSession; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpSession; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java index 6fffbb6c3a25..8315021b4b59 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java @@ -22,11 +22,11 @@ import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.beans.testfixture.beans.DerivedTestBean; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.context.ContextCleanupListener; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.GenericWebApplicationContext; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockServletContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequestTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequestTests.java index 966fc0e94039..6a71cf98582f 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequestTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequestTests.java @@ -23,9 +23,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockAsyncContext; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockAsyncContext; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerErrorTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerErrorTests.java index 4888379f662a..6ecb5fd2fd54 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerErrorTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerErrorTests.java @@ -25,10 +25,10 @@ import org.junit.jupiter.api.Test; import org.springframework.core.task.AsyncTaskExecutor; -import org.springframework.mock.web.test.MockAsyncContext; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.testfixture.servlet.MockAsyncContext; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java index 0a90ea36c390..ccde83a39c4c 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java @@ -26,7 +26,7 @@ import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.core.task.SimpleAsyncTaskExecutor; -import org.springframework.mock.web.test.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java index 2397acb1ffdb..7fcba13b1796 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java @@ -25,10 +25,10 @@ import org.junit.jupiter.api.Test; import org.springframework.core.task.AsyncTaskExecutor; -import org.springframework.mock.web.test.MockAsyncContext; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.testfixture.servlet.MockAsyncContext; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; diff --git a/spring-web/src/test/java/org/springframework/web/context/support/ResourceTests.java b/spring-web/src/test/java/org/springframework/web/context/support/ResourceTests.java index ead4700185d0..340838871814 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/ResourceTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/ResourceTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.springframework.core.io.Resource; -import org.springframework.mock.web.test.MockServletContext; +import org.springframework.web.testfixture.servlet.MockServletContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java b/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java index 094c042455a5..c8036faac907 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java @@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test; import org.springframework.context.annotation.ClassPathBeanDefinitionScanner; -import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.context.ContextLoader; import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.testfixture.servlet.MockServletContext; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java b/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java index a03dac5a6bbb..9a9f1b879e77 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java @@ -24,8 +24,8 @@ import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigUtils; -import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.testfixture.servlet.MockServletContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java b/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java index defa940ca87c..d68c677ddf18 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java @@ -20,7 +20,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.mock.web.test.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java b/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java index 72970cd7b140..e655cc71585b 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java @@ -23,8 +23,8 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/cors/UrlBasedCorsConfigurationSourceTests.java b/spring-web/src/test/java/org/springframework/web/cors/UrlBasedCorsConfigurationSourceTests.java index 5ef4ca99a731..f818b169dcac 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/UrlBasedCorsConfigurationSourceTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/UrlBasedCorsConfigurationSourceTests.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; -import org.springframework.mock.web.test.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java b/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java index 5b530a2ae250..617655643d52 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java @@ -23,12 +23,12 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.options; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.options; /** * Test case for reactive {@link CorsUtils}. diff --git a/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsWebFilterTests.java b/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsWebFilterTests.java index 938d80f6e311..2a269ad5534b 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsWebFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsWebFilterTests.java @@ -27,10 +27,10 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.server.WebFilterChain; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS; diff --git a/spring-web/src/test/java/org/springframework/web/cors/reactive/DefaultCorsProcessorTests.java b/spring-web/src/test/java/org/springframework/web/cors/reactive/DefaultCorsProcessorTests.java index 42d46222f383..8e317268f19f 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/reactive/DefaultCorsProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/reactive/DefaultCorsProcessorTests.java @@ -23,10 +23,10 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS; diff --git a/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java b/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java index e05e8652d9e9..6aecd98a511e 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java @@ -18,9 +18,9 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/filter/CharacterEncodingFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/CharacterEncodingFilterTests.java index 7ee5c8568489..19bd055b006b 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/CharacterEncodingFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/CharacterEncodingFilterTests.java @@ -22,9 +22,9 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockFilterConfig; -import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.mock.web.test.MockServletContext; +import org.springframework.web.testfixture.servlet.MockFilterConfig; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockServletContext; import org.springframework.web.util.WebUtils; import static org.mockito.BDDMockito.given; diff --git a/spring-web/src/test/java/org/springframework/web/filter/CompositeFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/CompositeFilterTests.java index 23930bb0fcad..fe9a21dd88a8 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/CompositeFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/CompositeFilterTests.java @@ -29,10 +29,10 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockFilterConfig; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.mock.web.test.MockServletContext; +import org.springframework.web.testfixture.servlet.MockFilterConfig; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockServletContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/filter/CorsFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/CorsFilterTests.java index 64ca23a02603..00db048c69dd 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/CorsFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/CorsFilterTests.java @@ -27,9 +27,9 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/spring-web/src/test/java/org/springframework/web/filter/DelegatingFilterProxyTests.java b/spring-web/src/test/java/org/springframework/web/filter/DelegatingFilterProxyTests.java index 003bfd02cc5a..3454a81d4eb4 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/DelegatingFilterProxyTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/DelegatingFilterProxyTests.java @@ -28,12 +28,12 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockFilterConfig; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.StaticWebApplicationContext; +import org.springframework.web.testfixture.servlet.MockFilterConfig; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockServletContext; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-web/src/test/java/org/springframework/web/filter/FormContentFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/FormContentFilterTests.java index d583610b2529..1273628b19ff 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/FormContentFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/FormContentFilterTests.java @@ -25,9 +25,9 @@ import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; -import org.springframework.mock.web.test.MockFilterChain; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockFilterChain; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java index 4fb97248e02f..ca073a049854 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java @@ -30,9 +30,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockFilterChain; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockFilterChain; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-web/src/test/java/org/springframework/web/filter/HiddenHttpMethodFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/HiddenHttpMethodFilterTests.java index 3d85486242fd..c35c86b60363 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/HiddenHttpMethodFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/HiddenHttpMethodFilterTests.java @@ -26,8 +26,8 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/filter/OncePerRequestFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/OncePerRequestFilterTests.java index 7f1b70da6807..94024a67492e 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/OncePerRequestFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/OncePerRequestFilterTests.java @@ -28,9 +28,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockFilterChain; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockFilterChain; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import org.springframework.web.util.WebUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/filter/RelativeRedirectFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/RelativeRedirectFilterTests.java index 71c94994d451..dd23fd6ac278 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/RelativeRedirectFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/RelativeRedirectFilterTests.java @@ -25,9 +25,9 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; -import org.springframework.mock.web.test.MockFilterChain; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockFilterChain; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/web/filter/RequestContextFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/RequestContextFilterTests.java index a785af134a80..c88b2e36c951 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/RequestContextFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/RequestContextFilterTests.java @@ -25,12 +25,12 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockFilterConfig; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.testfixture.servlet.MockFilterConfig; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockServletContext; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-web/src/test/java/org/springframework/web/filter/RequestLoggingFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/RequestLoggingFilterTests.java index 9d378a6a5c02..e3053bbb1b49 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/RequestLoggingFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/RequestLoggingFilterTests.java @@ -24,10 +24,10 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.mock.web.test.MockHttpSession; import org.springframework.util.FileCopyUtils; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockHttpSession; import org.springframework.web.util.ContentCachingRequestWrapper; import org.springframework.web.util.WebUtils; diff --git a/spring-web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTests.java index f0144bd86b5e..804a3c5b0ff4 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTests.java @@ -21,10 +21,10 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.util.FileCopyUtils; import org.springframework.util.StreamUtils; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilterTests.java index 61d79238a26b..4bf21aa08036 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilterTests.java @@ -25,10 +25,10 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebFilterChain; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/filter/reactive/ServerWebExchangeContextFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/reactive/ServerWebExchangeContextFilterTests.java index fee9f9293ae2..62c62b553d63 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/reactive/ServerWebExchangeContextFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/reactive/ServerWebExchangeContextFilterTests.java @@ -22,10 +22,10 @@ import reactor.core.publisher.Mono; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/CookieValueMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/CookieValueMethodArgumentResolverTests.java index 5f032f945513..47b184f4881e 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/CookieValueMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/CookieValueMethodArgumentResolverTests.java @@ -25,12 +25,12 @@ import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.web.bind.ServletRequestBindingException; import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolverTests.java index a3444193fc0a..1bf57b4bb2ec 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolverTests.java @@ -20,13 +20,13 @@ import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.validation.BindingResult; import org.springframework.validation.Errors; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.method.support.ModelAndViewContainer; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolverTests.java index 74d06bdd1266..86c419c8dd12 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolverTests.java @@ -24,12 +24,12 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.core.MethodParameter; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.context.support.GenericWebApplicationContext; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/InitBinderDataBinderFactoryTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/InitBinderDataBinderFactoryTests.java index c74c221ec184..1126d2bf2516 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/InitBinderDataBinderFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/InitBinderDataBinderFactoryTests.java @@ -24,7 +24,6 @@ import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.convert.ConversionService; import org.springframework.format.support.DefaultFormattingConversionService; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.RequestParam; @@ -35,6 +34,7 @@ import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.method.support.HandlerMethodArgumentResolverComposite; import org.springframework.web.method.support.InvocableHandlerMethod; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/MapMethodProcessorTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/MapMethodProcessorTests.java index 635dff6a3d8d..4482307abe7f 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/MapMethodProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/MapMethodProcessorTests.java @@ -22,14 +22,14 @@ import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.method.support.ModelAndViewContainer; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java index 7171fdd7e290..038f28bfa347 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java @@ -26,7 +26,6 @@ import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.validation.BindException; import org.springframework.validation.BindingResult; import org.springframework.validation.Errors; @@ -39,6 +38,7 @@ import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.context.request.WebRequest; import org.springframework.web.method.support.ModelAndViewContainer; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static java.lang.annotation.ElementType.CONSTRUCTOR; import static java.lang.annotation.ElementType.FIELD; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java index 31a3a271551a..9e4b9f3c0b37 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java @@ -30,8 +30,6 @@ import org.springframework.core.MethodIntrospector; import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.ui.Model; import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.annotation.ModelAttribute; @@ -46,6 +44,8 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolverComposite; import org.springframework.web.method.support.InvocableHandlerMethod; import org.springframework.web.method.support.ModelAndViewContainer; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java index afcfdc1b2d67..1275c08b6950 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java @@ -23,7 +23,6 @@ import org.junit.jupiter.api.Test; import org.springframework.core.LocalVariableTableParameterNameDiscoverer; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; import org.springframework.validation.BindingResult; @@ -40,6 +39,7 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolverComposite; import org.springframework.web.method.support.InvocableHandlerMethod; import org.springframework.web.method.support.ModelAndViewContainer; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelMethodProcessorTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelMethodProcessorTests.java index f3c5564c598c..8b28fdd4cf9f 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelMethodProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelMethodProcessorTests.java @@ -22,12 +22,12 @@ import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.ui.ExtendedModelMap; import org.springframework.ui.Model; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.method.support.ModelAndViewContainer; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java index 98568ec4fc1a..87e14b6a6411 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java @@ -26,13 +26,13 @@ import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; import org.springframework.http.HttpHeaders; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolverTests.java index 5f272dec905e..6acee9f04fbd 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolverTests.java @@ -30,8 +30,6 @@ import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; import org.springframework.format.support.DefaultFormattingConversionService; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.ServletRequestBindingException; import org.springframework.web.bind.annotation.RequestHeader; @@ -41,6 +39,8 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.context.support.GenericWebApplicationContext; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java index 10f433583cd4..8bc0dcb26600 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.mock.web.test.MockMultipartFile; -import org.springframework.mock.web.test.MockMultipartHttpServletRequest; -import org.springframework.mock.web.test.MockPart; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockMultipartFile; +import org.springframework.web.testfixture.servlet.MockMultipartHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockPart; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.web.method.MvcAnnotationPredicates.requestParam; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.requestParam; /** * Test fixture with {@link RequestParamMapMethodArgumentResolver}. diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java index 5ff9eba368f3..6cef633eae07 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java @@ -28,11 +28,6 @@ import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.core.MethodParameter; import org.springframework.core.convert.support.DefaultConversionService; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.mock.web.test.MockMultipartFile; -import org.springframework.mock.web.test.MockMultipartHttpServletRequest; -import org.springframework.mock.web.test.MockPart; import org.springframework.web.bind.MissingServletRequestParameterException; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.RequestParam; @@ -43,17 +38,22 @@ import org.springframework.web.bind.support.WebRequestDataBinder; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.multipart.MultipartException; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.support.MissingServletRequestPartException; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockMultipartFile; +import org.springframework.web.testfixture.servlet.MockMultipartHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockPart; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import static org.springframework.web.method.MvcAnnotationPredicates.requestParam; -import static org.springframework.web.method.MvcAnnotationPredicates.requestPart; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.requestParam; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.requestPart; /** * Test fixture with {@link RequestParamMethodArgumentResolver}. diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java index 269fc9dc8304..9c856d2d5337 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java @@ -22,13 +22,13 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.testfixture.beans.TestBean; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.bind.support.DefaultSessionAttributeStore; import org.springframework.web.bind.support.SessionAttributeStore; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/WebArgumentResolverAdapterTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/WebArgumentResolverAdapterTests.java index b6d1c22b3d8d..30cb6858bc7c 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/WebArgumentResolverAdapterTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/WebArgumentResolverAdapterTests.java @@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.bind.support.WebArgumentResolver; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/method/support/InvocableHandlerMethodTests.java b/spring-web/src/test/java/org/springframework/web/method/support/InvocableHandlerMethodTests.java index d2f6676d5086..041d5f0cc2b8 100644 --- a/spring-web/src/test/java/org/springframework/web/method/support/InvocableHandlerMethodTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/support/InvocableHandlerMethodTests.java @@ -22,12 +22,12 @@ import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.web.bind.support.WebDataBinderFactory; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; -import org.springframework.web.method.ResolvableMethod; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java b/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java index 7b7b9fd3940c..e4aa779da5be 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java @@ -46,11 +46,6 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; -import org.springframework.mock.web.test.MockFilterConfig; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; -import org.springframework.mock.web.test.MockServletContext; -import org.springframework.mock.web.test.PassThroughFilterChain; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.ServletRequestDataBinder; import org.springframework.web.context.WebApplicationContext; @@ -60,6 +55,11 @@ import org.springframework.web.multipart.support.ByteArrayMultipartFileEditor; import org.springframework.web.multipart.support.MultipartFilter; import org.springframework.web.multipart.support.StringMultipartFileEditor; +import org.springframework.web.testfixture.servlet.MockFilterConfig; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; +import org.springframework.web.testfixture.servlet.MockServletContext; +import org.springframework.web.testfixture.servlet.PassThroughFilterChain; import org.springframework.web.util.WebUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequestTests.java b/spring-web/src/test/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequestTests.java index e98f58de2a24..b241108a123f 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequestTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequestTests.java @@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java b/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java index 1344579e2bb2..9c47afeb679c 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java @@ -28,10 +28,10 @@ import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.server.ServerHttpRequest; -import org.springframework.mock.web.test.MockMultipartFile; -import org.springframework.mock.web.test.MockMultipartHttpServletRequest; import org.springframework.util.FileCopyUtils; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.testfixture.servlet.MockMultipartFile; +import org.springframework.web.testfixture.servlet.MockMultipartHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequestTests.java b/spring-web/src/test/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequestTests.java index 6ce3f7d0de2d..529639843c71 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequestTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequestTests.java @@ -23,11 +23,11 @@ import org.springframework.http.MockHttpOutputMessage; import org.springframework.http.converter.FormHttpMessageConverter; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockPart; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockPart; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeCheckNotModifiedTests.java b/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeCheckNotModifiedTests.java index 3f0fdfc90cac..97b963bd32f8 100644 --- a/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeCheckNotModifiedTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeCheckNotModifiedTests.java @@ -26,11 +26,11 @@ import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * "checkNotModified" unit tests for {@link DefaultServerWebExchange}. diff --git a/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeTests.java b/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeTests.java index dd7045c2cd31..ad0eb02a9861 100644 --- a/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeTests.java @@ -19,11 +19,11 @@ import org.junit.jupiter.api.Test; import org.springframework.http.codec.ServerCodecConfigurer; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver; import org.springframework.web.server.session.DefaultWebSessionManager; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/server/adapter/ForwardedHeaderTransformerTests.java b/spring-web/src/test/java/org/springframework/web/server/adapter/ForwardedHeaderTransformerTests.java index 3f5a674fe50d..25d27be12fe6 100644 --- a/spring-web/src/test/java/org/springframework/web/server/adapter/ForwardedHeaderTransformerTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/adapter/ForwardedHeaderTransformerTests.java @@ -23,7 +23,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java b/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java index 08e30c83b4db..d753b6c8d47a 100644 --- a/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java @@ -30,12 +30,12 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebExceptionHandler; import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebHandler; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static java.time.Duration.ofMillis; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/server/handler/ExceptionHandlingWebHandlerTests.java b/spring-web/src/test/java/org/springframework/web/server/handler/ExceptionHandlingWebHandlerTests.java index 8524dabaee62..4e27848f5f15 100644 --- a/spring-web/src/test/java/org/springframework/web/server/handler/ExceptionHandlingWebHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/handler/ExceptionHandlingWebHandlerTests.java @@ -23,12 +23,12 @@ import reactor.test.StepVerifier; import org.springframework.http.HttpStatus; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebExceptionHandler; import org.springframework.web.server.WebHandler; import org.springframework.web.server.adapter.HttpWebHandlerAdapter; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/server/handler/FilteringWebHandlerTests.java b/spring-web/src/test/java/org/springframework/web/server/handler/FilteringWebHandlerTests.java index d567ff9bd41c..c1b0d34406fb 100644 --- a/spring-web/src/test/java/org/springframework/web/server/handler/FilteringWebHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/handler/FilteringWebHandlerTests.java @@ -26,15 +26,15 @@ import reactor.core.publisher.Mono; import org.springframework.http.HttpStatus; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebExceptionHandler; import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebFilterChain; import org.springframework.web.server.WebHandler; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java b/spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java index 1048dbb226c9..5943d8896c3d 100644 --- a/spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java @@ -16,25 +16,7 @@ package org.springframework.web.server.handler; -import java.time.Duration; -import java.util.Arrays; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; -import org.springframework.web.server.MethodNotAllowedException; -import org.springframework.web.server.NotAcceptableStatusException; -import org.springframework.web.server.ResponseStatusException; - -import static org.assertj.core.api.Assertions.assertThat; +import org.springframework.web.testfixture.server.handler.AbstractResponseStatusExceptionHandlerTests; /** * Unit tests for {@link ResponseStatusExceptionHandler}. @@ -42,71 +24,8 @@ * @author Rossen Stoyanchev * @author Juergen Hoeller */ -public class ResponseStatusExceptionHandlerTests { - - protected final MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); - - protected ResponseStatusExceptionHandler handler; - - - @BeforeEach - public void setup() { - this.handler = createResponseStatusExceptionHandler(); - } - - protected ResponseStatusExceptionHandler createResponseStatusExceptionHandler() { - return new ResponseStatusExceptionHandler(); - } - - - @Test - public void handleResponseStatusException() { - Throwable ex = new ResponseStatusException(HttpStatus.BAD_REQUEST, ""); - this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); - assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); - } - - @Test - public void handleNestedResponseStatusException() { - Throwable ex = new Exception(new ResponseStatusException(HttpStatus.BAD_REQUEST, "")); - this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); - assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); - } - - @Test // gh-23741 - public void handleMethodNotAllowed() { - Throwable ex = new MethodNotAllowedException(HttpMethod.PATCH, Arrays.asList(HttpMethod.POST, HttpMethod.PUT)); - this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); - - MockServerHttpResponse response = this.exchange.getResponse(); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.METHOD_NOT_ALLOWED); - assertThat(response.getHeaders().getAllow()).containsOnly(HttpMethod.POST, HttpMethod.PUT); - } - - @Test // gh-23741 - public void handleResponseStatusExceptionWithHeaders() { - Throwable ex = new NotAcceptableStatusException(Arrays.asList(MediaType.TEXT_PLAIN, MediaType.TEXT_HTML)); - this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); - - MockServerHttpResponse response = this.exchange.getResponse(); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_ACCEPTABLE); - assertThat(response.getHeaders().getAccept()).containsOnly(MediaType.TEXT_PLAIN, MediaType.TEXT_HTML); - } - - @Test - public void unresolvedException() { - Throwable expected = new IllegalStateException(); - Mono mono = this.handler.handle(this.exchange, expected); - StepVerifier.create(mono).consumeErrorWith(actual -> assertThat(actual).isSameAs(expected)).verify(); - } +public class ResponseStatusExceptionHandlerTests extends AbstractResponseStatusExceptionHandlerTests { - @Test // SPR-16231 - public void responseCommitted() { - Throwable ex = new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Oops"); - this.exchange.getResponse().setStatusCode(HttpStatus.CREATED); - Mono mono = this.exchange.getResponse().setComplete() - .then(Mono.defer(() -> this.handler.handle(this.exchange, ex))); - StepVerifier.create(mono).consumeErrorWith(actual -> assertThat(actual).isSameAs(ex)).verify(); - } + // all tests in super class } diff --git a/spring-web/src/test/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolverTests.java b/spring-web/src/test/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolverTests.java index 882e7ddb8f5b..c4ba2d3c676a 100644 --- a/spring-web/src/test/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolverTests.java @@ -23,9 +23,9 @@ import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static java.util.Locale.CANADA; import static java.util.Locale.ENGLISH; diff --git a/spring-web/src/test/java/org/springframework/web/server/i18n/FixedLocaleContextResolverTests.java b/spring-web/src/test/java/org/springframework/web/server/i18n/FixedLocaleContextResolverTests.java index 290998067181..0ed2842f1586 100644 --- a/spring-web/src/test/java/org/springframework/web/server/i18n/FixedLocaleContextResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/i18n/FixedLocaleContextResolverTests.java @@ -24,9 +24,9 @@ import org.junit.jupiter.api.Test; import org.springframework.context.i18n.TimeZoneAwareLocaleContext; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static java.util.Locale.CANADA; import static java.util.Locale.FRANCE; diff --git a/spring-web/src/test/java/org/springframework/web/server/session/CookieWebSessionIdResolverTests.java b/spring-web/src/test/java/org/springframework/web/server/session/CookieWebSessionIdResolverTests.java index 5eb203761c68..71d950c736ce 100644 --- a/spring-web/src/test/java/org/springframework/web/server/session/CookieWebSessionIdResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/session/CookieWebSessionIdResolverTests.java @@ -18,9 +18,9 @@ import org.junit.jupiter.api.Test; import org.springframework.http.ResponseCookie; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.MultiValueMap; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/server/session/DefaultWebSessionManagerTests.java b/spring-web/src/test/java/org/springframework/web/server/session/DefaultWebSessionManagerTests.java index 7dca7c1d1e6b..3125862aa6cf 100644 --- a/spring-web/src/test/java/org/springframework/web/server/session/DefaultWebSessionManagerTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/session/DefaultWebSessionManagerTests.java @@ -28,12 +28,12 @@ import reactor.core.publisher.Mono; import org.springframework.http.codec.ServerCodecConfigurer; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebSession; import org.springframework.web.server.adapter.DefaultServerWebExchange; import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; diff --git a/spring-web/src/test/java/org/springframework/web/server/session/HeaderWebSessionIdResolverTests.java b/spring-web/src/test/java/org/springframework/web/server/session/HeaderWebSessionIdResolverTests.java index 5e9c7f2eab15..1347e2c05cbb 100644 --- a/spring-web/src/test/java/org/springframework/web/server/session/HeaderWebSessionIdResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/session/HeaderWebSessionIdResolverTests.java @@ -21,9 +21,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/web/server/session/WebSessionIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/server/session/WebSessionIntegrationTests.java index 922199e7e980..0fa99e340bae 100644 --- a/spring-web/src/test/java/org/springframework/web/server/session/WebSessionIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/session/WebSessionIntegrationTests.java @@ -29,14 +29,14 @@ import org.springframework.http.HttpStatus; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebHandler; import org.springframework.web.server.WebSession; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java b/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java index 20f040715f33..8f8ac90629bd 100644 --- a/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java @@ -18,8 +18,8 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.util.FileCopyUtils; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-web/src/test/java/org/springframework/web/util/ServletContextPropertyUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/ServletContextPropertyUtilsTests.java index 3a66ff0b2280..d87c7c416518 100644 --- a/spring-web/src/test/java/org/springframework/web/util/ServletContextPropertyUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/ServletContextPropertyUtilsTests.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockServletContext; +import org.springframework.web.testfixture.servlet.MockServletContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java index e8400799f9e4..011a3d77a718 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java @@ -29,10 +29,10 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpRequest; import org.springframework.http.server.ServletServerHttpRequest; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/web/util/UrlPathHelperTests.java b/spring-web/src/test/java/org/springframework/web/util/UrlPathHelperTests.java index 11cac7f0cf0a..82a069ae1288 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UrlPathHelperTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UrlPathHelperTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java index 0a4c0a3f76a2..68226877b166 100644 --- a/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java @@ -29,11 +29,11 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServletServerHttpRequest; -import org.springframework.mock.web.test.MockFilterChain; -import org.springframework.mock.web.test.MockHttpServletRequest; -import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.util.MultiValueMap; import org.springframework.web.filter.ForwardedHeaderFilter; +import org.springframework.web.testfixture.servlet.MockFilterChain; +import org.springframework.web.testfixture.servlet.MockHttpServletRequest; +import org.springframework.web.testfixture.servlet.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt b/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt index 8321d7f8119e..61c32fec3461 100644 --- a/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt +++ b/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt @@ -26,10 +26,10 @@ import org.springframework.core.annotation.SynthesizingMethodParameter import org.springframework.core.convert.support.DefaultConversionService import org.springframework.http.HttpMethod import org.springframework.http.MediaType -import org.springframework.mock.web.test.MockHttpServletRequest -import org.springframework.mock.web.test.MockHttpServletResponse -import org.springframework.mock.web.test.MockMultipartFile -import org.springframework.mock.web.test.MockMultipartHttpServletRequest +import org.springframework.web.testfixture.servlet.MockHttpServletRequest +import org.springframework.web.testfixture.servlet.MockHttpServletResponse +import org.springframework.web.testfixture.servlet.MockMultipartFile +import org.springframework.web.testfixture.servlet.MockMultipartHttpServletRequest import org.springframework.util.ReflectionUtils import org.springframework.web.bind.MissingServletRequestParameterException import org.springframework.web.bind.annotation.RequestParam diff --git a/spring-web/src/test/resources/org/springframework/http/server/reactive/spring.png b/spring-web/src/test/resources/org/springframework/web/spring.png similarity index 100% rename from spring-web/src/test/resources/org/springframework/http/server/reactive/spring.png rename to spring-web/src/test/resources/org/springframework/web/spring.png diff --git a/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpRequest.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/reactive/MockClientHttpRequest.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpRequest.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/reactive/MockClientHttpRequest.java index 02b9bceed263..fae88ad98df6 100644 --- a/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpRequest.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/reactive/MockClientHttpRequest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.http.client.reactive.test; +package org.springframework.web.testfixture.http.client.reactive; import java.net.URI; import java.nio.charset.Charset; diff --git a/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/reactive/MockClientHttpResponse.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/reactive/MockClientHttpResponse.java index e757bfad7c46..657f473b4c22 100644 --- a/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/reactive/MockClientHttpResponse.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.http.client.reactive.test; +package org.springframework.web.testfixture.http.client.reactive; import java.nio.ByteBuffer; import java.nio.charset.Charset; diff --git a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpRequest.java similarity index 99% rename from spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpRequest.java index 3b7ecb116510..0f41a41d21d0 100644 --- a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpRequest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.http.server.reactive.test; +package org.springframework.web.testfixture.http.server.reactive; import java.net.InetSocketAddress; import java.net.URI; diff --git a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpResponse.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpResponse.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpResponse.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpResponse.java index 98b92da526d0..fc82675a443d 100644 --- a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpResponse.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpResponse.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.http.server.reactive.test; +package org.springframework.web.testfixture.http.server.reactive; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/AbstractHttpHandlerIntegrationTests.java similarity index 88% rename from spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/AbstractHttpHandlerIntegrationTests.java index 88f47e37e608..90d05db9f20a 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/AbstractHttpHandlerIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.http.server.reactive; +package org.springframework.web.testfixture.http.server.reactive.bootstrap; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -32,11 +32,7 @@ import org.junit.jupiter.params.provider.MethodSource; import reactor.core.publisher.Flux; -import org.springframework.http.server.reactive.bootstrap.HttpServer; -import org.springframework.http.server.reactive.bootstrap.JettyHttpServer; -import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer; -import org.springframework.http.server.reactive.bootstrap.TomcatHttpServer; -import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer; +import org.springframework.http.server.reactive.HttpHandler; import org.springframework.util.StringUtils; import org.springframework.web.client.HttpServerErrorException; @@ -120,7 +116,7 @@ public static Flux testInterval(Duration period, int count) { @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @ParameterizedTest(name = "[{index}] {0}") - @MethodSource("org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests#httpServers()") + @MethodSource("org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests#httpServers()") // public for Kotlin public @interface ParameterizedHttpServerTest { } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/AbstractHttpServer.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/AbstractHttpServer.java similarity index 98% rename from spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/AbstractHttpServer.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/AbstractHttpServer.java index 8aca3b152e5e..6713282f9882 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/AbstractHttpServer.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/AbstractHttpServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.http.server.reactive.bootstrap; +package org.springframework.web.testfixture.http.server.reactive.bootstrap; import java.util.LinkedHashMap; import java.util.Map; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/HttpServer.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/HttpServer.java similarity index 92% rename from spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/HttpServer.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/HttpServer.java index 9abb1fe14c15..a17dbf80eab5 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/HttpServer.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/HttpServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.http.server.reactive.bootstrap; +package org.springframework.web.testfixture.http.server.reactive.bootstrap; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.Lifecycle; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/JettyHttpServer.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/JettyHttpServer.java similarity index 97% rename from spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/JettyHttpServer.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/JettyHttpServer.java index 4d63e75202bd..93f828bc3ddf 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/JettyHttpServer.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/JettyHttpServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.http.server.reactive.bootstrap; +package org.springframework.web.testfixture.http.server.reactive.bootstrap; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/ReactorHttpServer.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/ReactorHttpServer.java similarity index 96% rename from spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/ReactorHttpServer.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/ReactorHttpServer.java index 25e9b2ac3c7d..4df1070f61ff 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/ReactorHttpServer.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/ReactorHttpServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.http.server.reactive.bootstrap; +package org.springframework.web.testfixture.http.server.reactive.bootstrap; import java.util.concurrent.atomic.AtomicReference; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/ReactorHttpsServer.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/ReactorHttpsServer.java similarity index 96% rename from spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/ReactorHttpsServer.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/ReactorHttpsServer.java index 1a7636d93516..004e27832a9e 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/ReactorHttpsServer.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/ReactorHttpsServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.http.server.reactive.bootstrap; +package org.springframework.web.testfixture.http.server.reactive.bootstrap; import java.util.concurrent.atomic.AtomicReference; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/TomcatHttpServer.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/TomcatHttpServer.java similarity index 97% rename from spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/TomcatHttpServer.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/TomcatHttpServer.java index fb34b471cf06..2a1aeb556dfb 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/TomcatHttpServer.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/TomcatHttpServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.http.server.reactive.bootstrap; +package org.springframework.web.testfixture.http.server.reactive.bootstrap; import java.io.File; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/UndertowHttpServer.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/UndertowHttpServer.java similarity index 95% rename from spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/UndertowHttpServer.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/UndertowHttpServer.java index cdfc5711ac66..d195bae69551 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/UndertowHttpServer.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/UndertowHttpServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.http.server.reactive.bootstrap; +package org.springframework.web.testfixture.http.server.reactive.bootstrap; import java.net.InetSocketAddress; diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/package-info.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/package-info.java new file mode 100644 index 000000000000..82c65baf2be1 --- /dev/null +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/package-info.java @@ -0,0 +1,6 @@ +/** + * This package contains temporary interfaces and classes for running embedded servers. + * + *

    They are expected to be replaced by upcoming Spring Boot support. + */ +package org.springframework.web.testfixture.http.server.reactive.bootstrap; diff --git a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/package-info.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/package-info.java similarity index 73% rename from spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/package-info.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/package-info.java index 03e7701a7bdb..cc95fcf042c6 100644 --- a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/package-info.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/package-info.java @@ -3,7 +3,7 @@ */ @NonNullApi @NonNullFields -package org.springframework.mock.http.server.reactive.test; +package org.springframework.web.testfixture.http.server.reactive; import org.springframework.lang.NonNullApi; import org.springframework.lang.NonNullFields; diff --git a/spring-web/src/test/java/org/springframework/web/method/MvcAnnotationPredicates.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/method/MvcAnnotationPredicates.java similarity index 98% rename from spring-web/src/test/java/org/springframework/web/method/MvcAnnotationPredicates.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/method/MvcAnnotationPredicates.java index 1a95d49a9592..9bde5d3eab40 100644 --- a/spring-web/src/test/java/org/springframework/web/method/MvcAnnotationPredicates.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/method/MvcAnnotationPredicates.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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. @@ -13,7 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.web.method; + +package org.springframework.web.testfixture.method; import java.lang.reflect.Method; import java.util.Arrays; @@ -44,7 +45,6 @@ */ public class MvcAnnotationPredicates { - // Method parameter predicates public static ModelAttributePredicate modelAttribute() { diff --git a/spring-web/src/test/java/org/springframework/web/method/ResolvableMethod.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/method/ResolvableMethod.java similarity index 97% rename from spring-web/src/test/java/org/springframework/web/method/ResolvableMethod.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/method/ResolvableMethod.java index 4fc0ddd14d84..6ccef862b459 100644 --- a/spring-web/src/test/java/org/springframework/web/method/ResolvableMethod.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/method/ResolvableMethod.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.method; +package org.springframework.web.testfixture.method; import java.lang.annotation.Annotation; import java.lang.reflect.Method; @@ -188,7 +188,7 @@ public MethodParameter arg(ResolvableType type) { /** * Filter on method arguments with annotation. - * See {@link org.springframework.web.method.MvcAnnotationPredicates}. + * See {@link org.springframework.web.testfixture.method.MvcAnnotationPredicates}. */ @SafeVarargs public final ArgResolver annot(Predicate... filter) { @@ -301,7 +301,7 @@ public Builder argTypes(Class... argTypes) { /** * Filter on annotated methods. - * See {@link org.springframework.web.method.MvcAnnotationPredicates}. + * See {@link org.springframework.web.testfixture.method.MvcAnnotationPredicates}. */ @SafeVarargs public final Builder annot(Predicate... filters) { @@ -312,7 +312,7 @@ public final Builder annot(Predicate... filters) { /** * Filter on methods annotated with the given annotation type. * @see #annot(Predicate[]) - * See {@link org.springframework.web.method.MvcAnnotationPredicates}. + * See {@link org.springframework.web.testfixture.method.MvcAnnotationPredicates}. */ @SafeVarargs public final Builder annotPresent(Class... annotationTypes) { @@ -529,7 +529,7 @@ private ArgResolver(Predicate... filter) { /** * Filter on method arguments with annotations. - * See {@link org.springframework.web.method.MvcAnnotationPredicates}. + * See {@link org.springframework.web.testfixture.method.MvcAnnotationPredicates}. */ @SafeVarargs public final ArgResolver annot(Predicate... filters) { @@ -541,7 +541,7 @@ public final ArgResolver annot(Predicate... filters) { * Filter on method arguments that have the given annotations. * @param annotationTypes the annotation types * @see #annot(Predicate[]) - * See {@link org.springframework.web.method.MvcAnnotationPredicates}. + * See {@link org.springframework.web.testfixture.method.MvcAnnotationPredicates}. */ @SafeVarargs public final ArgResolver annotPresent(Class... annotationTypes) { diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/server/MockServerWebExchange.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/MockServerWebExchange.java similarity index 94% rename from spring-web/src/test/java/org/springframework/mock/web/test/server/MockServerWebExchange.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/MockServerWebExchange.java index 75b51a892bcb..000eadd6a244 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/server/MockServerWebExchange.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/MockServerWebExchange.java @@ -13,19 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.mock.web.test.server; +package org.springframework.web.testfixture.server; import reactor.core.publisher.Mono; import org.springframework.http.codec.ServerCodecConfigurer; import org.springframework.lang.Nullable; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.web.server.WebSession; import org.springframework.web.server.adapter.DefaultServerWebExchange; import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver; import org.springframework.web.server.session.DefaultWebSessionManager; import org.springframework.web.server.session.WebSessionManager; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; /** * Extension of {@link DefaultServerWebExchange} for use in tests, along with diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/server/MockWebSession.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/MockWebSession.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/server/MockWebSession.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/MockWebSession.java index ce043a2b1e1f..689418372fd3 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/server/MockWebSession.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/MockWebSession.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test.server; +package org.springframework.web.testfixture.server; import java.time.Clock; import java.time.Duration; diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/handler/AbstractResponseStatusExceptionHandlerTests.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/handler/AbstractResponseStatusExceptionHandlerTests.java new file mode 100644 index 000000000000..facc2681dd6e --- /dev/null +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/handler/AbstractResponseStatusExceptionHandlerTests.java @@ -0,0 +1,113 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.web.testfixture.server.handler; + +import java.time.Duration; +import java.util.Arrays; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; + +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.server.MethodNotAllowedException; +import org.springframework.web.server.NotAcceptableStatusException; +import org.springframework.web.server.ResponseStatusException; +import org.springframework.web.server.handler.ResponseStatusExceptionHandler; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Abstract base class for unit tests for {@link ResponseStatusExceptionHandler}. + * + * @author Rossen Stoyanchev + * @author Juergen Hoeller + */ +public abstract class AbstractResponseStatusExceptionHandlerTests { + + protected final MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); + + protected ResponseStatusExceptionHandler handler; + + + @BeforeEach + public void setup() { + this.handler = createResponseStatusExceptionHandler(); + } + + protected ResponseStatusExceptionHandler createResponseStatusExceptionHandler() { + return new ResponseStatusExceptionHandler(); + } + + + @Test + public void handleResponseStatusException() { + Throwable ex = new ResponseStatusException(HttpStatus.BAD_REQUEST, ""); + this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); + assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); + } + + @Test + public void handleNestedResponseStatusException() { + Throwable ex = new Exception(new ResponseStatusException(HttpStatus.BAD_REQUEST, "")); + this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); + assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); + } + + @Test // gh-23741 + public void handleMethodNotAllowed() { + Throwable ex = new MethodNotAllowedException(HttpMethod.PATCH, Arrays.asList(HttpMethod.POST, HttpMethod.PUT)); + this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); + + MockServerHttpResponse response = this.exchange.getResponse(); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.METHOD_NOT_ALLOWED); + assertThat(response.getHeaders().getAllow()).containsOnly(HttpMethod.POST, HttpMethod.PUT); + } + + @Test // gh-23741 + public void handleResponseStatusExceptionWithHeaders() { + Throwable ex = new NotAcceptableStatusException(Arrays.asList(MediaType.TEXT_PLAIN, MediaType.TEXT_HTML)); + this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); + + MockServerHttpResponse response = this.exchange.getResponse(); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_ACCEPTABLE); + assertThat(response.getHeaders().getAccept()).containsOnly(MediaType.TEXT_PLAIN, MediaType.TEXT_HTML); + } + + @Test + public void unresolvedException() { + Throwable expected = new IllegalStateException(); + Mono mono = this.handler.handle(this.exchange, expected); + StepVerifier.create(mono).consumeErrorWith(actual -> assertThat(actual).isSameAs(expected)).verify(); + } + + @Test // SPR-16231 + public void responseCommitted() { + Throwable ex = new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Oops"); + this.exchange.getResponse().setStatusCode(HttpStatus.CREATED); + Mono mono = this.exchange.getResponse().setComplete() + .then(Mono.defer(() -> this.handler.handle(this.exchange, ex))); + StepVerifier.create(mono).consumeErrorWith(actual -> assertThat(actual).isSameAs(ex)).verify(); + } + +} diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/server/package-info.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/package-info.java similarity index 77% rename from spring-web/src/test/java/org/springframework/mock/web/test/server/package-info.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/package-info.java index d1986319e449..54867a24232a 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/server/package-info.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/package-info.java @@ -3,7 +3,7 @@ */ @NonNullApi @NonNullFields -package org.springframework.mock.web.test.server; +package org.springframework.web.testfixture.server; import org.springframework.lang.NonNullApi; import org.springframework.lang.NonNullFields; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/DelegatingServletInputStream.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/DelegatingServletInputStream.java similarity index 97% rename from spring-web/src/test/java/org/springframework/mock/web/test/DelegatingServletInputStream.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/DelegatingServletInputStream.java index 577cfc0abc00..7be60d7318d3 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/DelegatingServletInputStream.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/DelegatingServletInputStream.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.IOException; import java.io.InputStream; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/DelegatingServletOutputStream.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/DelegatingServletOutputStream.java similarity index 97% rename from spring-web/src/test/java/org/springframework/mock/web/test/DelegatingServletOutputStream.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/DelegatingServletOutputStream.java index e70b2984f681..774f4bf672c3 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/DelegatingServletOutputStream.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/DelegatingServletOutputStream.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.IOException; import java.io.OutputStream; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/HeaderValueHolder.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/HeaderValueHolder.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/HeaderValueHolder.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/HeaderValueHolder.java index 1259509f22f7..5a36ee347d76 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/HeaderValueHolder.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/HeaderValueHolder.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.util.ArrayList; import java.util.Collection; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockAsyncContext.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockAsyncContext.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockAsyncContext.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockAsyncContext.java index 577847644760..0391911be354 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockAsyncContext.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockAsyncContext.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.IOException; import java.util.ArrayList; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockBodyContent.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockBodyContent.java similarity index 99% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockBodyContent.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockBodyContent.java index f38bf8a175e2..1d6a50611f24 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockBodyContent.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockBodyContent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.IOException; import java.io.Reader; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockCookie.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockCookie.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockCookie.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockCookie.java index 408e2ecefdd1..8f2e5eaa9756 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockCookie.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockCookie.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.time.DateTimeException; import java.time.ZonedDateTime; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockExpressionEvaluator.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockExpressionEvaluator.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockExpressionEvaluator.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockExpressionEvaluator.java index 0a778efb9163..3358798e7689 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockExpressionEvaluator.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockExpressionEvaluator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockFilterChain.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockFilterChain.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockFilterChain.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockFilterChain.java index b834e789cb68..259fecf306a3 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockFilterChain.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockFilterChain.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.IOException; import java.util.Arrays; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockFilterConfig.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockFilterConfig.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockFilterConfig.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockFilterConfig.java index 6428466ce530..2cd954986c36 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockFilterConfig.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockFilterConfig.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.util.Collections; import java.util.Enumeration; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletRequest.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java similarity index 99% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletRequest.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java index d02770268bd3..9aaa8589a532 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletRequest.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.BufferedReader; import java.io.ByteArrayInputStream; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletResponse.java similarity index 99% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletResponse.java index 21e24eb0ebd9..7f94c2265f28 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletResponse.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpSession.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpSession.java similarity index 99% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockHttpSession.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpSession.java index 01ed9876d6ae..b8302c48c570 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpSession.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpSession.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.Serializable; import java.util.Collections; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockJspWriter.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockJspWriter.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockJspWriter.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockJspWriter.java index dbc05ecd618c..03997d1076bd 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockJspWriter.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockJspWriter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.IOException; import java.io.PrintWriter; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartFile.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockMultipartFile.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartFile.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockMultipartFile.java index 8813df7e5cba..9250fb076c11 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartFile.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockMultipartFile.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.ByteArrayInputStream; import java.io.File; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartHttpServletRequest.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockMultipartHttpServletRequest.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartHttpServletRequest.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockMultipartHttpServletRequest.java index 996f1f562522..88757b539a99 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartHttpServletRequest.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockMultipartHttpServletRequest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.IOException; import java.util.Collections; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockPageContext.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPageContext.java similarity index 99% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockPageContext.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPageContext.java index 3959db201f4d..7ffc2d626319 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockPageContext.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPageContext.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.IOException; import java.io.UnsupportedEncodingException; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockPart.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPart.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockPart.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPart.java index 62398ffd801a..4079fd69c724 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockPart.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPart.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.ByteArrayInputStream; import java.io.IOException; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockRequestDispatcher.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockRequestDispatcher.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockRequestDispatcher.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockRequestDispatcher.java index df9dd91dcb0b..597f1730fff2 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockRequestDispatcher.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockRequestDispatcher.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import javax.servlet.RequestDispatcher; import javax.servlet.ServletRequest; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockServletConfig.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockServletConfig.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockServletConfig.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockServletConfig.java index 6bcec47ae480..81fcc2421dbb 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockServletConfig.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockServletConfig.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.util.Collections; import java.util.Enumeration; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockServletContext.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockServletContext.java similarity index 99% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockServletContext.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockServletContext.java index 32fa355b8662..b6140042e0cb 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockServletContext.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockServletContext.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.File; import java.io.IOException; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockSessionCookieConfig.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockSessionCookieConfig.java similarity index 97% rename from spring-web/src/test/java/org/springframework/mock/web/test/MockSessionCookieConfig.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockSessionCookieConfig.java index 54b9b5bf28b3..c7f834508745 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockSessionCookieConfig.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockSessionCookieConfig.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import javax.servlet.SessionCookieConfig; diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/PassThroughFilterChain.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/PassThroughFilterChain.java similarity index 98% rename from spring-web/src/test/java/org/springframework/mock/web/test/PassThroughFilterChain.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/PassThroughFilterChain.java index c440b7857908..e3537156ac53 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/PassThroughFilterChain.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/PassThroughFilterChain.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.mock.web.test; +package org.springframework.web.testfixture.servlet; import java.io.IOException; diff --git a/spring-web/src/test/java/org/springframework/http/codec/Pojo.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/xml/Pojo.java similarity index 96% rename from spring-web/src/test/java/org/springframework/http/codec/Pojo.java rename to spring-web/src/testFixtures/java/org/springframework/web/testfixture/xml/Pojo.java index 4db33fefbbe3..59accabc9a29 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/Pojo.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/xml/Pojo.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.http.codec; +package org.springframework.web.testfixture.xml; import javax.xml.bind.annotation.XmlRootElement; diff --git a/spring-web/src/test/resources/org/springframework/http/codec/multipart/foo.txt b/spring-web/src/testFixtures/resources/org/springframework/http/codec/multipart/foo.txt similarity index 100% rename from spring-web/src/test/resources/org/springframework/http/codec/multipart/foo.txt rename to spring-web/src/testFixtures/resources/org/springframework/http/codec/multipart/foo.txt diff --git a/spring-webflux/spring-webflux.gradle b/spring-webflux/spring-webflux.gradle index 3a3fe9487cb2..a636d47ad84e 100644 --- a/spring-webflux/spring-webflux.gradle +++ b/spring-webflux/spring-webflux.gradle @@ -33,6 +33,7 @@ dependencies { testCompile(project(":kotlin-coroutines")) testCompile(testFixtures(project(":spring-beans"))) testCompile(testFixtures(project(":spring-core"))) + testCompile(testFixtures(project(":spring-web"))) testCompile("javax.xml.bind:jaxb-api") testCompile("com.fasterxml:aalto-xml") testCompile("org.hibernate:hibernate-validator") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java index 43d1401e7fe1..f90fd6bc681b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java @@ -33,8 +33,6 @@ import org.springframework.core.codec.CharSequenceEncoder; import org.springframework.http.HttpStatus; import org.springframework.http.codec.EncoderHttpMessageWriter; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -49,6 +47,8 @@ import org.springframework.web.server.WebExceptionHandler; import org.springframework.web.server.WebHandler; import org.springframework.web.server.handler.ExceptionHandlingWebHandler; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.http.MediaType.APPLICATION_JSON; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java index 30c73409ace8..992990f6dca6 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java @@ -28,10 +28,10 @@ import org.springframework.core.Ordered; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java index 62fe229976a0..66143e4f2f76 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java @@ -24,12 +24,12 @@ import reactor.test.StepVerifier; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java index 8f96d37b3e28..8c2a104e8a85 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java @@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.NotAcceptableStatusException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java index b7fcd474c7bf..70f8a8e7741d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java @@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.NotAcceptableStatusException; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java index dd324411064f..2020bc23686d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java index 5ec569118c95..4129b8b90e6c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java @@ -31,8 +31,6 @@ import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.CacheControl; import org.springframework.http.server.PathContainer; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping; import org.springframework.web.reactive.resource.AppCacheManifestTransformer; @@ -47,6 +45,8 @@ import org.springframework.web.reactive.resource.ResourceWebHandler; import org.springframework.web.reactive.resource.VersionResourceResolver; import org.springframework.web.reactive.resource.WebJarsResourceResolver; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java index 8a6e77ae0f9d..5956a9391d46 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java @@ -45,7 +45,6 @@ import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.codec.xml.Jaxb2XmlDecoder; import org.springframework.http.codec.xml.Jaxb2XmlEncoder; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; import org.springframework.util.MultiValueMap; @@ -75,6 +74,7 @@ import org.springframework.web.reactive.result.view.freemarker.FreeMarkerViewResolver; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebHandler; +import org.springframework.web.testfixture.server.MockServerWebExchange; import org.springframework.web.util.pattern.PathPatternParser; import static org.assertj.core.api.Assertions.assertThat; @@ -87,7 +87,7 @@ import static org.springframework.http.MediaType.APPLICATION_XML; import static org.springframework.http.MediaType.IMAGE_PNG; import static org.springframework.http.MediaType.TEXT_PLAIN; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link WebFluxConfigurationSupport}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java index fa5944a9188f..55aa6302ffdb 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java @@ -59,9 +59,9 @@ import org.springframework.http.codec.xml.Jaxb2XmlDecoder; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.mock.http.client.reactive.test.MockClientHttpResponse; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.util.MultiValueMap; +import org.springframework.web.testfixture.http.client.reactive.MockClientHttpResponse; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java index a74864d76593..11141262083f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java @@ -61,11 +61,11 @@ import org.springframework.http.codec.xml.Jaxb2XmlEncoder; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.mock.http.client.reactive.test.MockClientHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import org.springframework.web.testfixture.http.client.reactive.MockClientHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java index afabb433accc..7ce6e021afcd 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java @@ -32,7 +32,6 @@ import org.springframework.http.codec.multipart.FilePart; import org.springframework.http.codec.multipart.FormFieldPart; import org.springframework.http.codec.multipart.Part; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.util.FileCopyUtils; import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.function.client.ClientResponse; @@ -41,6 +40,7 @@ import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.ServerRequest; import org.springframework.web.reactive.function.server.ServerResponse; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilderTests.java index f01f37c89970..c9bef9b638cf 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilderTests.java @@ -33,8 +33,8 @@ import org.springframework.http.client.reactive.ClientHttpRequest; import org.springframework.http.codec.EncoderHttpMessageWriter; import org.springframework.http.codec.HttpMessageWriter; -import org.springframework.mock.http.client.reactive.test.MockClientHttpRequest; import org.springframework.web.reactive.function.BodyInserter; +import org.springframework.web.testfixture.http.client.reactive.MockClientHttpRequest; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java index dfe54d29dc8e..659004be4894 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java @@ -58,7 +58,7 @@ import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.http.client.reactive.JettyClientHttpConnector; import org.springframework.http.client.reactive.ReactorClientHttpConnector; -import org.springframework.http.codec.Pojo; +import org.springframework.web.testfixture.xml.Pojo; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/AbstractRouterFunctionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/AbstractRouterFunctionIntegrationTests.java index 64dcaa8ed73a..91e76516e97b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/AbstractRouterFunctionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/AbstractRouterFunctionIntegrationTests.java @@ -16,8 +16,8 @@ package org.springframework.web.reactive.function.server; -import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; /** * @author Arjen Poutsma diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java index e6aafd795dfe..96ad5cc5cddc 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java @@ -41,12 +41,12 @@ import org.springframework.http.ResponseCookie; import org.springframework.http.codec.EncoderHttpMessageWriter; import org.springframework.http.codec.HttpMessageWriter; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.result.view.ViewResolver; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java index 46a57bb063dd..95952c55f3ab 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java @@ -34,9 +34,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseCookie; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.result.view.AbstractView; @@ -44,6 +41,9 @@ import org.springframework.web.reactive.result.view.ViewResolver; import org.springframework.web.reactive.result.view.ViewResolverSupport; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java index ee85f887207e..8e4f483d5986 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java @@ -27,8 +27,8 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseCookie; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java index 87feefb06df7..b4e17cca6922 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java @@ -49,12 +49,12 @@ import org.springframework.http.codec.json.Jackson2JsonDecoder; import org.springframework.http.codec.multipart.FormFieldPart; import org.springframework.http.codec.multipart.Part; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.server.ServerWebInputException; import org.springframework.web.server.UnsupportedMediaTypeStatusException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java index d687a29f8cac..38b295463ca4 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java @@ -36,12 +36,12 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseCookie; import org.springframework.http.codec.HttpMessageWriter; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.result.view.ViewResolver; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java index 25dd8a2b2778..3bc9716124af 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java @@ -29,9 +29,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -40,6 +38,8 @@ import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.reactive.config.EnableWebFlux; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.util.pattern.PathPattern; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/InvalidHttpMethodIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/InvalidHttpMethodIntegrationTests.java index 764792ab228c..f7bdf6e3f523 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/InvalidHttpMethodIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/InvalidHttpMethodIntegrationTests.java @@ -20,7 +20,7 @@ import okhttp3.Request; import okhttp3.Response; -import org.springframework.http.server.reactive.bootstrap.HttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java index e5a229a9f7b4..efc8cf8c1e24 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java @@ -26,7 +26,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.lang.Nullable; import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; @@ -34,6 +33,7 @@ import org.springframework.web.reactive.result.view.ViewResolver; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.i18n.FixedLocaleContextResolver; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/NestedRouteIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/NestedRouteIntegrationTests.java index ca13675bb5e4..bab05a7a1285 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/NestedRouteIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/NestedRouteIntegrationTests.java @@ -24,9 +24,9 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.lang.Nullable; import org.springframework.web.client.RestTemplate; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.util.pattern.PathPattern; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java index c20054bbeb6b..b34685ea5632 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java @@ -27,8 +27,8 @@ import org.springframework.http.HttpStatus; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.web.reactive.function.BodyExtractors.toMono; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java index 6cf0a7baefdd..1e8819afd775 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java @@ -30,12 +30,12 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.lang.Nullable; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.result.view.View; import org.springframework.web.reactive.result.view.ViewResolver; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.web.reactive.function.server.HandlerFilterFunction.ofResponseProcessor; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java index 2eaeaf3c90d0..f20e3678a4ad 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java @@ -23,8 +23,8 @@ import org.springframework.core.codec.StringDecoder; import org.springframework.http.codec.DecoderHttpMessageReader; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java index 9b05431dbdc0..1c60b8a5ad15 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java @@ -32,10 +32,10 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.codec.HttpMessageWriter; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.reactive.result.view.ViewResolver; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java index be24c7d642aa..57919dece4a2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java @@ -27,14 +27,14 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseCookie; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebFilterChain; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java index 92d51cd7644d..9db4f97db40b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java @@ -25,8 +25,8 @@ import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.MediaType; import org.springframework.http.codec.ServerSentEvent; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.http.MediaType.TEXT_EVENT_STREAM; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java index 6276697abd4d..4d5b01404654 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java @@ -23,9 +23,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.DispatcherHandler; import org.springframework.web.reactive.config.EnableWebFlux; @@ -33,6 +31,8 @@ import org.springframework.web.reactive.function.server.ServerRequest; import org.springframework.web.reactive.function.server.ServerResponse; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.web.reactive.function.server.RequestPredicates.accept; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/RouterFunctionMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/RouterFunctionMappingTests.java index 88748cc50c75..4daa40f150cf 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/RouterFunctionMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/RouterFunctionMappingTests.java @@ -21,12 +21,12 @@ import reactor.test.StepVerifier; import org.springframework.http.codec.ServerCodecConfigurer; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.reactive.function.server.HandlerFunction; import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.ServerResponse; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; /** * @author Arjen Poutsma diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java index 652c78dfb8aa..b9385f0b9ceb 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java @@ -22,11 +22,11 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.reactive.CorsConfigurationSource; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java index 73d80b7c4326..38dbf17e4170 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java @@ -26,10 +26,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.http.HttpMethod; import org.springframework.http.server.PathContainer; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.web.reactive.HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java index 064a4d1eb644..6da2116256ba 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java @@ -23,7 +23,7 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.server.handler.ResponseStatusExceptionHandler; -import org.springframework.web.server.handler.ResponseStatusExceptionHandlerTests; +import org.springframework.web.testfixture.server.handler.AbstractResponseStatusExceptionHandlerTests; import static org.assertj.core.api.Assertions.assertThat; @@ -33,7 +33,7 @@ * @author Juergen Hoeller * @author Rossen Stoyanchev */ -public class WebFluxResponseStatusExceptionHandlerTests extends ResponseStatusExceptionHandlerTests { +public class WebFluxResponseStatusExceptionHandlerTests extends AbstractResponseStatusExceptionHandlerTests { @Override protected ResponseStatusExceptionHandler createResponseStatusExceptionHandler() { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java index 3856014728bc..d58f0fb81cbf 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java @@ -26,11 +26,11 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.FileCopyUtils; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link AppCacheManifestTransformer}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java index 84d5c5a12cff..193c92237345 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java @@ -30,11 +30,11 @@ import org.springframework.cache.concurrent.ConcurrentMapCache; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.reactive.resource.GzipSupport.GzippedFiles; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link CachingResourceResolver}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java index d35847754522..1217658507b4 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java @@ -29,13 +29,13 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.StringUtils; import org.springframework.web.reactive.resource.EncodedResourceResolver.EncodedResource; import org.springframework.web.reactive.resource.GzipSupport.GzippedFiles; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link CssLinkResourceTransformer}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java index 24d680e6e9ba..2d9e084eeeb3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java @@ -30,9 +30,9 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.http.HttpHeaders; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.reactive.resource.GzipSupport.GzippedFiles; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java index cafb3afb4a85..419e3c7f00df 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java @@ -27,9 +27,9 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java index 1d8ce77d4457..45dbdcc1b0ec 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java @@ -31,14 +31,14 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.mock.web.test.MockServletContext; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping; +import org.springframework.web.testfixture.server.MockServerWebExchange; +import org.springframework.web.testfixture.servlet.MockServletContext; import org.springframework.web.util.pattern.PathPattern; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link ResourceUrlProvider}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java index f057b690661b..34c46c7e1a37 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java @@ -46,14 +46,14 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.server.PathContainer; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.StringUtils; import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.server.MethodNotAllowedException; import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java index 3d9e97be95d3..4467fa42fd0d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java @@ -29,9 +29,9 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/WebJarsResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/WebJarsResourceResolverTests.java index b78bcc4ec0fe..b3092b989f3c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/WebJarsResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/WebJarsResourceResolverTests.java @@ -25,9 +25,9 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java index 28c3522088fb..19c822c46e34 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java @@ -24,12 +24,12 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.reactive.accept.FixedContentTypeResolver; import org.springframework.web.reactive.accept.HeaderContentTypeResolver; import org.springframework.web.reactive.accept.RequestedContentTypeResolver; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.http.MediaType.ALL; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java index f5d489f2e146..7d869abdb5ff 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java @@ -33,9 +33,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.DispatcherHandler; @@ -43,6 +41,8 @@ import org.springframework.web.server.WebHandler; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; import org.springframework.web.server.handler.ResponseStatusExceptionHandler; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java index 1a04dfbb880d..efe1ab4ce9a2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java @@ -19,9 +19,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java index 12bb56842d57..15509df1c49b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java @@ -22,9 +22,9 @@ import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.reactive.result.condition.ConsumesRequestCondition.ConsumeMediaTypeExpression; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java index ebe9da151996..5b0dd59c8129 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java @@ -20,11 +20,11 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link HeadersRequestCondition}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ParamsRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ParamsRequestConditionTests.java index dd8d11cfb5aa..7cf95f593839 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ParamsRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ParamsRequestConditionTests.java @@ -20,11 +20,11 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link ParamsRequestCondition}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java index 3cd5074426ac..4439843cdd90 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java @@ -22,13 +22,13 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.server.MockServerWebExchange; import org.springframework.web.util.pattern.PathPattern; import org.springframework.web.util.pattern.PathPatternParser; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link PatternsRequestCondition}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java index e7c40731182f..3b9e7e97534e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java @@ -22,14 +22,14 @@ import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.reactive.accept.RequestedContentTypeResolver; import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link ProducesRequestCondition}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java index 7fd98a583352..5c5d7eb5636b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java @@ -18,9 +18,9 @@ import org.junit.jupiter.api.Test; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java index 60e7dcf1e711..b9ded4a53609 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java @@ -26,11 +26,11 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.reactive.result.method.RequestMappingInfo; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import org.springframework.web.util.pattern.PathPattern; import org.springframework.web.util.pattern.PathPatternParser; import org.springframework.web.util.pattern.PatternParseException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java index d7b9f50ab055..fbff5bc5d258 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java @@ -24,10 +24,10 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.web.bind.annotation.RequestMethod.DELETE; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java index c1ff34974a50..8e9aa3e41fb2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java @@ -25,12 +25,12 @@ import reactor.test.StepVerifier; import org.springframework.http.server.PathContainer; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.method.HandlerMethod; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import org.springframework.web.util.pattern.PathPattern; import org.springframework.web.util.pattern.PathPatternParser; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java index c870e2b26f27..ca4a4c7d88a5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java @@ -33,14 +33,14 @@ import org.springframework.http.HttpStatus; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.lang.Nullable; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.reactive.HandlerResult; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.UnsupportedMediaTypeStatusException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -48,7 +48,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link InvocableHandlerMethod}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java index d9d1b505479a..dc505f80f3b9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java @@ -37,8 +37,6 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.stereotype.Controller; import org.springframework.util.ClassUtils; import org.springframework.util.MultiValueMap; @@ -56,22 +54,24 @@ import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebInputException; import org.springframework.web.server.UnsupportedMediaTypeStatusException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import org.springframework.web.util.pattern.PathPattern; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.method; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.post; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.put; import static org.springframework.web.bind.annotation.RequestMethod.GET; import static org.springframework.web.bind.annotation.RequestMethod.HEAD; import static org.springframework.web.bind.annotation.RequestMethod.OPTIONS; -import static org.springframework.web.method.MvcAnnotationPredicates.getMapping; -import static org.springframework.web.method.MvcAnnotationPredicates.requestMapping; -import static org.springframework.web.method.ResolvableMethod.on; import static org.springframework.web.reactive.HandlerMapping.BEST_MATCHING_HANDLER_ATTRIBUTE; import static org.springframework.web.reactive.HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE; import static org.springframework.web.reactive.result.method.RequestMappingInfo.paths; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.method; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.post; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.put; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.getMapping; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.requestMapping; +import static org.springframework.web.testfixture.method.ResolvableMethod.on; /** * Unit tests for {@link RequestMappingInfoHandlerMapping}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/AbstractRequestMappingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/AbstractRequestMappingIntegrationTests.java index 6ed719dff323..68040bb4ccbc 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/AbstractRequestMappingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/AbstractRequestMappingIntegrationTests.java @@ -27,10 +27,10 @@ import org.springframework.http.MediaType; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; import org.springframework.web.client.RestTemplate; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; import static org.springframework.http.RequestEntity.get; import static org.springframework.http.RequestEntity.options; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java index 73a12ff1474f..4434cf6d2894 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java @@ -23,13 +23,13 @@ import org.springframework.context.annotation.Configuration; import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer; -import org.springframework.http.server.reactive.bootstrap.TomcatHttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.config.EnableWebFlux; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.ReactorHttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.TomcatHttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java index cd0424fbd75e..ec0e73ee02cb 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java @@ -28,8 +28,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.util.ClassUtils; @@ -44,6 +42,8 @@ import org.springframework.web.method.HandlerMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.reactive.HandlerResult; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerInputIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerInputIntegrationTests.java index af93bb19461d..013218698c69 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerInputIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerInputIntegrationTests.java @@ -23,12 +23,12 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.MatrixVariable; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.config.EnableWebFlux; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java index 22db275a41a6..0ae2ff24281a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java @@ -38,7 +38,6 @@ import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.method.HandlerMethod; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver; import org.springframework.web.reactive.result.method.InvocableHandlerMethod; @@ -46,6 +45,7 @@ import org.springframework.web.reactive.result.method.SyncInvocableHandlerMethod; import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.method.ResolvableMethod; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java index a6829344bc94..a0c4f5cdc354 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java @@ -28,12 +28,12 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.annotation.SynthesizingMethodParameter; import org.springframework.http.HttpCookie; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebInputException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java index 07a027b6926b..f89c653109f9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java @@ -29,7 +29,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -38,6 +37,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.config.EnableWebFlux; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolverTests.java index f576115dde45..5be02293760e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolverTests.java @@ -25,14 +25,14 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.ResolvableType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.validation.BindingResult; import org.springframework.validation.DataBinder; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java index 43d5ac18f18e..59c41fd68907 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java @@ -26,10 +26,10 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.ReflectionUtils; import org.springframework.web.reactive.BindingContext; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java index 49dd73e5a062..96d119d75e75 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java @@ -26,13 +26,13 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.config.CorsRegistry; import org.springframework.web.reactive.config.WebFluxConfigurationSupport; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java index d163b54ccfdc..f907bcb27f9c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java @@ -40,18 +40,18 @@ import org.springframework.http.RequestEntity; import org.springframework.http.codec.DecoderHttpMessageReader; import org.springframework.http.codec.HttpMessageReader; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.ObjectUtils; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebInputException; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.springframework.core.ResolvableType.forClassWithGenerics; import static org.springframework.http.MediaType.TEXT_PLAIN; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.post; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.post; /** * Unit tests for {@link HttpEntityMethodArgumentResolver}.When adding a test also diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java index 8d1bbd33d9fc..56ba84873cca 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java @@ -27,8 +27,6 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.convert.ConversionService; import org.springframework.format.support.DefaultFormattingConversionService; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.RequestParam; @@ -36,6 +34,8 @@ import org.springframework.web.reactive.BindingContext; import org.springframework.web.reactive.result.method.SyncHandlerMethodArgumentResolver; import org.springframework.web.reactive.result.method.SyncInvocableHandlerMethod; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonHintsIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonHintsIntegrationTests.java index f6fb973ff676..60387e47bf0a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonHintsIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonHintsIntegrationTests.java @@ -30,12 +30,12 @@ import org.springframework.http.HttpEntity; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.config.EnableWebFlux; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonStreamingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonStreamingIntegrationTests.java index b6efc7ebec98..99b34ae33e5a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonStreamingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonStreamingIntegrationTests.java @@ -25,15 +25,15 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; -import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.DispatcherHandler; import org.springframework.web.reactive.config.EnableWebFlux; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON; import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON_VALUE; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java index 681dafa7370a..1b41388d1307 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java @@ -26,17 +26,17 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.MatrixVariable; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.reactive.HandlerMapping; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.web.method.MvcAnnotationPredicates.matrixAttribute; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.matrixAttribute; /** * Unit tests for {@link MatrixVariableMapMethodArgumentResolver}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java index c51b62014924..ac1e9aaade4b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java @@ -26,20 +26,20 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.MatrixVariable; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.server.ServerErrorException; import org.springframework.web.server.ServerWebInputException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.web.method.MvcAnnotationPredicates.matrixAttribute; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.matrixAttribute; /** * Unit tests for {@link MatrixVariableMethodArgumentResolver}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java index 18bccc04dda4..df9d4cb27e51 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java @@ -47,22 +47,22 @@ import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.codec.json.Jackson2JsonDecoder; import org.springframework.lang.Nullable; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.validation.Errors; import org.springframework.validation.Validator; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; import org.springframework.web.method.HandlerMethod; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebInputException; import org.springframework.web.server.UnsupportedMediaTypeStatusException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.ResolvableType.forClassWithGenerics; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.post; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.post; /** * Unit tests for {@link AbstractMessageReaderArgumentResolver}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java index 4273bd98b28e..6acf14437d42 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java @@ -47,17 +47,17 @@ import org.springframework.http.codec.ResourceHttpMessageWriter; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.codec.xml.Jaxb2XmlEncoder; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.ObjectUtils; import org.springframework.web.reactive.accept.RequestedContentTypeResolver; import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.testfixture.io.buffer.DataBufferTestUtils.dumpString; import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.web.method.ResolvableMethod.on; import static org.springframework.web.reactive.HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE; +import static org.springframework.web.testfixture.method.ResolvableMethod.on; /** * Unit tests for {@link AbstractMessageWriterResultHandler}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java index 3b0beaef44d5..22160e1f27e1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java @@ -31,17 +31,17 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; import org.springframework.web.bind.support.WebExchangeBindException; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java index 0a388a1ca568..90e07285be01 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java @@ -33,8 +33,6 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.lang.Nullable; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.ui.Model; import org.springframework.util.ReflectionUtils; import org.springframework.validation.Validator; @@ -48,10 +46,12 @@ import org.springframework.web.bind.support.WebBindingInitializer; import org.springframework.web.bind.support.WebExchangeDataBinder; import org.springframework.web.method.HandlerMethod; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.result.method.SyncInvocableHandlerMethod; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebSession; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java index 3611213f0c02..1542eb1fe611 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java @@ -23,16 +23,16 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; /** * Unit tests for {@link ModelMethodArgumentResolver}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java index a40d47679015..11fa71efbb8f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java @@ -41,9 +41,8 @@ import org.springframework.http.codec.multipart.FormFieldPart; import org.springframework.http.codec.multipart.MultipartHttpMessageReader; import org.springframework.http.codec.multipart.Part; -import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.http.server.reactive.bootstrap.HttpServer; +import org.springframework.util.FileCopyUtils; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; @@ -55,6 +54,8 @@ import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; @@ -204,7 +205,8 @@ private MultiValueMap> generateBody() { private static void verifyContents(Path tempFile, Resource resource) { try { byte[] tempBytes = Files.readAllBytes(tempFile); - byte[] resourceBytes = Files.readAllBytes(resource.getFile().toPath()); + // Use FileCopyUtils since the resource might reside in a JAR instead of in the file system. + byte[] resourceBytes = FileCopyUtils.copyToByteArray(resource.getInputStream()); assertThat(tempBytes).isEqualTo(resourceBytes); } catch (IOException ex) { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java index 051e10bcb03b..74c75eb0ed62 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java @@ -27,12 +27,12 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.reactive.BindingContext; import org.springframework.web.reactive.HandlerMapping; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java index 2be22e77e1b4..6636ca27f644 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java @@ -30,14 +30,14 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.annotation.SynthesizingMethodParameter; import org.springframework.format.support.DefaultFormattingConversionService; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; import org.springframework.web.reactive.BindingContext; import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.server.ServerErrorException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java index 32078174ff84..a923b89e0144 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java @@ -24,11 +24,11 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java index 2b58d9ff0e41..e64264e83715 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java @@ -26,13 +26,13 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.config.EnableWebFlux; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.protobuf.Msg; import org.springframework.web.reactive.protobuf.SecondMsg; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java index c4ba3f373e1f..f66db9ab11d7 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java @@ -29,16 +29,16 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.format.support.DefaultFormattingConversionService; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebInputException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.web.method.MvcAnnotationPredicates.requestAttribute; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.requestAttribute; /** * Unit tests for {@link RequestAttributeMethodArgumentResolver}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java index 3442f208db69..28d4755a29d4 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java @@ -37,17 +37,17 @@ import org.springframework.core.codec.StringDecoder; import org.springframework.http.codec.DecoderHttpMessageReader; import org.springframework.http.codec.HttpMessageReader; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebInputException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.web.method.MvcAnnotationPredicates.requestBody; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.requestBody; /** * Unit tests for {@link RequestBodyMethodArgumentResolver}. When adding a test also diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java index a333fad48762..a0c6eea3b2eb 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java @@ -28,12 +28,12 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.annotation.SynthesizingMethodParameter; import org.springframework.http.HttpHeaders; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java index 57350e0e8295..bcbc65d5acf4 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java @@ -32,14 +32,14 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.annotation.SynthesizingMethodParameter; import org.springframework.format.support.DefaultFormattingConversionService; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebInputException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java index 250441f5eb3e..8cce6adcec7d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java @@ -29,7 +29,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.validation.Errors; @@ -41,6 +40,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.config.EnableWebFlux; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java index 25bff1a87d3e..7acff0afd13b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java @@ -30,12 +30,12 @@ import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.reactive.config.EnableWebFlux; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java index 75819401dde7..f3191dbf00f9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java @@ -29,13 +29,13 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.config.EnableWebFlux; import org.springframework.web.server.adapter.ForwardedHeaderTransformer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java index 3ad78feebf97..266952dbc66c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java @@ -52,14 +52,13 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.codec.json.Jackson2JsonEncoder; -import org.springframework.http.server.reactive.ZeroCopyIntegrationTests; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.config.EnableWebFlux; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; @@ -657,7 +656,7 @@ private static class ResourceController { @GetMapping("/resource") public Resource resource() { - return new ClassPathResource("spring.png", ZeroCopyIntegrationTests.class); + return new ClassPathResource("/org/springframework/web/reactive/spring.png"); } } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java index 7714923dc218..c0e4176a45b0 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java @@ -31,7 +31,6 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.http.client.SimpleClientHttpRequestFactory; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @@ -41,6 +40,7 @@ import org.springframework.web.reactive.config.WebFluxConfigurer; import org.springframework.web.reactive.result.view.freemarker.FreeMarkerConfigurer; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java index dbb2e44071dc..0c3563b27ac5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java @@ -26,16 +26,16 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.springframework.web.method.MvcAnnotationPredicates.requestParam; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.requestParam; /** * Unit tests for {@link RequestParamMapMethodArgumentResolver}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java index 33cd535338c5..d124bf31a84c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java @@ -28,19 +28,19 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.format.support.DefaultFormattingConversionService; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebInputException; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.springframework.core.ResolvableType.forClassWithGenerics; -import static org.springframework.web.method.MvcAnnotationPredicates.requestParam; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.requestParam; /** * Unit tests for {@link RequestParamMethodArgumentResolver}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java index 4beaf7af247e..19ebc737a9f3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java @@ -43,19 +43,19 @@ import org.springframework.http.codec.ServerCodecConfigurer; import org.springframework.http.codec.multipart.MultipartHttpMessageWriter; import org.springframework.http.codec.multipart.Part; -import org.springframework.mock.http.client.reactive.test.MockClientHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebInputException; +import org.springframework.web.testfixture.http.client.reactive.MockClientHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.ResolvableType.forClass; -import static org.springframework.web.method.MvcAnnotationPredicates.requestPart; +import static org.springframework.web.testfixture.method.MvcAnnotationPredicates.requestPart; /** * Unit tests for {@link RequestPartMethodArgumentResolver}. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java index ecc77837de7f..96fd0a3c0763 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java @@ -42,7 +42,7 @@ import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.web.method.ResolvableMethod.on; +import static org.springframework.web.testfixture.method.ResolvableMethod.on; /** * Unit tests for {@link ResponseBodyResultHandler}.When adding a test also diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java index 86b92d67cff7..a000cf08587f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java @@ -52,20 +52,20 @@ import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.codec.xml.Jaxb2XmlEncoder; import org.springframework.http.converter.HttpMessageNotWritableException; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.ObjectUtils; import org.springframework.web.reactive.HandlerResult; import org.springframework.web.reactive.accept.RequestedContentTypeResolver; import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.core.ResolvableType.forClassWithGenerics; import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.http.ResponseEntity.notFound; import static org.springframework.http.ResponseEntity.ok; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; -import static org.springframework.web.method.ResolvableMethod.on; import static org.springframework.web.reactive.HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.method.ResolvableMethod.on; /** * Unit tests for {@link ResponseEntityResultHandler}. When adding a test also diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java index 83dc3d2ffbaf..7f0539fbbca2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java @@ -28,12 +28,12 @@ import org.springframework.http.HttpMethod; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebSession; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import org.springframework.web.util.UriBuilder; import org.springframework.web.util.UriComponentsBuilder; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java index 26215d438328..09bb53bfce47 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java @@ -30,8 +30,6 @@ import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.annotation.SynthesizingMethodParameter; import org.springframework.format.support.DefaultFormattingConversionService; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.annotation.SessionAttribute; import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; @@ -39,6 +37,8 @@ import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebInputException; import org.springframework.web.server.WebSession; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java index d0fd055ce50b..9afbe8b96205 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java @@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.testfixture.beans.TestBean; -import org.springframework.mock.web.test.server.MockWebSession; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.server.WebSession; +import org.springframework.web.testfixture.server.MockWebSession; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java index 9d545d6ab1a3..b83e8f3b46cd 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java @@ -37,13 +37,7 @@ import org.springframework.http.client.reactive.JettyClientHttpConnector; import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.http.codec.ServerSentEvent; -import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.http.server.reactive.bootstrap.HttpServer; -import org.springframework.http.server.reactive.bootstrap.JettyHttpServer; -import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer; -import org.springframework.http.server.reactive.bootstrap.TomcatHttpServer; -import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -51,6 +45,12 @@ import org.springframework.web.reactive.config.EnableWebFlux; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.JettyHttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.ReactorHttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.TomcatHttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.UndertowHttpServer; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assumptions.assumeTrue; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java index 605438926666..96796f939473 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java @@ -21,12 +21,12 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; -import org.springframework.web.method.ResolvableMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebSession; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.method.ResolvableMethod; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java index 6e3717fb7efa..0d494966867d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java @@ -31,11 +31,11 @@ import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.http.MediaType; import org.springframework.lang.Nullable; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.validation.BindingResult; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java index e44647d08975..b75a214c300b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java @@ -33,10 +33,10 @@ import org.springframework.http.MediaType; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.codec.xml.Jaxb2XmlEncoder; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.ui.ExtendedModelMap; import org.springframework.ui.ModelMap; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/LocaleContextResolverIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/LocaleContextResolverIntegrationTests.java index f2d072098227..b21b68cd5b7e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/LocaleContextResolverIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/LocaleContextResolverIntegrationTests.java @@ -30,7 +30,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.lang.Nullable; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @@ -42,6 +41,7 @@ import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.i18n.FixedLocaleContextResolver; import org.springframework.web.server.i18n.LocaleContextResolver; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java index 35e57892ca84..db20e2e00a8e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java @@ -26,9 +26,9 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.reactive.HandlerMapping; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java index 3ed184f6bc93..0146f192e893 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java @@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java index 72e1f392ec85..669bf2ef5994 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java @@ -43,8 +43,6 @@ import org.springframework.http.MediaType; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.lang.Nullable; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.ui.ConcurrentModel; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; @@ -54,13 +52,15 @@ import org.springframework.web.reactive.accept.RequestedContentTypeResolver; import org.springframework.web.server.NotAcceptableStatusException; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get; -import static org.springframework.web.method.ResolvableMethod.on; +import static org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get; +import static org.springframework.web.testfixture.method.ResolvableMethod.on; /** * ViewResolutionResultHandler relying on a canned {@link TestViewResolver} diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java index e660183ff55d..ad50b9658cb0 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java @@ -34,8 +34,6 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.ui.ExtendedModelMap; import org.springframework.ui.ModelMap; import org.springframework.util.FileCopyUtils; @@ -44,6 +42,8 @@ import org.springframework.web.reactive.result.view.DummyMacroRequestContext; import org.springframework.web.reactive.result.view.RequestContext; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static java.util.Collections.singletonMap; import static java.util.stream.Collectors.toList; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java index 6feddbd56958..54d8f805232e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java @@ -30,8 +30,6 @@ import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.http.codec.ServerCodecConfigurer; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.ui.ExtendedModelMap; import org.springframework.ui.ModelMap; import org.springframework.web.reactive.result.view.ZeroDemandResponse; @@ -39,6 +37,8 @@ import org.springframework.web.server.adapter.DefaultServerWebExchange; import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver; import org.springframework.web.server.session.DefaultWebSessionManager; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java index 6fa014884f8b..0687038d1442 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java @@ -26,9 +26,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java index 6a29ef0643a1..579c4e9dd004 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java @@ -25,9 +25,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java index 3ceab25891fa..9ae7aa12554f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java @@ -27,9 +27,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.support.ResourceBundleMessageSource; import org.springframework.http.MediaType; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java index b57138fea0c0..126e1c2f94c1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java @@ -26,14 +26,14 @@ import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; import org.springframework.http.codec.ServerCodecConfigurer; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; -import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.reactive.result.view.ZeroDemandResponse; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.adapter.DefaultServerWebExchange; import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver; import org.springframework.web.server.session.DefaultWebSessionManager; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse; +import org.springframework.web.testfixture.server.MockServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java index ffc85cf04b32..02f8a6593de1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java @@ -44,11 +44,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.http.server.reactive.bootstrap.HttpServer; -import org.springframework.http.server.reactive.bootstrap.JettyHttpServer; -import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer; -import org.springframework.http.server.reactive.bootstrap.TomcatHttpServer; -import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer; import org.springframework.web.reactive.DispatcherHandler; import org.springframework.web.reactive.socket.client.JettyWebSocketClient; import org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient; @@ -64,6 +59,11 @@ import org.springframework.web.reactive.socket.server.upgrade.TomcatRequestUpgradeStrategy; import org.springframework.web.reactive.socket.server.upgrade.UndertowRequestUpgradeStrategy; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.JettyHttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.ReactorHttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.TomcatHttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.UndertowHttpServer; /** * Base class for WebSocket integration tests. Sub-classes must implement diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java index a8cabe0bf39f..0e970b49658c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java @@ -33,10 +33,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; -import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping; import org.springframework.web.reactive.socket.client.WebSocketClient; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceTests.java index 28b143dc8f82..b4633dec117a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceTests.java @@ -24,13 +24,13 @@ import reactor.core.publisher.Mono; import org.springframework.lang.Nullable; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.web.test.server.MockServerWebExchange; -import org.springframework.mock.web.test.server.MockWebSession; import org.springframework.web.reactive.socket.HandshakeInfo; import org.springframework.web.reactive.socket.WebSocketHandler; import org.springframework.web.reactive.socket.server.RequestUpgradeStrategy; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; +import org.springframework.web.testfixture.server.MockServerWebExchange; +import org.springframework.web.testfixture.server.MockWebSession; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/KotlinInvocableHandlerMethodTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/KotlinInvocableHandlerMethodTests.kt index 4ab2dc39326a..8589ddc570fa 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/KotlinInvocableHandlerMethodTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/KotlinInvocableHandlerMethodTests.kt @@ -23,8 +23,8 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.http.HttpStatus import org.springframework.http.server.reactive.ServerHttpResponse -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get -import org.springframework.mock.web.test.server.MockServerWebExchange +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get +import org.springframework.web.testfixture.server.MockServerWebExchange import org.springframework.web.bind.annotation.ResponseStatus import org.springframework.web.reactive.BindingContext import org.springframework.web.reactive.HandlerResult diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt index 369aa06fd89b..af2502c09f87 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt @@ -29,7 +29,7 @@ import org.springframework.context.annotation.ComponentScan import org.springframework.context.annotation.Configuration import org.springframework.http.HttpHeaders import org.springframework.http.HttpStatus -import org.springframework.http.server.reactive.bootstrap.HttpServer +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RestController import org.springframework.web.client.HttpServerErrorException diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt index 086372c63751..73c4def5349a 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt @@ -22,8 +22,8 @@ import org.springframework.core.MethodParameter import org.springframework.core.ReactiveAdapterRegistry import org.springframework.core.annotation.SynthesizingMethodParameter import org.springframework.format.support.DefaultFormattingConversionService -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest -import org.springframework.mock.web.test.server.MockServerWebExchange +import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest +import org.springframework.web.testfixture.server.MockServerWebExchange import org.springframework.util.ReflectionUtils import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.support.ConfigurableWebBindingInitializer diff --git a/spring-webflux/src/test/resources/org/springframework/web/reactive/spring.png b/spring-webflux/src/test/resources/org/springframework/web/reactive/spring.png new file mode 100644 index 0000000000000000000000000000000000000000..2fec781a5e31ff09dd56ed4e01c1ee1927c67b2b GIT binary patch literal 951 zcmV;o14#UdP)R$ekqBST9o%}ZHk zR|8$mS|QMuiXyr^6htK5e2BCQVxInInzd=2ot<&DorU?}_i|=t=XZ|Z`OcZ6kB=UD z=%I%mDx%|IP@y-=Zvq4ac%ytI=odP$&fDap!FNHPQtB<@<3I)&6v58hJXJk2N4I=A{zxnc%9YW!vscwtsRZ zZvd}6E#J~*AoX{QQr8CLXbs$*_ z@@=*t5?^HEQ%G?Kgk}7*r{%3+a~VgnF0gX<^-FbNqZUSg_c@kC=bK5pP4>QSsSaHC zw0wFEOG5Vrlj>HZt9xxy9r)-eaaw6o&Tu3oGnnj`PaQjTj`Dt$whjMHoQm$M{F5@21e8omm*VI9z$B?T z&^P8K61iS{jTsts%GzV9ah7A@i3IiT(pniHy_Du;wFL@?n+qhHN-t;zh;c6uL;&v>8YG`;o4;(TiQ3 z2+(|`l2sNXIevp7hc2=twTk0QVMMlhn6P-%_tvtmR#-XCEByjn1i80#Czx`U<3}>4 zz|6}@ji@U^gH-%w)?+ZZP{I`vbehUexa% z1xJ8t`2dRO*{GsihuB=uE0TX=zqYNMYl=H+`hq-eKGMh}3Hzl9PA2{gz<@9i54M9G zP$8UbScP Date: Tue, 31 Dec 2019 15:40:16 +0100 Subject: [PATCH 0252/2315] Delete obsolete TestSourcesPlugin Since we have migrated to Gradle's built-in test fixture support, the custom TestSourcesPlugin Gradle plugin is now obsolete. See gh-23550 --- buildSrc/README.md | 16 +-- buildSrc/build.gradle | 4 - .../build/testsources/TestSourcesPlugin.java | 130 ------------------ gradle/spring-module.gradle | 1 - integration-tests/integration-tests.gradle | 2 - 5 files changed, 5 insertions(+), 148 deletions(-) delete mode 100644 buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java diff --git a/buildSrc/README.md b/buildSrc/README.md index 7c722a362730..30486631ccd0 100644 --- a/buildSrc/README.md +++ b/buildSrc/README.md @@ -1,4 +1,4 @@ -# Spring Framework build +# Spring Framework Build This folder contains the custom plugins and conventions for the Spring Framework build. They are declared in the `build.gradle` file in this folder. @@ -7,8 +7,8 @@ They are declared in the `build.gradle` file in this folder. ### Compiler conventions -The `org.springframework.build.compile` applies the Java compiler conventions to the build. -By default, the build is compiling sources with the `1.8` source and target compatibility. +The `org.springframework.build.compile` plubin applies the Java compiler conventions to the build. +By default, the build compiles sources with Java `1.8` source and target compatibility. You can test a different source compatibility version on the CLI with a project property like: ``` @@ -25,17 +25,11 @@ but doesn't affect the classpath of dependent projects. This plugin does not provide a `provided` configuration, as the native `compileOnly` and `testCompileOnly` configurations are preferred. -## Test sources - -The `org.springframework.build.test-sources` updates `testCompile` dependencies to include -the test source sets of `project()` dependencies. This plugin is used in the Spring Framework build -to share test utilities and fixtures amongst modules. - ## API Diff This plugin uses the [Gradle JApiCmp](https://github.com/melix/japicmp-gradle-plugin) plugin to generate API Diff reports for each Spring Framework module. This plugin is applied once on the root -project and create tasks in each framework module. Unlike previous versions of this part of the build, +project and creates tasks in each framework module. Unlike previous versions of this part of the build, there is no need for checking out a specific tag. The plugin will fetch the JARs we want to compare the current working version with. You can generate the reports for all modules or a single module: @@ -44,4 +38,4 @@ current working version with. You can generate the reports for all modules or a ./gradlew :spring-core:apiDiff -PbaselineVersion=5.1.0.RELEASE ``` -The reports are located under `build/reports/api-diff/$OLDVERSION_to_$NEWVERSION/`. \ No newline at end of file +The reports are located under `build/reports/api-diff/$OLDVERSION_to_$NEWVERSION/`. diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 1aed5f6e78a2..1dfc3d995ab4 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -26,9 +26,5 @@ gradlePlugin { id = "org.springframework.build.optional-dependencies" implementationClass = "org.springframework.build.optional.OptionalDependenciesPlugin" } - testSourcesPlugin { - id = "org.springframework.build.test-sources" - implementationClass = "org.springframework.build.testsources.TestSourcesPlugin" - } } } diff --git a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java b/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java deleted file mode 100644 index b05e08214c3d..000000000000 --- a/buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2002-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.build.testsources; - -import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.ProjectDependency; -import org.gradle.api.plugins.JavaPlugin; -import org.gradle.api.plugins.JavaPluginConvention; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetOutput; - -import org.springframework.build.optional.OptionalDependenciesPlugin; - -/** - * {@link Plugin} that automatically updates testCompile dependencies to include - * the test source sets of {@code project()} dependencies. - * - *

    This plugin is used in the Spring Framework build to share test utilities and fixtures - * between projects. - * - * @author Phillip Webb - * @author Brian Clozel - */ -public class TestSourcesPlugin implements Plugin { - - /** - * List of configurations this plugin should look for project dependencies in. - */ - @SuppressWarnings("deprecation") - private static final List CONFIGURATIONS = Arrays.asList( - JavaPlugin.COMPILE_CONFIGURATION_NAME, - JavaPlugin.API_CONFIGURATION_NAME, - JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, - OptionalDependenciesPlugin.OPTIONAL_CONFIGURATION_NAME, - JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME); - - /** - * Projects which will not be automatically added as a test dependency. - *

    This is used to assist with the migration to Gradle test fixtures. - */ - private static final List excludedProjects = Arrays.asList( - "integration-tests", - "kotlin-coroutines", - "spring-aop", - "spring-aspects", - "spring-beans", - "spring-context", - "spring-context-indexer", - "spring-context-support", - "spring-core", - "spring-expression", - "spring-instrument", - "spring-jcl", - "spring-jdbc", - "spring-jms", - "spring-messaging", - "spring-orm", - "spring-oxm", - // "spring-test", - "spring-tx", - "spring-web", - "spring-webflux", - // "spring-webmvc", - "spring-websocket" - ); - - - @Override - public void apply(Project project) { - project.getPlugins().withType(JavaPlugin.class, plugin -> addTestSourcesToProject(project)); - } - - private void addTestSourcesToProject(Project project) { - project.afterEvaluate(currentProject -> { - Set projectDependencies = new LinkedHashSet<>(); - collectProjectDependencies(projectDependencies, project); - projectDependencies.forEach(dep -> addTestSourcesFromDependency(currentProject, dep)); - }); - } - - private void collectProjectDependencies(Set projectDependencies, Project project) { - for (String configurationName : CONFIGURATIONS) { - Configuration configuration = project.getConfigurations().findByName(configurationName); - if (configuration != null) { - configuration.getDependencies().forEach(dependency -> { - if (dependency instanceof ProjectDependency) { - ProjectDependency projectDependency = (ProjectDependency) dependency; - projectDependencies.add(projectDependency); - collectProjectDependencies(projectDependencies, projectDependency.getDependencyProject()); - } - }); - } - } - } - - @SuppressWarnings("deprecation") - private void addTestSourcesFromDependency(Project currentProject, ProjectDependency dependency) { - Project dependencyProject = dependency.getDependencyProject(); - if (!excludedProjects.contains(dependencyProject.getName())) { - dependencyProject.getPlugins().withType(JavaPlugin.class, plugin -> { - JavaPluginConvention javaPlugin = dependencyProject.getConvention().getPlugin(JavaPluginConvention.class); - SourceSetOutput test = javaPlugin.getSourceSets().findByName(SourceSet.TEST_SOURCE_SET_NAME).getOutput(); - System.err.println(String.format("Adding test source dependencies from %s to %s", currentProject.getName(), dependencyProject.getName())); - currentProject.getDependencies().add(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME, test); - }); - } - } - -} diff --git a/gradle/spring-module.gradle b/gradle/spring-module.gradle index c70263e18c0a..ad6ed3168f13 100644 --- a/gradle/spring-module.gradle +++ b/gradle/spring-module.gradle @@ -1,6 +1,5 @@ apply plugin: 'org.springframework.build.compile' apply plugin: 'org.springframework.build.optional-dependencies' -apply plugin: 'org.springframework.build.test-sources' apply from: "$rootDir/gradle/publications.gradle" jar { diff --git a/integration-tests/integration-tests.gradle b/integration-tests/integration-tests.gradle index 5e18462c1e84..71e23b906049 100644 --- a/integration-tests/integration-tests.gradle +++ b/integration-tests/integration-tests.gradle @@ -1,7 +1,5 @@ description = "Spring Integration Tests" -apply plugin: "org.springframework.build.test-sources" - dependencies { testCompile(project(":spring-aop")) testCompile(project(":spring-beans")) From d5f0bb23aed29578cb45653f14d291d1bfe291e7 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 2 Jan 2020 15:21:40 +0100 Subject: [PATCH 0253/2315] Disable publication of test fixture artifacts Thanks to @melix for providing the code snippet necessary to achieve this with Gradle 5.6.x. See gh-23550 --- gradle/spring-module.gradle | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gradle/spring-module.gradle b/gradle/spring-module.gradle index ad6ed3168f13..5c513b976e34 100644 --- a/gradle/spring-module.gradle +++ b/gradle/spring-module.gradle @@ -55,6 +55,14 @@ task javadocJar(type: Jar) { publishing { publications { mavenJava(MavenPublication) { + // Disable publication of test fixture artifacts. + // + // Once we upgrade to Gradle 6.x, we will need to delete the following line ... + components.java.variants.removeAll { it.outgoingConfiguration.name.startsWith("testFixtures") } + // ... and uncomment the following two lines. + // components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() } + // components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() } + from components.java artifact sourcesJar artifact javadocJar From 68f9f8116cb49f7dc096edf72aa0b334b787bef7 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 2 Jan 2020 12:11:41 +0000 Subject: [PATCH 0254/2315] Fix typo in RSocket reference See gh-24245 --- src/docs/asciidoc/rsocket.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docs/asciidoc/rsocket.adoc b/src/docs/asciidoc/rsocket.adoc index 8c373c14764d..27df66009706 100644 --- a/src/docs/asciidoc/rsocket.adoc +++ b/src/docs/asciidoc/rsocket.adoc @@ -287,8 +287,8 @@ can be registered as follows: .Java ---- RSocketStrategies strategies = RSocketStrategies.builder() - .encoders(encoders -> encoders.add(new Jackson2CborEncoder)) - .decoders(decoders -> decoders.add(new Jackson2CborDecoder)) + .encoders(encoders -> encoders.add(new Jackson2CborEncoder())) + .decoders(decoders -> decoders.add(new Jackson2CborDecoder())) .build(); Mono requesterMono = RSocketRequester.builder() From 03ea92df9916baa5f8df37ec4154cb07fd2cea4d Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 3 Jan 2020 11:12:01 +0000 Subject: [PATCH 0255/2315] Improve RestClientException Javadoc Closes gh-24288 --- .../springframework/web/client/RestClientException.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/client/RestClientException.java b/spring-web/src/main/java/org/springframework/web/client/RestClientException.java index 4e25c7cf3908..4125304f3a51 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestClientException.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestClientException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2020 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,10 +17,13 @@ package org.springframework.web.client; import org.springframework.core.NestedRuntimeException; +import org.springframework.http.client.ClientHttpResponse; /** - * Base class for exceptions thrown by {@link RestTemplate} whenever it encounters - * client-side HTTP errors. + * Base class for exceptions thrown by {@link RestTemplate} in case a request + * fails because of a server error response, as determined via + * {@link ResponseErrorHandler#hasError(ClientHttpResponse)}, failure to decode + * the response, or a low level I/O error. * * @author Arjen Poutsma * @since 3.0 From f585eb0b79429d4e2f15031ff237d16f01572b4d Mon Sep 17 00:00:00 2001 From: KangZhiDong Date: Fri, 3 Jan 2020 16:50:12 +0800 Subject: [PATCH 0256/2315] Fix Javadoc typos See gh-24287 --- .../org/springframework/beans/factory/parsing/ParseState.java | 2 +- .../springframework/beans/factory/parsing/ReaderContext.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java index 23a013ce91f1..51e9aeb627dd 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java @@ -53,7 +53,7 @@ public ParseState() { } /** - * Create a new {@code ParseState} whose {@link LinkedList} is a {@link Object#clone clone} + * Create a new {@code ParseState} whose {@link LinkedList} is an {@link Object#clone clone} * of that of the passed in {@code ParseState}. */ @SuppressWarnings("unchecked") diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ReaderContext.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ReaderContext.java index 7c31fe994b7d..f984ed4c4867 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ReaderContext.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ReaderContext.java @@ -152,14 +152,14 @@ public void warning(String message, @Nullable Object source, @Nullable ParseStat // Explicit parse events /** - * Fire an defaults-registered event. + * Fire a defaults-registered event. */ public void fireDefaultsRegistered(DefaultsDefinition defaultsDefinition) { this.eventListener.defaultsRegistered(defaultsDefinition); } /** - * Fire an component-registered event. + * Fire a component-registered event. */ public void fireComponentRegistered(ComponentDefinition componentDefinition) { this.eventListener.componentRegistered(componentDefinition); From 510ef1ab2e769786dfdad11f4ccd1b78d7761097 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 3 Jan 2020 11:17:29 +0000 Subject: [PATCH 0257/2315] Polishing contribution See gh-24287 --- .../org/springframework/beans/factory/parsing/ParseState.java | 4 ++-- .../springframework/beans/factory/parsing/ReaderContext.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java index 51e9aeb627dd..36375ef84fd6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -53,7 +53,7 @@ public ParseState() { } /** - * Create a new {@code ParseState} whose {@link LinkedList} is an {@link Object#clone clone} + * Create a new {@code ParseState} whose {@link LinkedList} is a {@link Object#clone clone} * of that of the passed in {@code ParseState}. */ @SuppressWarnings("unchecked") diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ReaderContext.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ReaderContext.java index f984ed4c4867..2b95aa8f6c3b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ReaderContext.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ReaderContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. From 081b3d304d94bdbdffc663e3a4810f76d6eb1fc4 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 3 Jan 2020 14:34:29 +0100 Subject: [PATCH 0258/2315] Move JavaUtilLoggingConfigurer to spring-core test fixtures See gh-23550 --- spring-core/spring-core.gradle | 5 +++-- .../core/testfixture}/JavaUtilLoggingConfigurer.java | 4 ++-- spring-webflux/spring-webflux.gradle | 1 - .../org.junit.platform.launcher.TestExecutionListener | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename {spring-webflux/src/test/java/org/springframework/web/reactive/fixtures => spring-core/src/testFixtures/java/org/springframework/core/testfixture}/JavaUtilLoggingConfigurer.java (94%) diff --git a/spring-core/spring-core.gradle b/spring-core/spring-core.gradle index a84b8e753706..94327d342e32 100644 --- a/spring-core/spring-core.gradle +++ b/spring-core/spring-core.gradle @@ -60,11 +60,12 @@ dependencies { testCompile("javax.xml.bind:jaxb-api") testCompile("com.fasterxml.woodstox:woodstox-core") testCompile(project(":kotlin-coroutines")) - testFixturesApi("org.junit.jupiter:junit-jupiter-api") - testFixturesApi("org.junit.jupiter:junit-jupiter-params") testFixturesImplementation("com.google.code.findbugs:jsr305") testFixturesImplementation("io.projectreactor:reactor-test") testFixturesImplementation("org.assertj:assertj-core") + testFixturesImplementation("org.junit.platform:junit-platform-launcher") + testFixturesImplementation("org.junit.jupiter:junit-jupiter-api") + testFixturesImplementation("org.junit.jupiter:junit-jupiter-params") testFixturesImplementation("org.xmlunit:xmlunit-assertj") } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/fixtures/JavaUtilLoggingConfigurer.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/JavaUtilLoggingConfigurer.java similarity index 94% rename from spring-webflux/src/test/java/org/springframework/web/reactive/fixtures/JavaUtilLoggingConfigurer.java rename to spring-core/src/testFixtures/java/org/springframework/core/testfixture/JavaUtilLoggingConfigurer.java index 2c555e16ad91..d54483099eff 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/fixtures/JavaUtilLoggingConfigurer.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/JavaUtilLoggingConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.reactive.fixtures; +package org.springframework.core.testfixture; import java.io.InputStream; import java.util.logging.LogManager; diff --git a/spring-webflux/spring-webflux.gradle b/spring-webflux/spring-webflux.gradle index a636d47ad84e..1028d6e59c42 100644 --- a/spring-webflux/spring-webflux.gradle +++ b/spring-webflux/spring-webflux.gradle @@ -46,7 +46,6 @@ dependencies { testCompile("org.eclipse.jetty:jetty-server") testCompile("org.eclipse.jetty:jetty-servlet") testCompile("org.eclipse.jetty:jetty-reactive-httpclient") - testCompile("org.junit.platform:junit-platform-launcher") testCompile("com.squareup.okhttp3:mockwebserver") testCompile("org.jetbrains.kotlin:kotlin-script-runtime") testRuntime("org.jetbrains.kotlin:kotlin-scripting-jsr223-embeddable") diff --git a/spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener b/spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener index fd231f292ca1..973bfea9767e 100644 --- a/spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener +++ b/spring-webflux/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener @@ -1 +1 @@ -org.springframework.web.reactive.fixtures.JavaUtilLoggingConfigurer \ No newline at end of file +org.springframework.core.testfixture.JavaUtilLoggingConfigurer \ No newline at end of file From 22a888b53df620b0905ce8beb6b0cf71981086d8 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 3 Jan 2020 14:56:13 +0100 Subject: [PATCH 0259/2315] Polish test fixture publication skipping config Thanks to @jjohannes for the tip. See gh-23550 --- gradle/spring-module.gradle | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gradle/spring-module.gradle b/gradle/spring-module.gradle index 5c513b976e34..048735af1cbb 100644 --- a/gradle/spring-module.gradle +++ b/gradle/spring-module.gradle @@ -55,17 +55,17 @@ task javadocJar(type: Jar) { publishing { publications { mavenJava(MavenPublication) { - // Disable publication of test fixture artifacts. - // - // Once we upgrade to Gradle 6.x, we will need to delete the following line ... - components.java.variants.removeAll { it.outgoingConfiguration.name.startsWith("testFixtures") } - // ... and uncomment the following two lines. - // components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() } - // components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() } - from components.java artifact sourcesJar artifact javadocJar } } } + +// Disable publication of test fixture artifacts. +// +// Once we upgrade to Gradle 6.x, we will need to delete the following line ... +components.java.variants.removeAll { it.outgoingConfiguration.name.startsWith("testFixtures") } +// ... and uncomment the following two lines. +// components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() } +// components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() } From 328e88d204c0fe8c5631888c1313d77343f3b23c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 6 Jan 2020 10:53:20 +0100 Subject: [PATCH 0260/2315] Document minimum Buildship and Eclipse requirements --- import-into-eclipse.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/import-into-eclipse.md b/import-into-eclipse.md index d303e0c7412b..17e028db58f7 100644 --- a/import-into-eclipse.md +++ b/import-into-eclipse.md @@ -3,12 +3,12 @@ This document will guide you through the process of importing the Spring Framework projects into Eclipse or the Spring Tool Suite (_STS_). It is recommended that you have a recent version of Eclipse. As a bare minimum you will need Eclipse with full Java -8 support, the Kotlin plugin, and the Groovy plugin. +8 support, Eclipse Buildship, the Kotlin plugin, and the Groovy plugin. The following instructions have been tested against [STS](https://spring.io/tools) 4.3.2 ([download](https://github.com/spring-projects/sts4/wiki/Previous-Versions#spring-tools-432-changelog)) -with [Eclipse Buildship](https://projects.eclipse.org/projects/tools.buildship). The -instructions should work with the latest Eclipse distribution as long as you install +(based on Eclipse 4.12) with [Eclipse Buildship](https://projects.eclipse.org/projects/tools.buildship). +The instructions should work with the latest Eclipse distribution as long as you install [Buildship](https://marketplace.eclipse.org/content/buildship-gradle-integration). Note that STS 4 comes with Buildship preinstalled. From d0c2812dad28b2ef4b829d39887d407bce1d6d4d Mon Sep 17 00:00:00 2001 From: Qimiao Chen Date: Mon, 6 Jan 2020 18:28:24 +0800 Subject: [PATCH 0261/2315] Optimize SimpleAliasRegistry hasAlias implementation This commit reduces the number of loops and recursions in the implementation of SimpleAliasRegistry#hasAlias(). Closes gh-24295 --- .../springframework/core/SimpleAliasRegistry.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java b/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java index 0614301de068..9e2cae75a99b 100644 --- a/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java +++ b/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java @@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import org.springframework.util.StringValueResolver; @@ -36,6 +37,7 @@ * implementations. * * @author Juergen Hoeller + * @author Qimiao Chen * @since 2.5.2 */ public class SimpleAliasRegistry implements AliasRegistry { @@ -98,16 +100,9 @@ protected boolean allowAliasOverriding() { * @since 4.2.1 */ public boolean hasAlias(String name, String alias) { - for (Map.Entry entry : this.aliasMap.entrySet()) { - String registeredName = entry.getValue(); - if (registeredName.equals(name)) { - String registeredAlias = entry.getKey(); - if (registeredAlias.equals(alias) || hasAlias(registeredAlias, alias)) { - return true; - } - } - } - return false; + String registeredName = this.aliasMap.get(alias); + return ObjectUtils.nullSafeEquals(registeredName, name) || (registeredName != null + && hasAlias(name, registeredName)); } @Override From 3299793c8a5b764aaf66dcc1d875efe6541ec1a1 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 6 Jan 2020 11:30:05 +0100 Subject: [PATCH 0262/2315] Polish [Simple]AliasRegistry[Tests] --- .../java/org/springframework/core/AliasRegistry.java | 6 +++--- .../org/springframework/core/SimpleAliasRegistry.java | 10 +++++----- .../springframework/core/SimpleAliasRegistryTests.java | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/AliasRegistry.java b/spring-core/src/main/java/org/springframework/core/AliasRegistry.java index 3fb47cb12adf..689b3aeea9be 100644 --- a/spring-core/src/main/java/org/springframework/core/AliasRegistry.java +++ b/spring-core/src/main/java/org/springframework/core/AliasRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2020 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,7 @@ package org.springframework.core; /** - * Common interface for managing aliases. Serves as super-interface for + * Common interface for managing aliases. Serves as a super-interface for * {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}. * * @author Juergen Hoeller @@ -42,7 +42,7 @@ public interface AliasRegistry { void removeAlias(String alias); /** - * Determine whether this given name is defines as an alias + * Determine whether the given name is defined as an alias * (as opposed to the name of an actually registered component). * @param name the name to check * @return whether the given name is an alias diff --git a/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java b/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java index 9e2cae75a99b..1eee8f2c3aa2 100644 --- a/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java +++ b/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -32,7 +32,7 @@ /** * Simple implementation of the {@link AliasRegistry} interface. - * Serves as base class for + *

    Serves as base class for * {@link org.springframework.beans.factory.support.BeanDefinitionRegistry} * implementations. * @@ -86,8 +86,8 @@ public void registerAlias(String name, String alias) { } /** - * Return whether alias overriding is allowed. - * Default is {@code true}. + * Determine whether alias overriding is allowed. + *

    Default is {@code true}. */ protected boolean allowAliasOverriding() { return true; @@ -145,7 +145,7 @@ private void retrieveAliases(String name, List result) { /** * Resolve all alias target names and aliases registered in this - * factory, applying the given StringValueResolver to them. + * registry, applying the given {@link StringValueResolver} to them. *

    The value resolver may for example resolve placeholders * in target bean names and even in alias names. * @param valueResolver the StringValueResolver to apply diff --git a/spring-core/src/test/java/org/springframework/core/SimpleAliasRegistryTests.java b/spring-core/src/test/java/org/springframework/core/SimpleAliasRegistryTests.java index 802b705c98fc..5e679128ccc1 100644 --- a/spring-core/src/test/java/org/springframework/core/SimpleAliasRegistryTests.java +++ b/spring-core/src/test/java/org/springframework/core/SimpleAliasRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -35,13 +35,13 @@ void aliasChaining() { assertThat(registry.hasAlias("test", "testAlias")).isTrue(); assertThat(registry.hasAlias("test", "testAlias2")).isTrue(); assertThat(registry.hasAlias("test", "testAlias3")).isTrue(); - assertThat(registry.canonicalName("testAlias")).isSameAs("test"); - assertThat(registry.canonicalName("testAlias2")).isSameAs("test"); - assertThat(registry.canonicalName("testAlias3")).isSameAs("test"); + assertThat(registry.canonicalName("testAlias")).isEqualTo("test"); + assertThat(registry.canonicalName("testAlias2")).isEqualTo("test"); + assertThat(registry.canonicalName("testAlias3")).isEqualTo("test"); } @Test // SPR-17191 - void testAliasChainingWithMultipleAliases() { + void aliasChainingWithMultipleAliases() { SimpleAliasRegistry registry = new SimpleAliasRegistry(); registry.registerAlias("name", "alias_a"); registry.registerAlias("name", "alias_b"); From c1d0060a6f4f03bc7d761f568e1b60a0f59ed59b Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 6 Jan 2020 14:41:00 +0100 Subject: [PATCH 0263/2315] Recommend third-party alternatives in BeanUtils Javadoc See gh-24268 --- .../main/java/org/springframework/beans/BeanUtils.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java index 1aff95efadb8..92ffa7c934c6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -55,8 +55,11 @@ * Static convenience methods for JavaBeans: for instantiating beans, * checking bean property types, copying bean properties, etc. * - *

    Mainly for use within the framework, but to some degree also - * useful for application classes. + *

    Mainly for internal use within the framework, but to some degree also + * useful for application classes. Consider + * Apache Commons BeanUtils, + * BULL - Bean Utils Light Library, + * or similar third-party frameworks for more comprehensive bean utilities. * * @author Rod Johnson * @author Juergen Hoeller From 59ade9169406e50e04d2923c170724830a11a499 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 6 Jan 2020 14:45:17 +0100 Subject: [PATCH 0264/2315] Use HTTPS in link See gh-24268 --- .../src/main/java/org/springframework/beans/BeanUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java index 92ffa7c934c6..e80864f5949a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java @@ -57,7 +57,7 @@ * *

    Mainly for internal use within the framework, but to some degree also * useful for application classes. Consider - * Apache Commons BeanUtils, + * Apache Commons BeanUtils, * BULL - Bean Utils Light Library, * or similar third-party frameworks for more comprehensive bean utilities. * From f9c1565f4ef031904c3545a70e63080aeade6e90 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 6 Jan 2020 16:39:14 +0100 Subject: [PATCH 0265/2315] Remove Content-* response headers for error handling Prior to this commit, when WebFlux handlers added `"Content-*"` response headers and an error happened while handling the request, all those headers would not be cleared from the response before error handling. This commit clears those headers from the response in two places: * when invoking the handler and adapting the response * when writing the response body Not removing those headers might break HTTP clients since they're given wrong information about how to interpret the HTTP response body: the error response body might be very different from the original one. Fixes gh-24238 --- .../org/springframework/http/HttpHeaders.java | 18 ++++++++- .../reactive/AbstractServerHttpResponse.java | 13 ++++--- .../reactive/ServerHttpResponseTests.java | 39 +++++++++++++------ .../RequestMappingHandlerAdapter.java | 4 +- 4 files changed, 53 insertions(+), 21 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index da4ffac8cfe9..68e693375d34 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -1827,6 +1827,22 @@ public static String encodeBasicAuth(String username, String password, @Nullable return new String(encodedBytes, charset); } + /** + * Remove the well-known {@code "Content-*"} HTTP headers from the given instance. + *

    Such headers should be cleared, if possible, from the response if the intended + * body can't be written due to errors. + * @since 5.2.3 + */ + public static void clearContentHeaders(HttpHeaders headers) { + headers.remove(HttpHeaders.CONTENT_DISPOSITION); + headers.remove(HttpHeaders.CONTENT_ENCODING); + headers.remove(HttpHeaders.CONTENT_LANGUAGE); + headers.remove(HttpHeaders.CONTENT_LENGTH); + headers.remove(HttpHeaders.CONTENT_LOCATION); + headers.remove(HttpHeaders.CONTENT_RANGE); + headers.remove(HttpHeaders.CONTENT_TYPE); + } + // Package-private: used in ResponseCookie static String formatDate(long date) { Instant instant = Instant.ofEpochMilli(date); diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java index d5378f058e25..e53366e27643 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -181,21 +181,22 @@ public final Mono writeWith(Publisher body) { if (body instanceof Mono) { return ((Mono) body).flatMap(buffer -> doCommit(() -> writeWithInternal(Mono.just(buffer))) - .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release)); + .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release)) + .doOnError(t -> clearContentHeaders()); } return new ChannelSendOperator<>(body, inner -> doCommit(() -> writeWithInternal(inner))) - .doOnError(t -> removeContentLength()); + .doOnError(t -> clearContentHeaders()); } @Override public final Mono writeAndFlushWith(Publisher> body) { return new ChannelSendOperator<>(body, inner -> doCommit(() -> writeAndFlushWithInternal(inner))) - .doOnError(t -> removeContentLength()); + .doOnError(t -> clearContentHeaders()); } - private void removeContentLength() { + private void clearContentHeaders() { if (!this.isCommitted()) { - this.getHeaders().remove(HttpHeaders.CONTENT_LENGTH); + HttpHeaders.clearContentHeaders(this.getHeaders()); } } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java index acc7b4bd71d8..c8a8552dd346 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -30,6 +30,7 @@ import org.springframework.core.io.buffer.DefaultDataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; import org.springframework.http.ResponseCookie; import static org.assertj.core.api.Assertions.assertThat; @@ -37,11 +38,12 @@ /** * @author Rossen Stoyanchev * @author Sebastien Deleuze + * @author Brian Clozel */ public class ServerHttpResponseTests { @Test - public void writeWith() throws Exception { + void writeWith() throws Exception { TestServerHttpResponse response = new TestServerHttpResponse(); response.writeWith(Flux.just(wrap("a"), wrap("b"), wrap("c"))).block(); @@ -56,7 +58,7 @@ public void writeWith() throws Exception { } @Test // SPR-14952 - public void writeAndFlushWithFluxOfDefaultDataBuffer() throws Exception { + void writeAndFlushWithFluxOfDefaultDataBuffer() throws Exception { TestServerHttpResponse response = new TestServerHttpResponse(); Flux> flux = Flux.just(Flux.just(wrap("foo"))); response.writeAndFlushWith(flux).block(); @@ -70,21 +72,35 @@ public void writeAndFlushWithFluxOfDefaultDataBuffer() throws Exception { } @Test - public void writeWithError() throws Exception { - TestServerHttpResponse response = new TestServerHttpResponse(); - response.getHeaders().setContentLength(12); + void writeWithFluxError() throws Exception { IllegalStateException error = new IllegalStateException("boo"); - response.writeWith(Flux.error(error)).onErrorResume(ex -> Mono.empty()).block(); + writeWithError(Flux.error(error)); + } + + @Test + void writeWithMonoError() throws Exception { + IllegalStateException error = new IllegalStateException("boo"); + writeWithError(Mono.error(error)); + } + + void writeWithError(Publisher body) throws Exception { + TestServerHttpResponse response = new TestServerHttpResponse(); + HttpHeaders headers = response.getHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.set(HttpHeaders.CONTENT_ENCODING, "gzip"); + headers.setContentLength(12); + response.writeWith(body).onErrorResume(ex -> Mono.empty()).block(); assertThat(response.statusCodeWritten).isFalse(); assertThat(response.headersWritten).isFalse(); assertThat(response.cookiesWritten).isFalse(); - assertThat(response.getHeaders().containsKey(HttpHeaders.CONTENT_LENGTH)).isFalse(); + assertThat(headers).doesNotContainKeys(HttpHeaders.CONTENT_TYPE, HttpHeaders.CONTENT_LENGTH, + HttpHeaders.CONTENT_ENCODING); assertThat(response.body.isEmpty()).isTrue(); } @Test - public void setComplete() throws Exception { + void setComplete() throws Exception { TestServerHttpResponse response = new TestServerHttpResponse(); response.setComplete().block(); @@ -95,7 +111,7 @@ public void setComplete() throws Exception { } @Test - public void beforeCommitWithComplete() throws Exception { + void beforeCommitWithComplete() throws Exception { ResponseCookie cookie = ResponseCookie.from("ID", "123").build(); TestServerHttpResponse response = new TestServerHttpResponse(); response.beforeCommit(() -> Mono.fromRunnable(() -> response.getCookies().add(cookie.getName(), cookie))); @@ -113,7 +129,7 @@ public void beforeCommitWithComplete() throws Exception { } @Test - public void beforeCommitActionWithSetComplete() throws Exception { + void beforeCommitActionWithSetComplete() throws Exception { ResponseCookie cookie = ResponseCookie.from("ID", "123").build(); TestServerHttpResponse response = new TestServerHttpResponse(); response.beforeCommit(() -> { @@ -130,7 +146,6 @@ public void beforeCommitActionWithSetComplete() throws Exception { } - private DefaultDataBuffer wrap(String a) { return new DefaultDataBufferFactory().wrap(ByteBuffer.wrap(a.getBytes(StandardCharsets.UTF_8))); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java index 4608df51ab31..a8f5a1efeac6 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -211,7 +211,7 @@ private Mono handleException(Throwable exception, HandlerMethod h // Success and error responses may use different content types exchange.getAttributes().remove(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE); if (!exchange.getResponse().isCommitted()) { - exchange.getResponse().getHeaders().remove(HttpHeaders.CONTENT_TYPE); + HttpHeaders.clearContentHeaders(exchange.getResponse().getHeaders()); } InvocableHandlerMethod invocable = this.methodResolver.getExceptionHandlerMethod(exception, handlerMethod); From ea6d2ea1ce6d42c67d8ca5e34d24bbca625c9ced Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 6 Jan 2020 22:05:29 +0000 Subject: [PATCH 0266/2315] Multi-value headers in ResponseStatusException Closes gh-24261 --- .../web/server/MethodNotAllowedException.java | 23 ++++++++++++---- .../server/NotAcceptableStatusException.java | 22 +++++++++++++--- .../web/server/ResponseStatusException.java | 26 ++++++++++++++++--- .../ResponseStatusExceptionHandler.java | 7 ++--- 4 files changed, 63 insertions(+), 15 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/server/MethodNotAllowedException.java b/spring-web/src/main/java/org/springframework/web/server/MethodNotAllowedException.java index 14dcd2a62b8f..40cf7d46607a 100644 --- a/spring-web/src/main/java/org/springframework/web/server/MethodNotAllowedException.java +++ b/spring-web/src/main/java/org/springframework/web/server/MethodNotAllowedException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -22,12 +22,12 @@ import java.util.Map; import java.util.Set; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; /** * Exception for errors that fit response status 405 (method not allowed). @@ -62,11 +62,24 @@ public MethodNotAllowedException(String method, @Nullable Collection * Return a Map with an "Allow" header. * @since 5.1.11 */ + @SuppressWarnings("deprecation") @Override public Map getHeaders() { - return !CollectionUtils.isEmpty(this.httpMethods) ? - Collections.singletonMap("Allow", StringUtils.collectionToDelimitedString(this.httpMethods, ", ")) : - Collections.emptyMap(); + return getResponseHeaders().toSingleValueMap(); + } + + /** + * Return HttpHeaders with an "Allow" header. + * @since 5.1.13 + */ + @Override + public HttpHeaders getResponseHeaders() { + if (CollectionUtils.isEmpty(this.httpMethods)) { + return HttpHeaders.EMPTY; + } + HttpHeaders headers = new HttpHeaders(); + headers.setAllow(this.httpMethods); + return headers; } /** diff --git a/spring-web/src/main/java/org/springframework/web/server/NotAcceptableStatusException.java b/spring-web/src/main/java/org/springframework/web/server/NotAcceptableStatusException.java index aa8a01d46a68..6045dbd51693 100644 --- a/spring-web/src/main/java/org/springframework/web/server/NotAcceptableStatusException.java +++ b/spring-web/src/main/java/org/springframework/web/server/NotAcceptableStatusException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -20,6 +20,7 @@ import java.util.List; import java.util.Map; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.util.CollectionUtils; @@ -57,11 +58,24 @@ public NotAcceptableStatusException(List supportedMediaTypes) { * Return a Map with an "Accept" header. * @since 5.1.11 */ + @SuppressWarnings("deprecation") @Override public Map getHeaders() { - return !CollectionUtils.isEmpty(this.supportedMediaTypes) ? - Collections.singletonMap("Accept", MediaType.toString(this.supportedMediaTypes)) : - Collections.emptyMap(); + return getResponseHeaders().toSingleValueMap(); + } + + /** + * Return HttpHeaders with an "Accept" header, or an empty instance. + * @since 5.1.13 + */ + @Override + public HttpHeaders getResponseHeaders() { + if (CollectionUtils.isEmpty(this.supportedMediaTypes)) { + return HttpHeaders.EMPTY; + } + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(this.supportedMediaTypes); + return headers; } /** diff --git a/spring-web/src/main/java/org/springframework/web/server/ResponseStatusException.java b/spring-web/src/main/java/org/springframework/web/server/ResponseStatusException.java index a0245686a081..67c8d78391ea 100644 --- a/spring-web/src/main/java/org/springframework/web/server/ResponseStatusException.java +++ b/spring-web/src/main/java/org/springframework/web/server/ResponseStatusException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -21,6 +21,7 @@ import org.springframework.core.NestedExceptionUtils; import org.springframework.core.NestedRuntimeException; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.lang.Nullable; import org.springframework.util.Assert; @@ -82,14 +83,33 @@ public HttpStatus getStatus() { } /** - * Return response headers associated with the exception, possibly required - * for the given status code (e.g. "Allow", "Accept"). + * Return headers associated with the exception that should be added to the + * error response, e.g. "Allow", "Accept", etc. + *

    The default implementation in this class returns an empty map. * @since 5.1.11 + * @deprecated as of 5.1.13 in favor of {@link #getResponseHeaders()} */ + @Deprecated public Map getHeaders() { return Collections.emptyMap(); } + /** + * Return headers associated with the exception that should be added to the + * error response, e.g. "Allow", "Accept", etc. + *

    The default implementation in this class returns empty headers. + * @since 5.1.13 + */ + public HttpHeaders getResponseHeaders() { + Map headers = getHeaders(); + if (headers.isEmpty()) { + return HttpHeaders.EMPTY; + } + HttpHeaders result = new HttpHeaders(); + getHeaders().forEach(result::add); + return result; + } + /** * The reason explaining the exception (potentially {@code null} or empty). */ diff --git a/spring-web/src/main/java/org/springframework/web/server/handler/ResponseStatusExceptionHandler.java b/spring-web/src/main/java/org/springframework/web/server/handler/ResponseStatusExceptionHandler.java index 263e9cf1afe0..cda26cba2136 100644 --- a/spring-web/src/main/java/org/springframework/web/server/handler/ResponseStatusExceptionHandler.java +++ b/spring-web/src/main/java/org/springframework/web/server/handler/ResponseStatusExceptionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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,8 +92,9 @@ private boolean updateResponse(ServerHttpResponse response, Throwable ex) { if (status != null) { if (response.setStatusCode(status)) { if (ex instanceof ResponseStatusException) { - ((ResponseStatusException) ex).getHeaders() - .forEach((name, value) -> response.getHeaders().add(name, value)); + ((ResponseStatusException) ex).getResponseHeaders() + .forEach((name, values) -> + values.forEach(value -> response.getHeaders().add(name, value))); } result = true; } From ffc1f960f9b87aadab071aa46fecc59f29a9bb28 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 7 Jan 2020 09:05:49 +0100 Subject: [PATCH 0267/2315] Polish See gh-24238 --- .../org/springframework/http/HttpHeaders.java | 32 +++++++++---------- .../http/ReadOnlyHttpHeaders.java | 5 +++ .../reactive/AbstractServerHttpResponse.java | 12 ++----- .../RequestMappingHandlerAdapter.java | 5 +-- 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index 68e693375d34..68c4ab013c27 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -1522,6 +1522,22 @@ public List getValuesAsList(String headerName) { return Collections.emptyList(); } + /** + * Remove the well-known {@code "Content-*"} HTTP headers. + *

    Such headers should be cleared from the response if the intended + * body can't be written due to errors. + * @since 5.2.3 + */ + public void clearContentHeaders() { + this.headers.remove(HttpHeaders.CONTENT_DISPOSITION); + this.headers.remove(HttpHeaders.CONTENT_ENCODING); + this.headers.remove(HttpHeaders.CONTENT_LANGUAGE); + this.headers.remove(HttpHeaders.CONTENT_LENGTH); + this.headers.remove(HttpHeaders.CONTENT_LOCATION); + this.headers.remove(HttpHeaders.CONTENT_RANGE); + this.headers.remove(HttpHeaders.CONTENT_TYPE); + } + /** * Retrieve a combined result from the field values of the ETag header. * @param headerName the header name @@ -1827,22 +1843,6 @@ public static String encodeBasicAuth(String username, String password, @Nullable return new String(encodedBytes, charset); } - /** - * Remove the well-known {@code "Content-*"} HTTP headers from the given instance. - *

    Such headers should be cleared, if possible, from the response if the intended - * body can't be written due to errors. - * @since 5.2.3 - */ - public static void clearContentHeaders(HttpHeaders headers) { - headers.remove(HttpHeaders.CONTENT_DISPOSITION); - headers.remove(HttpHeaders.CONTENT_ENCODING); - headers.remove(HttpHeaders.CONTENT_LANGUAGE); - headers.remove(HttpHeaders.CONTENT_LENGTH); - headers.remove(HttpHeaders.CONTENT_LOCATION); - headers.remove(HttpHeaders.CONTENT_RANGE); - headers.remove(HttpHeaders.CONTENT_TYPE); - } - // Package-private: used in ResponseCookie static String formatDate(long date) { Instant instant = Instant.ofEpochMilli(date); diff --git a/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java b/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java index ff129f7a0c98..3fb73408630c 100644 --- a/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java @@ -75,6 +75,11 @@ public List getAccept() { } } + @Override + public void clearContentHeaders() { + // No-op. + } + @Override public List get(Object key) { List values = this.headers.get(key); diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java index e53366e27643..a87126791415 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java @@ -182,22 +182,16 @@ public final Mono writeWith(Publisher body) { return ((Mono) body).flatMap(buffer -> doCommit(() -> writeWithInternal(Mono.just(buffer))) .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release)) - .doOnError(t -> clearContentHeaders()); + .doOnError(t -> this.getHeaders().clearContentHeaders()); } return new ChannelSendOperator<>(body, inner -> doCommit(() -> writeWithInternal(inner))) - .doOnError(t -> clearContentHeaders()); + .doOnError(t -> this.getHeaders().clearContentHeaders()); } @Override public final Mono writeAndFlushWith(Publisher> body) { return new ChannelSendOperator<>(body, inner -> doCommit(() -> writeAndFlushWithInternal(inner))) - .doOnError(t -> clearContentHeaders()); - } - - private void clearContentHeaders() { - if (!this.isCommitted()) { - HttpHeaders.clearContentHeaders(this.getHeaders()); - } + .doOnError(t -> this.getHeaders().clearContentHeaders()); } @Override diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java index a8f5a1efeac6..094c8a728752 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java @@ -29,7 +29,6 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.http.HttpHeaders; import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.codec.ServerCodecConfigurer; import org.springframework.lang.Nullable; @@ -210,9 +209,7 @@ private Mono handleException(Throwable exception, HandlerMethod h // Success and error responses may use different content types exchange.getAttributes().remove(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE); - if (!exchange.getResponse().isCommitted()) { - HttpHeaders.clearContentHeaders(exchange.getResponse().getHeaders()); - } + exchange.getResponse().getHeaders().clearContentHeaders(); InvocableHandlerMethod invocable = this.methodResolver.getExceptionHandlerMethod(exception, handlerMethod); if (invocable != null) { From 132805133ded4737d2a69dbcd1f81852934884d5 Mon Sep 17 00:00:00 2001 From: lixiaolong11000 Date: Tue, 7 Jan 2020 18:03:11 +0800 Subject: [PATCH 0268/2315] Improve ExposeInvocationInterceptor exception message Closes gh-24293 --- .../aop/interceptor/ExposeInvocationInterceptor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java index 3b3f62fa7cc5..52142fd99169 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java @@ -73,7 +73,9 @@ public static MethodInvocation currentInvocation() throws IllegalStateException throw new IllegalStateException( "No MethodInvocation found: Check that an AOP invocation is in progress, and that the " + "ExposeInvocationInterceptor is upfront in the interceptor chain. Specifically, note that " + - "advices with order HIGHEST_PRECEDENCE will execute before ExposeInvocationInterceptor!"); + "advices with order HIGHEST_PRECEDENCE will execute before ExposeInvocationInterceptor! " + + "Check that ExposeInvocationInterceptor and ExposeInvocationInterceptor.currentInvocation() " + + "invoke in one Thread"); } return mi; } From 141dae6437f5e2681a14fae35616edd525366e99 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 7 Jan 2020 11:07:03 +0100 Subject: [PATCH 0269/2315] Polish contribution See gh-24293 --- .../aop/interceptor/ExposeInvocationInterceptor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java index 52142fd99169..6c14533b3959 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -71,11 +71,11 @@ public static MethodInvocation currentInvocation() throws IllegalStateException MethodInvocation mi = invocation.get(); if (mi == null) { throw new IllegalStateException( - "No MethodInvocation found: Check that an AOP invocation is in progress, and that the " + + "No MethodInvocation found: Check that an AOP invocation is in progress and that the " + "ExposeInvocationInterceptor is upfront in the interceptor chain. Specifically, note that " + "advices with order HIGHEST_PRECEDENCE will execute before ExposeInvocationInterceptor! " + - "Check that ExposeInvocationInterceptor and ExposeInvocationInterceptor.currentInvocation() " + - "invoke in one Thread"); + "In addition, ExposeInvocationInterceptor and ExposeInvocationInterceptor.currentInvocation() " + + "must be invoked from the same thread."); } return mi; } From 4692f20aaca89b763aee703ce714e7109dca4e9c Mon Sep 17 00:00:00 2001 From: GungnirLaevatain <547992357@qq.com> Date: Tue, 7 Jan 2020 18:35:38 +0800 Subject: [PATCH 0270/2315] Remove code duplication in AnnotationDrivenBeanDefinitionParser This commit merges the implementations of getCallableInterceptors() and getDeferredResultInterceptors() in order to remove code duplication. Closes gh-24305 --- .../AnnotationDrivenBeanDefinitionParser.java | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java index 7c8dfc5432ac..5258a1054488 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java @@ -234,8 +234,8 @@ public BeanDefinition parse(Element element, ParserContext context) { ManagedList returnValueHandlers = getReturnValueHandlers(element, context); String asyncTimeout = getAsyncTimeout(element); RuntimeBeanReference asyncExecutor = getAsyncExecutor(element); - ManagedList callableInterceptors = getCallableInterceptors(element, source, context); - ManagedList deferredResultInterceptors = getDeferredResultInterceptors(element, source, context); + ManagedList callableInterceptors = getInterceptors(element, source, context, "callable-interceptors"); + ManagedList deferredResultInterceptors = getInterceptors(element, source, context, "deferred-result-interceptors"); RootBeanDefinition handlerAdapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class); handlerAdapterDef.setSource(source); @@ -480,34 +480,13 @@ private RuntimeBeanReference getAsyncExecutor(Element element) { return null; } - private ManagedList getCallableInterceptors( - Element element, @Nullable Object source, ParserContext context) { - - ManagedList interceptors = new ManagedList<>(); - Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support"); - if (asyncElement != null) { - Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, "callable-interceptors"); - if (interceptorsElement != null) { - interceptors.setSource(source); - for (Element converter : DomUtils.getChildElementsByTagName(interceptorsElement, "bean")) { - BeanDefinitionHolder beanDef = context.getDelegate().parseBeanDefinitionElement(converter); - if (beanDef != null) { - beanDef = context.getDelegate().decorateBeanDefinitionIfRequired(converter, beanDef); - interceptors.add(beanDef); - } - } - } - } - return interceptors; - } - - private ManagedList getDeferredResultInterceptors( - Element element, @Nullable Object source, ParserContext context) { + private ManagedList getInterceptors( + Element element, @Nullable Object source, ParserContext context, String interceptorElementName) { ManagedList interceptors = new ManagedList<>(); Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support"); if (asyncElement != null) { - Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, "deferred-result-interceptors"); + Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, interceptorElementName); if (interceptorsElement != null) { interceptors.setSource(source); for (Element converter : DomUtils.getChildElementsByTagName(interceptorsElement, "bean")) { From 12a78d1af2fffa83ceffaa314aa5a20d6096e0e7 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 7 Jan 2020 11:36:53 +0100 Subject: [PATCH 0271/2315] Update copyright date See gh-24305 --- .../servlet/config/AnnotationDrivenBeanDefinitionParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java index 5258a1054488..d70469ceb584 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. From 55e0ff11ca770b8d2359b20760344cd3ae232b2a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 7 Jan 2020 13:59:31 +0100 Subject: [PATCH 0272/2315] Add note regarding ADJT development builds for Eclipse 4.10 --- import-into-eclipse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/import-into-eclipse.md b/import-into-eclipse.md index 17e028db58f7..e2175748ad61 100644 --- a/import-into-eclipse.md +++ b/import-into-eclipse.md @@ -23,7 +23,7 @@ _When instructed to execute `./gradlew` from the command line, be sure to execut 1. Switch to Groovy 2.5 (Preferences -> Groovy -> Compiler -> Switch to 2.5...) in Eclipse. 1. Change the _Forbidden reference (access rule)_ in Eclipse from Error to Warning (Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rule)). -1. Optionally install the [AspectJ Development Tools](https://www.eclipse.org/ajdt/downloads/) (_AJDT_) if you need to work with the `spring-aspects` project. +1. Optionally install the [AspectJ Development Tools](https://www.eclipse.org/ajdt/downloads/) (_AJDT_) if you need to work with the `spring-aspects` project. Please note that as of January 2020, the AJDT _Development builds for Eclipse 4.10_ are known to work with versions of Eclipse greater than 4.10. For example, this has been tested with STS 4.5 (Eclipse 4.14). 1. Optionally install the [TestNG plugin](https://testng.org/doc/eclipse.html) in Eclipse if you need to execute TestNG tests in the `spring-test` module. 1. Build `spring-oxm` from the command line with `./gradlew :spring-oxm:check`. 1. To apply project specific settings, run `./gradlew eclipseBuildship` from the command line. From c480a99a773d461a6f64dab0dfceeaa6cefa2fb4 Mon Sep 17 00:00:00 2001 From: stsypanov Date: Thu, 19 Dec 2019 18:14:49 +0200 Subject: [PATCH 0273/2315] Trim line from LineInfo only once --- .../resource/AppCacheManifestTransformer.java | 11 ++++++----- .../servlet/resource/AppCacheManifestTransformer.java | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java index 58ea4ab7fccb..e6d2d56a580e 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java @@ -68,13 +68,13 @@ */ public class AppCacheManifestTransformer extends ResourceTransformerSupport { - private static final Collection MANIFEST_SECTION_HEADERS = - Arrays.asList("CACHE MANIFEST", "NETWORK:", "FALLBACK:", "CACHE:"); - private static final String MANIFEST_HEADER = "CACHE MANIFEST"; private static final String CACHE_HEADER = "CACHE:"; + private static final Collection MANIFEST_SECTION_HEADERS = + Arrays.asList(MANIFEST_HEADER, "NETWORK:", "FALLBACK:", CACHE_HEADER); + private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; private static final Log logger = LogFactory.getLog(AppCacheManifestTransformer.class); @@ -212,8 +212,9 @@ private static class LineInfo { private static boolean initCacheSectionFlag(String line, @Nullable LineInfo previousLine) { - if (MANIFEST_SECTION_HEADERS.contains(line.trim())) { - return line.trim().equals(CACHE_HEADER); + String trimmedLine = line.trim(); + if (MANIFEST_SECTION_HEADERS.contains(trimmedLine)) { + return trimmedLine.equals(CACHE_HEADER); } else if (previousLine != null) { return previousLine.isCacheSection(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java index 8868b5c54f0d..fb3bdd0b30c5 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java @@ -65,13 +65,13 @@ */ public class AppCacheManifestTransformer extends ResourceTransformerSupport { - private static final Collection MANIFEST_SECTION_HEADERS = - Arrays.asList("CACHE MANIFEST", "NETWORK:", "FALLBACK:", "CACHE:"); - private static final String MANIFEST_HEADER = "CACHE MANIFEST"; private static final String CACHE_HEADER = "CACHE:"; + private static final Collection MANIFEST_SECTION_HEADERS = + Arrays.asList(MANIFEST_HEADER, "NETWORK:", "FALLBACK:", CACHE_HEADER); + private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; private static final Log logger = LogFactory.getLog(AppCacheManifestTransformer.class); @@ -168,8 +168,9 @@ public LineInfo(String line, @Nullable LineInfo previous) { } private static boolean initCacheSectionFlag(String line, @Nullable LineInfo previousLine) { - if (MANIFEST_SECTION_HEADERS.contains(line.trim())) { - return line.trim().equals(CACHE_HEADER); + String trimmedLine = line.trim(); + if (MANIFEST_SECTION_HEADERS.contains(trimmedLine)) { + return trimmedLine.equals(CACHE_HEADER); } else if (previousLine != null) { return previousLine.isCacheSection(); From 9d963abb7dfb6b0d0a3f6d89a2e60ebd42268146 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 7 Jan 2020 14:00:27 +0000 Subject: [PATCH 0274/2315] Concrete MediaType check in StringHttpMessageConverter Closes gh-23287 --- .../converter/AbstractHttpMessageConverter.java | 4 ++-- .../http/converter/StringHttpMessageConverter.java | 10 +++++----- .../converter/StringHttpMessageConverterTests.java | 14 +++++++++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java index 7b873b97b046..cf0674e06a1a 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -239,7 +239,7 @@ public HttpHeaders getHeaders() { protected void addDefaultHeaders(HttpHeaders headers, T t, @Nullable MediaType contentType) throws IOException { if (headers.getContentType() == null) { MediaType contentTypeToUse = contentType; - if (contentType == null || contentType.isWildcardType() || contentType.isWildcardSubtype()) { + if (contentType == null || !contentType.isConcrete()) { contentTypeToUse = getDefaultContentType(t); } else if (MediaType.APPLICATION_OCTET_STREAM.equals(contentType)) { diff --git a/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java index 7abccf5a06fd..d576855d95d5 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -102,14 +102,14 @@ protected Long getContentLength(String str, @Nullable MediaType contentType) { @Override - protected void addDefaultHeaders(HttpHeaders headers, String s, @Nullable MediaType mediaType) throws IOException { + protected void addDefaultHeaders(HttpHeaders headers, String s, @Nullable MediaType type) throws IOException { if (headers.getContentType() == null ) { - if (mediaType != null && mediaType.isCompatibleWith(MediaType.APPLICATION_JSON)) { + if (type != null && type.isConcrete() && type.isCompatibleWith(MediaType.APPLICATION_JSON)) { // Prevent charset parameter for JSON.. - headers.setContentType(mediaType); + headers.setContentType(type); } } - super.addDefaultHeaders(headers, s, mediaType); + super.addDefaultHeaders(headers, s, type); } @Override diff --git a/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java index c0e8792d33f6..5ee6df9b009b 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -131,4 +131,16 @@ public void writeOverrideRequestedContentType() throws IOException { assertThat(headers.getAcceptCharset().isEmpty()).isTrue(); } + @Test // gh-24283 + public void writeWithWildCardMediaType() throws IOException { + String body = "Hello World"; + this.converter.write(body, MediaType.ALL, this.outputMessage); + + HttpHeaders headers = this.outputMessage.getHeaders(); + assertThat(this.outputMessage.getBodyAsString(StandardCharsets.US_ASCII)).isEqualTo(body); + assertThat(headers.getContentType()).isEqualTo(new MediaType("text", "plain", StandardCharsets.ISO_8859_1)); + assertThat(headers.getContentLength()).isEqualTo(body.getBytes().length); + assertThat(headers.getAcceptCharset().isEmpty()).isTrue(); + } + } From ef6b1ba034f48178c922051870363a5c5f6139fc Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 7 Jan 2020 17:15:23 +0100 Subject: [PATCH 0275/2315] Update copyright date --- .../web/reactive/resource/AppCacheManifestTransformer.java | 2 +- .../web/servlet/resource/AppCacheManifestTransformer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java index e6d2d56a580e..f77eed5346be 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java index fb3bdd0b30c5..eb3253e13284 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. From e1fb4a1966a340893d6958789520a18638d95cf4 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 7 Jan 2020 18:47:54 +0100 Subject: [PATCH 0276/2315] Polishing --- .../annotation/AnnotationBeanNameGenerator.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java index 29ad5fce072c..58b7a3631495 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -32,15 +32,12 @@ import org.springframework.util.StringUtils; /** - * {@link org.springframework.beans.factory.support.BeanNameGenerator} - * implementation for bean classes annotated with the - * {@link org.springframework.stereotype.Component @Component} annotation - * or with another annotation that is itself annotated with - * {@link org.springframework.stereotype.Component @Component} as a + * {@link BeanNameGenerator} implementation for bean classes annotated with the + * {@link org.springframework.stereotype.Component @Component} annotation or + * with another annotation that is itself annotated with {@code @Component} as a * meta-annotation. For example, Spring's stereotype annotations (such as * {@link org.springframework.stereotype.Repository @Repository}) are - * themselves annotated with - * {@link org.springframework.stereotype.Component @Component}. + * themselves annotated with {@code @Component}. * *

    Also supports Java EE 6's {@link javax.annotation.ManagedBean} and * JSR-330's {@link javax.inject.Named} annotations, if available. Note that From b4c91e7dac91c6176a5412ed930d2c048cc5c42f Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 7 Jan 2020 19:39:28 +0100 Subject: [PATCH 0277/2315] Introduce BeanNameGenerator based on fully qualified class name Prior to this commit, Spring offered two top-level implementations of the BeanNameGenerator strategy: DefaultBeanNameGenerator and AnnotationBeanNameGenerator. The latter is used as the default bean name generator for beans picked up via component scanning. In a typical application, this strategy works well; however, if multiple component scanned beans have the same simple class name (i.e., identical names ignoring the package), a BeanDefinitionStoreException is thrown. To address such naming conflicts, users of Spring have had to implement a custom BeanNameGenerator based on the fully qualified class name of such components. Similar conflicts can arise with components registered via configuration class imports (i.e., via @Import), and ConfigurationClassPostProcessor addresses this via an anonymous inner class that extends AnnotationBeanNameGenerator but falls back to using the fully qualified class name if an explicit bean name is not provided via an annotation. This commit extracts the implementation of ConfigurationClassPostProcessor's internal BeanNameGenerator into a new top-level FullyQualifiedAnnotationBeanNameGenerator class that can be used to disambiguate between same-named components residing in different packages that are picked up via component scanning. This bean name generator can be configured via @ComponentScan's nameGenerator attribute. Closes gh-24114 --- .../AnnotationBeanNameGenerator.java | 1 + .../ConfigurationClassPostProcessor.java | 12 ++--- ...yQualifiedAnnotationBeanNameGenerator.java | 48 +++++++++++++++++++ 3 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 spring-context/src/main/java/org/springframework/context/annotation/FullyQualifiedAnnotationBeanNameGenerator.java diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java index 58b7a3631495..b01dc9f95fb1 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java @@ -57,6 +57,7 @@ * @see org.springframework.stereotype.Service#value() * @see org.springframework.stereotype.Controller#value() * @see javax.inject.Named#value() + * @see FullyQualifiedAnnotationBeanNameGenerator */ public class AnnotationBeanNameGenerator implements BeanNameGenerator { diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java index 4baaa4f94dae..515c78c91a3b 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -95,14 +95,8 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo * @since 5.2 * @see #setBeanNameGenerator */ - public static final AnnotationBeanNameGenerator IMPORT_BEAN_NAME_GENERATOR = new AnnotationBeanNameGenerator() { - @Override - protected String buildDefaultBeanName(BeanDefinition definition) { - String beanClassName = definition.getBeanClassName(); - Assert.state(beanClassName != null, "No bean class name set"); - return beanClassName; - } - }; + public static final AnnotationBeanNameGenerator IMPORT_BEAN_NAME_GENERATOR = + new FullyQualifiedAnnotationBeanNameGenerator(); private static final String IMPORT_REGISTRY_BEAN_NAME = ConfigurationClassPostProcessor.class.getName() + ".importRegistry"; diff --git a/spring-context/src/main/java/org/springframework/context/annotation/FullyQualifiedAnnotationBeanNameGenerator.java b/spring-context/src/main/java/org/springframework/context/annotation/FullyQualifiedAnnotationBeanNameGenerator.java new file mode 100644 index 000000000000..da68da276cb6 --- /dev/null +++ b/spring-context/src/main/java/org/springframework/context/annotation/FullyQualifiedAnnotationBeanNameGenerator.java @@ -0,0 +1,48 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.context.annotation; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.util.Assert; + +/** + * An extension of {@code AnnotationBeanNameGenerator} that uses the fully qualified + * class name as the default bean name if an explicit bean name is not supplied via + * a supported type-level annotation such as {@code @Component} (see + * {@link AnnotationBeanNameGenerator} for details on supported annotations). + * + *

    Note that an instance of this class is used by default for configuration-level + * import purposes; whereas, the default for component scanning purposes is a plain + * {@code AnnotationBeanNameGenerator}. + * + * @author Juergen Hoeller + * @author Sam Brannen + * @since 5.2.3 + * @see org.springframework.beans.factory.support.DefaultBeanNameGenerator + * @see AnnotationBeanNameGenerator + * @see ConfigurationClassPostProcessor#IMPORT_BEAN_NAME_GENERATOR + */ +public class FullyQualifiedAnnotationBeanNameGenerator extends AnnotationBeanNameGenerator { + + @Override + protected String buildDefaultBeanName(BeanDefinition definition) { + String beanClassName = definition.getBeanClassName(); + Assert.state(beanClassName != null, "No bean class name set"); + return beanClassName; + } + +} From e3e7d904158a74ff5c3e578ab2e3467ea910deba Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 8 Jan 2020 16:44:55 +0100 Subject: [PATCH 0278/2315] Improve documentation for FullyQualifiedAnnotationBeanNameGenerator See gh-24114 --- .../AnnotationConfigApplicationContext.java | 6 ++++-- .../context/annotation/ComponentScan.java | 4 +++- .../FullyQualifiedAnnotationBeanNameGenerator.java | 5 +++++ src/docs/asciidoc/core/core-beans.adoc | 13 ++++++++++--- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java index fa98718d2706..696655ad0d7f 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -116,11 +116,13 @@ public void setEnvironment(ConfigurableEnvironment environment) { /** * Provide a custom {@link BeanNameGenerator} for use with {@link AnnotatedBeanDefinitionReader} * and/or {@link ClassPathBeanDefinitionScanner}, if any. - *

    Default is {@link org.springframework.context.annotation.AnnotationBeanNameGenerator}. + *

    Default is {@link AnnotationBeanNameGenerator}. *

    Any call to this method must occur prior to calls to {@link #register(Class...)} * and/or {@link #scan(String...)}. * @see AnnotatedBeanDefinitionReader#setBeanNameGenerator * @see ClassPathBeanDefinitionScanner#setBeanNameGenerator + * @see AnnotationBeanNameGenerator + * @see FullyQualifiedAnnotationBeanNameGenerator */ public void setBeanNameGenerator(BeanNameGenerator beanNameGenerator) { this.reader.setBeanNameGenerator(beanNameGenerator); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ComponentScan.java b/spring-context/src/main/java/org/springframework/context/annotation/ComponentScan.java index 7bd970b63fc8..ffa1f1a06451 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ComponentScan.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ComponentScan.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2020 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. @@ -94,6 +94,8 @@ * {@link AnnotationBeanNameGenerator} or any custom instance supplied to the * application context at bootstrap time. * @see AnnotationConfigApplicationContext#setBeanNameGenerator(BeanNameGenerator) + * @see AnnotationBeanNameGenerator + * @see FullyQualifiedAnnotationBeanNameGenerator */ Class nameGenerator() default BeanNameGenerator.class; diff --git a/spring-context/src/main/java/org/springframework/context/annotation/FullyQualifiedAnnotationBeanNameGenerator.java b/spring-context/src/main/java/org/springframework/context/annotation/FullyQualifiedAnnotationBeanNameGenerator.java index da68da276cb6..5495535d6a77 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/FullyQualifiedAnnotationBeanNameGenerator.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/FullyQualifiedAnnotationBeanNameGenerator.java @@ -25,6 +25,11 @@ * a supported type-level annotation such as {@code @Component} (see * {@link AnnotationBeanNameGenerator} for details on supported annotations). * + *

    Favor this bean naming strategy over {@code AnnotationBeanNameGenerator} if + * you run into naming conflicts due to multiple autodetected components having the + * same non-qualified class name (i.e., classes with identical names but residing in + * different packages). + * *

    Note that an instance of this class is used by default for configuration-level * import purposes; whereas, the default for component scanning purposes is a plain * {@code AnnotationBeanNameGenerator}. diff --git a/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc index d434ac95de15..bbecd6c728a1 100644 --- a/src/docs/asciidoc/core/core-beans.adoc +++ b/src/docs/asciidoc/core/core-beans.adoc @@ -6941,12 +6941,19 @@ classes were detected, the names would be `myMovieLister` and `movieFinderImpl`: } ---- -NOTE: If you do not want to rely on the default bean-naming strategy, you can provide a -custom bean-naming strategy. First, implement the +If you do not want to rely on the default bean-naming strategy, you can provide a custom +bean-naming strategy. First, implement the {api-spring-framework}/beans/factory/support/BeanNameGenerator.html[`BeanNameGenerator`] interface, and be sure to include a default no-arg constructor. Then, provide the fully qualified class name when configuring the scanner, as the following example annotation -and bean definition show: +and bean definition show. + +TIP: If you run into naming conflicts due to multiple autodetected components having the +same non-qualified class name (i.e., classes with identical names but residing in +different packages), you may need to configure a `BeanNameGenerator` that defaults to the +fully qualified class name for the generated bean name. As of Spring Framework 5.2.3, the +`FullyQualifiedAnnotationBeanNameGenerator` located in package +`org.springframework.context.annotation` can be used for such purposes. [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java From e96b71acf3af4df7d00270e93659ec1f00495fdc Mon Sep 17 00:00:00 2001 From: Oleh Faizulin Date: Sat, 4 Jan 2020 09:54:53 +0200 Subject: [PATCH 0279/2315] contentLength support for Resource decoding Expose the known content length, if known, in the InputStreamResource returned by ResourceHttpMessageConverter or ResourceDecoder. See gh-24292 --- .../core/codec/ResourceDecoder.java | 5 +++++ .../core/codec/ResourceDecoderTests.java | 18 ++++++++++++++++++ .../ResourceHttpMessageConverter.java | 5 +++++ .../ResourceHttpMessageConverterTests.java | 2 ++ 4 files changed, 30 insertions(+) diff --git a/spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java b/spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java index eeb307cfcdf9..b19e6f954500 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java @@ -83,6 +83,11 @@ public Resource decode(DataBuffer dataBuffer, ResolvableType elementType, public String getFilename() { return filename; } + + @Override + public long contentLength() { + return bytes.length; + } }; } else if (Resource.class.isAssignableFrom(clazz)) { diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java index 1c3a531f7a3e..3c129428f555 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java @@ -105,4 +105,22 @@ public void decodeToMono() { Collections.singletonMap(ResourceDecoder.FILENAME_HINT, "testFile")); } + @Test + public void decodeInputStreamResource() { + Flux input = Flux.concat(dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); + testDecodeAll(input, InputStreamResource.class, step -> step + .consumeNextWith(resource -> { + try { + byte[] bytes = StreamUtils.copyToByteArray(resource.getInputStream()); + assertThat(new String(bytes)).isEqualTo("foobar"); + assertThat(resource.contentLength()).isEqualTo(fooBytes.length + barBytes.length); + } + catch (IOException ex) { + throw new AssertionError(ex.getMessage(), ex); + } + }) + .expectComplete() + .verify()); + } + } diff --git a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java index 582ab859de16..3fd720831578 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java @@ -84,6 +84,11 @@ protected Resource readInternal(Class clazz, HttpInputMessag public String getFilename() { return inputMessage.getHeaders().getContentDisposition().getFilename(); } + + @Override + public long contentLength() { + return inputMessage.getHeaders().getContentLength(); + } }; } else if (Resource.class == clazz || ByteArrayResource.class.isAssignableFrom(clazz)) { diff --git a/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java index efc1163bd75f..082ec788ca31 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java @@ -80,10 +80,12 @@ public void shouldReadInputStreamResource() throws IOException { inputMessage.getHeaders().setContentType(MediaType.IMAGE_JPEG); inputMessage.getHeaders().setContentDisposition( ContentDisposition.builder("attachment").filename("yourlogo.jpg").build()); + inputMessage.getHeaders().setContentLength(123); Resource actualResource = converter.read(InputStreamResource.class, inputMessage); assertThat(actualResource).isInstanceOf(InputStreamResource.class); assertThat(actualResource.getInputStream()).isEqualTo(body); assertThat(actualResource.getFilename()).isEqualTo("yourlogo.jpg"); + assertThat(actualResource.contentLength()).isEqualTo(123); } } From 01827389ef2e8297ff572ac3ffa8bb5e8ac604d8 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 8 Jan 2020 16:16:07 +0000 Subject: [PATCH 0280/2315] Polishing contribution See gh-24292 --- .../org/springframework/core/codec/ResourceDecoder.java | 3 +-- .../springframework/core/codec/ResourceDecoderTests.java | 7 ++----- .../http/converter/ResourceHttpMessageConverter.java | 8 ++++---- .../http/converter/ResourceHttpMessageConverterTests.java | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java b/spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java index b19e6f954500..4e9552a650a0 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -83,7 +83,6 @@ public Resource decode(DataBuffer dataBuffer, ResolvableType elementType, public String getFilename() { return filename; } - @Override public long contentLength() { return bytes.length; diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java index 3c129428f555..f060ce4f3598 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -82,10 +82,7 @@ public void decode() { @Override @Test public void decodeToMono() { - Flux input = Flux.concat( - dataBuffer(this.fooBytes), - dataBuffer(this.barBytes)); - + Flux input = Flux.concat(dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); testDecodeToMonoAll(input, ResolvableType.forClass(Resource.class), step -> step .consumeNextWith(value -> { diff --git a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java index 3fd720831578..f587aecf7ff9 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -84,10 +84,10 @@ protected Resource readInternal(Class clazz, HttpInputMessag public String getFilename() { return inputMessage.getHeaders().getContentDisposition().getFilename(); } - @Override - public long contentLength() { - return inputMessage.getHeaders().getContentLength(); + public long contentLength() throws IOException { + long length = inputMessage.getHeaders().getContentLength(); + return (length != -1 ? length : super.contentLength()); } }; } diff --git a/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java index 082ec788ca31..5a05d431c792 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. From 53b39eb753300bfeb385d19de062267d0cbd98a9 Mon Sep 17 00:00:00 2001 From: Astushi Yoshikawa Date: Thu, 5 Dec 2019 21:47:23 +0900 Subject: [PATCH 0281/2315] MvcUriComponentsBuilder prepends slash See gh-24143 --- .../annotation/MvcUriComponentsBuilder.java | 10 +++--- .../MvcUriComponentsBuilderTests.java | 33 +++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java index 27ef77bf84d3..0107807b55b6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java @@ -102,6 +102,8 @@ public class MvcUriComponentsBuilder { */ public static final String MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME = "mvcUriComponentsContributor"; + /** Path separator: "/". */ + public static final String PATH_SEPARATOR = "/"; private static final Log logger = LogFactory.getLog(MvcUriComponentsBuilder.class); @@ -545,7 +547,7 @@ private static UriComponentsBuilder fromMethodInternal(@Nullable UriComponentsBu String typePath = getClassMapping(controllerType); String methodPath = getMethodMapping(method); String path = pathMatcher.combine(typePath, methodPath); - builder.path(path); + builder.path(path.startsWith(PATH_SEPARATOR) ? path : PATH_SEPARATOR + path); return applyContributors(builder, method, args); } @@ -576,11 +578,11 @@ private static String getClassMapping(Class controllerType) { Assert.notNull(controllerType, "'controllerType' must not be null"); RequestMapping mapping = AnnotatedElementUtils.findMergedAnnotation(controllerType, RequestMapping.class); if (mapping == null) { - return "/"; + return PATH_SEPARATOR; } String[] paths = mapping.path(); if (ObjectUtils.isEmpty(paths) || !StringUtils.hasLength(paths[0])) { - return "/"; + return PATH_SEPARATOR; } if (paths.length > 1 && logger.isTraceEnabled()) { logger.trace("Using first of multiple paths on " + controllerType.getName()); @@ -596,7 +598,7 @@ private static String getMethodMapping(Method method) { } String[] paths = requestMapping.path(); if (ObjectUtils.isEmpty(paths) || !StringUtils.hasLength(paths[0])) { - return "/"; + return PATH_SEPARATOR; } if (paths.length > 1 && logger.isTraceEnabled()) { logger.trace("Using first of multiple paths on " + method.toGenericString()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java index 103118d8ebcb..52ec013363e3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java @@ -434,6 +434,20 @@ public void fromMappingNameWithEncoding() { assertThat(url).isEqualTo("/base/people/_%2B_/addresses/DE%3BFR"); } + @Test + public void fromMappingNameWithNonSlashPath() { + + initWebApplicationContext(NonSlashPathWebConfig.class); + + this.request.setServerName("example.org"); + this.request.setServerPort(9999); + this.request.setContextPath("/base"); + + String mappingName = "NSPC#getAddressesForCountry"; + String url = fromMappingName(mappingName).arg(0, "DE;FR").encode().buildAndExpand("_+_"); + assertThat(url).isEqualTo("/base/people/DE%3BFR"); + } + @Test public void fromControllerWithPrefix() { @@ -499,6 +513,15 @@ HttpEntity getAddressesForCountry(@PathVariable String country) { } + @RequestMapping({"people"}) + static class NonSlashPathController { + + @RequestMapping("/{country}") + HttpEntity getAddressesForCountry(@PathVariable String country) { + return null; + } + } + @RequestMapping({"/persons", "/people"}) private class InvalidController { } @@ -622,6 +645,16 @@ public PersonsAddressesController controller() { } + @EnableWebMvc + static class NonSlashPathWebConfig implements WebMvcConfigurer { + + @Bean + public NonSlashPathController controller() { + return new NonSlashPathController(); + } + } + + @EnableWebMvc static class PathPrefixWebConfig implements WebMvcConfigurer { From d509d5ae6f413c623a5e763bf832e604090d6cad Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 8 Jan 2020 16:46:53 +0000 Subject: [PATCH 0282/2315] Polishing contribution See gh-24143 --- .../annotation/MvcUriComponentsBuilder.java | 15 ++++++++------- .../MvcUriComponentsBuilderTests.java | 17 ++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java index 0107807b55b6..765823866b8f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -102,8 +102,6 @@ public class MvcUriComponentsBuilder { */ public static final String MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME = "mvcUriComponentsContributor"; - /** Path separator: "/". */ - public static final String PATH_SEPARATOR = "/"; private static final Log logger = LogFactory.getLog(MvcUriComponentsBuilder.class); @@ -547,7 +545,10 @@ private static UriComponentsBuilder fromMethodInternal(@Nullable UriComponentsBu String typePath = getClassMapping(controllerType); String methodPath = getMethodMapping(method); String path = pathMatcher.combine(typePath, methodPath); - builder.path(path.startsWith(PATH_SEPARATOR) ? path : PATH_SEPARATOR + path); + if (StringUtils.hasLength(path) && !path.startsWith("/")) { + path = "/" + path; + } + builder.path(path); return applyContributors(builder, method, args); } @@ -578,11 +579,11 @@ private static String getClassMapping(Class controllerType) { Assert.notNull(controllerType, "'controllerType' must not be null"); RequestMapping mapping = AnnotatedElementUtils.findMergedAnnotation(controllerType, RequestMapping.class); if (mapping == null) { - return PATH_SEPARATOR; + return "/"; } String[] paths = mapping.path(); if (ObjectUtils.isEmpty(paths) || !StringUtils.hasLength(paths[0])) { - return PATH_SEPARATOR; + return "/"; } if (paths.length > 1 && logger.isTraceEnabled()) { logger.trace("Using first of multiple paths on " + controllerType.getName()); @@ -598,7 +599,7 @@ private static String getMethodMapping(Method method) { } String[] paths = requestMapping.path(); if (ObjectUtils.isEmpty(paths) || !StringUtils.hasLength(paths[0])) { - return PATH_SEPARATOR; + return "/"; } if (paths.length > 1 && logger.isTraceEnabled()) { logger.trace("Using first of multiple paths on " + method.toGenericString()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java index 52ec013363e3..99abb24debdf 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -435,15 +435,15 @@ public void fromMappingNameWithEncoding() { } @Test - public void fromMappingNameWithNonSlashPath() { + public void fromMappingNameWithPathWithoutLeadingSlash() { - initWebApplicationContext(NonSlashPathWebConfig.class); + initWebApplicationContext(PathWithoutLeadingSlashConfig.class); this.request.setServerName("example.org"); this.request.setServerPort(9999); this.request.setContextPath("/base"); - String mappingName = "NSPC#getAddressesForCountry"; + String mappingName = "PWLSC#getAddressesForCountry"; String url = fromMappingName(mappingName).arg(0, "DE;FR").encode().buildAndExpand("_+_"); assertThat(url).isEqualTo("/base/people/DE%3BFR"); } @@ -512,9 +512,8 @@ HttpEntity getAddressesForCountry(@PathVariable String country) { } } - @RequestMapping({"people"}) - static class NonSlashPathController { + static class PathWithoutLeadingSlashController { @RequestMapping("/{country}") HttpEntity getAddressesForCountry(@PathVariable String country) { @@ -646,11 +645,11 @@ public PersonsAddressesController controller() { @EnableWebMvc - static class NonSlashPathWebConfig implements WebMvcConfigurer { + static class PathWithoutLeadingSlashConfig implements WebMvcConfigurer { @Bean - public NonSlashPathController controller() { - return new NonSlashPathController(); + public PathWithoutLeadingSlashController controller() { + return new PathWithoutLeadingSlashController(); } } From 259ffe9b3b49f175ea78ebd36179a5e7551d1b45 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 8 Jan 2020 18:37:07 +0100 Subject: [PATCH 0283/2315] Thread-safe compiled expression evaluation in SpelExpression Closes gh-24265 --- .../spel/standard/SpelExpression.java | 108 ++++++++++-------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java index 870a523266b5..124a7a411aeb 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -67,7 +67,7 @@ public class SpelExpression implements Expression { // Holds the compiled form of the expression (if it has been compiled) @Nullable - private CompiledExpression compiledAst; + private volatile CompiledExpression compiledAst; // Count of many times as the expression been interpreted - can trigger compilation // when certain limit reached @@ -75,7 +75,7 @@ public class SpelExpression implements Expression { // The number of times compilation was attempted and failed - enables us to eventually // give up trying to compile it when it just doesn't seem to be possible. - private volatile int failedAttempts = 0; + private final AtomicInteger failedAttempts = new AtomicInteger(0); /** @@ -118,16 +118,17 @@ public String getExpressionString() { @Override @Nullable public Object getValue() throws EvaluationException { - if (this.compiledAst != null) { + CompiledExpression compiledAst = this.compiledAst; + if (compiledAst != null) { try { EvaluationContext context = getEvaluationContext(); - return this.compiledAst.getValue(context.getRootObject().getValue(), context); + return compiledAst.getValue(context.getRootObject().getValue(), context); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { - this.interpretedCount.set(0); this.compiledAst = null; + this.interpretedCount.set(0); } else { // Running in SpelCompilerMode.immediate mode - propagate exception to caller @@ -146,10 +147,11 @@ public Object getValue() throws EvaluationException { @Override @Nullable public T getValue(@Nullable Class expectedResultType) throws EvaluationException { - if (this.compiledAst != null) { + CompiledExpression compiledAst = this.compiledAst; + if (compiledAst != null) { try { EvaluationContext context = getEvaluationContext(); - Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context); + Object result = compiledAst.getValue(context.getRootObject().getValue(), context); if (expectedResultType == null) { return (T) result; } @@ -161,8 +163,8 @@ public T getValue(@Nullable Class expectedResultType) throws EvaluationEx catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { - this.interpretedCount.set(0); this.compiledAst = null; + this.interpretedCount.set(0); } else { // Running in SpelCompilerMode.immediate mode - propagate exception to caller @@ -181,15 +183,16 @@ public T getValue(@Nullable Class expectedResultType) throws EvaluationEx @Override @Nullable public Object getValue(@Nullable Object rootObject) throws EvaluationException { - if (this.compiledAst != null) { + CompiledExpression compiledAst = this.compiledAst; + if (compiledAst != null) { try { - return this.compiledAst.getValue(rootObject, getEvaluationContext()); + return compiledAst.getValue(rootObject, getEvaluationContext()); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { - this.interpretedCount.set(0); this.compiledAst = null; + this.interpretedCount.set(0); } else { // Running in SpelCompilerMode.immediate mode - propagate exception to caller @@ -209,9 +212,10 @@ public Object getValue(@Nullable Object rootObject) throws EvaluationException { @Override @Nullable public T getValue(@Nullable Object rootObject, @Nullable Class expectedResultType) throws EvaluationException { - if (this.compiledAst != null) { + CompiledExpression compiledAst = this.compiledAst; + if (compiledAst != null) { try { - Object result = this.compiledAst.getValue(rootObject, getEvaluationContext()); + Object result = compiledAst.getValue(rootObject, getEvaluationContext()); if (expectedResultType == null) { return (T)result; } @@ -223,8 +227,8 @@ public T getValue(@Nullable Object rootObject, @Nullable Class expectedRe catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { - this.interpretedCount.set(0); this.compiledAst = null; + this.interpretedCount.set(0); } else { // Running in SpelCompilerMode.immediate mode - propagate exception to caller @@ -246,15 +250,16 @@ public T getValue(@Nullable Object rootObject, @Nullable Class expectedRe public Object getValue(EvaluationContext context) throws EvaluationException { Assert.notNull(context, "EvaluationContext is required"); - if (this.compiledAst != null) { + CompiledExpression compiledAst = this.compiledAst; + if (compiledAst != null) { try { - return this.compiledAst.getValue(context.getRootObject().getValue(), context); + return compiledAst.getValue(context.getRootObject().getValue(), context); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { - this.interpretedCount.set(0); this.compiledAst = null; + this.interpretedCount.set(0); } else { // Running in SpelCompilerMode.immediate mode - propagate exception to caller @@ -275,9 +280,10 @@ public Object getValue(EvaluationContext context) throws EvaluationException { public T getValue(EvaluationContext context, @Nullable Class expectedResultType) throws EvaluationException { Assert.notNull(context, "EvaluationContext is required"); - if (this.compiledAst != null) { + CompiledExpression compiledAst = this.compiledAst; + if (compiledAst != null) { try { - Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context); + Object result = compiledAst.getValue(context.getRootObject().getValue(), context); if (expectedResultType != null) { return ExpressionUtils.convertTypedValue(context, new TypedValue(result), expectedResultType); } @@ -288,8 +294,8 @@ public T getValue(EvaluationContext context, @Nullable Class expectedResu catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { - this.interpretedCount.set(0); this.compiledAst = null; + this.interpretedCount.set(0); } else { // Running in SpelCompilerMode.immediate mode - propagate exception to caller @@ -309,15 +315,16 @@ public T getValue(EvaluationContext context, @Nullable Class expectedResu public Object getValue(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException { Assert.notNull(context, "EvaluationContext is required"); - if (this.compiledAst != null) { + CompiledExpression compiledAst = this.compiledAst; + if (compiledAst != null) { try { - return this.compiledAst.getValue(rootObject, context); + return compiledAst.getValue(rootObject, context); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { - this.interpretedCount.set(0); this.compiledAst = null; + this.interpretedCount.set(0); } else { // Running in SpelCompilerMode.immediate mode - propagate exception to caller @@ -340,9 +347,10 @@ public T getValue(EvaluationContext context, @Nullable Object rootObject, @N Assert.notNull(context, "EvaluationContext is required"); - if (this.compiledAst != null) { + CompiledExpression compiledAst = this.compiledAst; + if (compiledAst != null) { try { - Object result = this.compiledAst.getValue(rootObject, context); + Object result = compiledAst.getValue(rootObject, context); if (expectedResultType != null) { return ExpressionUtils.convertTypedValue(context, new TypedValue(result), expectedResultType); } @@ -353,8 +361,8 @@ public T getValue(EvaluationContext context, @Nullable Object rootObject, @N catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { - this.interpretedCount.set(0); this.compiledAst = null; + this.interpretedCount.set(0); } else { // Running in SpelCompilerMode.immediate mode - propagate exception to caller @@ -492,31 +500,41 @@ private void checkCompile(ExpressionState expressionState) { } } - /** - * Perform expression compilation. This will only succeed once exit descriptors for all nodes have - * been determined. If the compilation fails and has failed more than 100 times the expression is - * no longer considered suitable for compilation. + * Perform expression compilation. This will only succeed once exit descriptors for + * all nodes have been determined. If the compilation fails and has failed more than + * 100 times the expression is no longer considered suitable for compilation. + * @return whether this expression has been successfully compiled */ public boolean compileExpression() { - if (this.failedAttempts > FAILED_ATTEMPTS_THRESHOLD) { + CompiledExpression compiledAst = this.compiledAst; + if (compiledAst != null) { + // Previously compiled + return true; + } + if (this.failedAttempts.get() > FAILED_ATTEMPTS_THRESHOLD) { // Don't try again return false; } - if (this.compiledAst == null) { - synchronized (this.expression) { - // Possibly compiled by another thread before this thread got into the sync block - if (this.compiledAst != null) { - return true; - } - SpelCompiler compiler = SpelCompiler.getCompiler(this.configuration.getCompilerClassLoader()); - this.compiledAst = compiler.compile(this.ast); - if (this.compiledAst == null) { - this.failedAttempts++; - } + + synchronized (this) { + if (this.compiledAst != null) { + // Compiled by another thread before this thread got into the sync block + return true; + } + SpelCompiler compiler = SpelCompiler.getCompiler(this.configuration.getCompilerClassLoader()); + compiledAst = compiler.compile(this.ast); + if (compiledAst != null) { + // Successfully compiled + this.compiledAst = compiledAst; + return true; + } + else { + // Failed to compile + this.failedAttempts.incrementAndGet(); + return false; } } - return (this.compiledAst != null); } /** @@ -527,7 +545,7 @@ public boolean compileExpression() { public void revertToInterpreted() { this.compiledAst = null; this.interpretedCount.set(0); - this.failedAttempts = 0; + this.failedAttempts.set(0); } /** From c562c3a0b3d02cdc3aa1654560683aac0cedead3 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 8 Jan 2020 18:38:55 +0100 Subject: [PATCH 0284/2315] Upgrade to Netty 4.1.44, Jetty 9.4.25, Undertow 2.0.29, OkHttp 3.14.5, Jackson 2.10.2 --- build.gradle | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index c3f625e7962e..f0e407dce10c 100644 --- a/build.gradle +++ b/build.gradle @@ -41,11 +41,11 @@ configure(allprojects) { project -> dependencyManagement { imports { - mavenBom "com.fasterxml.jackson:jackson-bom:2.10.1" - mavenBom "io.netty:netty-bom:4.1.43.Final" + mavenBom "com.fasterxml.jackson:jackson-bom:2.10.2" + mavenBom "io.netty:netty-bom:4.1.44.Final" mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR2" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" - mavenBom "org.eclipse.jetty:jetty-bom:9.4.24.v20191120" + mavenBom "org.eclipse.jetty:jetty-bom:9.4.25.v20191220" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.61" mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.2" mavenBom "org.junit:junit-bom:5.5.2" @@ -146,7 +146,7 @@ configure(allprojects) { project -> entry 'tomcat-embed-core' entry 'tomcat-embed-websocket' } - dependencySet(group: 'io.undertow', version: '2.0.28.Final') { + dependencySet(group: 'io.undertow', version: '2.0.29.Final') { entry 'undertow-core' entry('undertow-websockets-jsr') { exclude group: "org.jboss.spec.javax.websocket", name: "jboss-websocket-api_1.1_spec" @@ -157,7 +157,7 @@ configure(allprojects) { project -> } } - dependencySet(group: 'com.squareup.okhttp3', version: '3.14.4') { + dependencySet(group: 'com.squareup.okhttp3', version: '3.14.5') { entry 'okhttp' entry 'mockwebserver' } From 8e5cad2af3d0465c98f7269ec1a6262a3f30c1bb Mon Sep 17 00:00:00 2001 From: stsypanov Date: Mon, 30 Dec 2019 17:20:07 +0200 Subject: [PATCH 0285/2315] Add fast path for ClassUtils.hasMethod() --- .../aop/framework/CglibAopProxy.java | 2 +- .../beans/factory/support/AutowireUtils.java | 5 ++- .../InterfaceBasedMBeanInfoAssembler.java | 2 +- .../MethodValidationInterceptor.java | 2 +- .../org/springframework/util/ClassUtils.java | 34 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java index 1e899671aaaf..a58ae43ced75 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java @@ -365,7 +365,7 @@ public int hashCode() { */ private static boolean implementsInterface(Method method, Set> ifcs) { for (Class ifc : ifcs) { - if (ClassUtils.hasMethod(ifc, method.getName(), method.getParameterTypes())) { + if (ClassUtils.hasMethod(ifc, method)) { return true; } } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java index 50adef4df217..cb569b07d626 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java @@ -97,7 +97,7 @@ public static boolean isExcludedFromDependencyCheck(PropertyDescriptor pd) { // It was declared by CGLIB, but we might still want to autowire it // if it was actually declared by the superclass. Class superclass = wm.getDeclaringClass().getSuperclass(); - return !ClassUtils.hasMethod(superclass, wm.getName(), wm.getParameterTypes()); + return !ClassUtils.hasMethod(superclass, wm); } /** @@ -112,8 +112,7 @@ public static boolean isSetterDefinedInInterface(PropertyDescriptor pd, Set targetClass = setter.getDeclaringClass(); for (Class ifc : interfaces) { - if (ifc.isAssignableFrom(targetClass) && - ClassUtils.hasMethod(ifc, setter.getName(), setter.getParameterTypes())) { + if (ifc.isAssignableFrom(targetClass) && ClassUtils.hasMethod(ifc, setter)) { return true; } } diff --git a/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java b/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java index 8248215725aa..3b4ef961f6ed 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java @@ -207,7 +207,7 @@ protected boolean includeOperation(Method method, String beanKey) { * configured interfaces and is public, otherwise {@code false}. */ private boolean isPublicInInterface(Method method, String beanKey) { - return ((method.getModifiers() & Modifier.PUBLIC) > 0) && isDeclaredInInterface(method, beanKey); + return Modifier.isPublic(method.getModifiers()) && isDeclaredInInterface(method, beanKey); } /** diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java index 4b4d5e506a47..eb28c85d8506 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java +++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java @@ -145,7 +145,7 @@ else if (FactoryBean.class.isAssignableFrom(clazz)) { factoryBeanType = FactoryBean.class; } return (factoryBeanType != null && !method.getName().equals("getObject") && - ClassUtils.hasMethod(factoryBeanType, method.getName(), method.getParameterTypes())); + ClassUtils.hasMethod(factoryBeanType, method)); } /** diff --git a/spring-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index 44390ec2dfd1..c77dcba127fd 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -1101,6 +1101,24 @@ public static boolean hasMethod(Class clazz, String methodName, Class... p return (getMethodIfAvailable(clazz, methodName, paramTypes) != null); } + /** + * Determine whether the given class has a public method with the given signature. + * @param clazz the clazz to analyze + * @param method checked method + * @return whether the class has a corresponding method + * @see Method#getDeclaringClass + */ + public static boolean hasMethod(Class clazz, Method method) { + Assert.notNull(clazz, "Class must not be null"); + Assert.notNull(method, "Method must not be null"); + if (clazz == method.getDeclaringClass()) { + return true; + } + String methodName = method.getName(); + Class[] paramTypes = method.getParameterTypes(); + return getMethodOrNull(clazz, methodName, paramTypes) != null; + } + /** * Determine whether the given class has a public method with the given signature, * and return it if available (else throws an {@code IllegalStateException}). @@ -1158,12 +1176,7 @@ public static Method getMethodIfAvailable(Class clazz, String methodName, @Nu Assert.notNull(clazz, "Class must not be null"); Assert.notNull(methodName, "Method name must not be null"); if (paramTypes != null) { - try { - return clazz.getMethod(methodName, paramTypes); - } - catch (NoSuchMethodException ex) { - return null; - } + return getMethodOrNull(clazz, methodName, paramTypes); } else { Set candidates = findMethodCandidatesByName(clazz, methodName); @@ -1370,4 +1383,13 @@ private static Set findMethodCandidatesByName(Class clazz, String met } return candidates; } + + @Nullable + private static Method getMethodOrNull(Class clazz, String methodName, Class[] paramTypes) { + try { + return clazz.getMethod(methodName, paramTypes); + } catch (NoSuchMethodException ex) { + return null; + } + } } From c39ed52f9774f83b08c41d1ca3ab2adcf5026f72 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 8 Jan 2020 19:05:03 +0100 Subject: [PATCH 0286/2315] Add since tag to hasMethod(Class, Method) See gh-24282 --- .../org/springframework/util/ClassUtils.java | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index c77dcba127fd..91a74aa3f8fc 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -533,7 +533,7 @@ public static Class resolvePrimitiveIfNecessary(Class clazz) { * @param lhsType the target type * @param rhsType the value type that should be assigned to the target type * @return if the target type is assignable from the value type - * @see TypeUtils#isAssignable + * @see TypeUtils#isAssignable(java.lang.reflect.Type, java.lang.reflect.Type) */ public static boolean isAssignable(Class lhsType, Class rhsType) { Assert.notNull(lhsType, "Left-hand side type must not be null"); @@ -1088,25 +1088,12 @@ public static Constructor getConstructorIfAvailable(Class clazz, Class } } - /** - * Determine whether the given class has a public method with the given signature. - *

    Essentially translates {@code NoSuchMethodException} to "false". - * @param clazz the clazz to analyze - * @param methodName the name of the method - * @param paramTypes the parameter types of the method - * @return whether the class has a corresponding method - * @see Class#getMethod - */ - public static boolean hasMethod(Class clazz, String methodName, Class... paramTypes) { - return (getMethodIfAvailable(clazz, methodName, paramTypes) != null); - } - /** * Determine whether the given class has a public method with the given signature. * @param clazz the clazz to analyze - * @param method checked method + * @param method the method to look for * @return whether the class has a corresponding method - * @see Method#getDeclaringClass + * @since 5.2.3 */ public static boolean hasMethod(Class clazz, Method method) { Assert.notNull(clazz, "Class must not be null"); @@ -1119,6 +1106,19 @@ public static boolean hasMethod(Class clazz, Method method) { return getMethodOrNull(clazz, methodName, paramTypes) != null; } + /** + * Determine whether the given class has a public method with the given signature. + *

    Essentially translates {@code NoSuchMethodException} to "false". + * @param clazz the clazz to analyze + * @param methodName the name of the method + * @param paramTypes the parameter types of the method + * @return whether the class has a corresponding method + * @see Class#getMethod + */ + public static boolean hasMethod(Class clazz, String methodName, Class... paramTypes) { + return (getMethodIfAvailable(clazz, methodName, paramTypes) != null); + } + /** * Determine whether the given class has a public method with the given signature, * and return it if available (else throws an {@code IllegalStateException}). @@ -1373,6 +1373,17 @@ public static Method getStaticMethod(Class clazz, String methodName, Class } } + + @Nullable + private static Method getMethodOrNull(Class clazz, String methodName, Class[] paramTypes) { + try { + return clazz.getMethod(methodName, paramTypes); + } + catch (NoSuchMethodException ex) { + return null; + } + } + private static Set findMethodCandidatesByName(Class clazz, String methodName) { Set candidates = new HashSet<>(1); Method[] methods = clazz.getMethods(); @@ -1384,12 +1395,4 @@ private static Set findMethodCandidatesByName(Class clazz, String met return candidates; } - @Nullable - private static Method getMethodOrNull(Class clazz, String methodName, Class[] paramTypes) { - try { - return clazz.getMethod(methodName, paramTypes); - } catch (NoSuchMethodException ex) { - return null; - } - } } From 2ac57443235238394d369aafbdb5fa01219aec3f Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 16 Dec 2019 09:03:40 +0000 Subject: [PATCH 0287/2315] Upgrade to Asciidoctor Gradle Plugin 2.4 This commit updates the build to use the latest version of the Asciidoctor Gradle Plugin. One significant new feature is that the plugin's tasks are now cacheable. Closes gh-24216 --- build.gradle | 13 +------------ gradle/docs.gradle | 32 +++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index f0e407dce10c..b375eec539f1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,8 @@ -buildscript { - dependencies { - classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16' - classpath 'io.spring.asciidoctor:spring-asciidoctor-extensions:0.1.3.RELEASE' - } -} - plugins { id 'io.spring.dependency-management' version '1.0.8.RELEASE' apply false id 'org.jetbrains.kotlin.jvm' version '1.3.61' apply false id 'org.jetbrains.dokka' version '0.9.18' apply false - id 'org.asciidoctor.convert' version '1.5.8' + id 'org.asciidoctor.jvm.convert' version '2.4.0' id 'io.spring.nohttp' version '0.0.4.RELEASE' id 'de.undercouch.download' version '4.0.0' id 'com.gradle.build-scan' version '3.1.1' @@ -413,10 +406,6 @@ configure(rootProject) { } } - dependencies { - asciidoctor("io.spring.asciidoctor:spring-asciidoctor-extensions:0.1.3.RELEASE") - } - publishing { publications { mavenJava(MavenPublication) { diff --git a/gradle/docs.gradle b/gradle/docs.gradle index fd83d77f5f1c..934015c2615c 100644 --- a/gradle/docs.gradle +++ b/gradle/docs.gradle @@ -1,3 +1,11 @@ +configurations { + asciidoctorExt +} + +dependencies { + asciidoctorExt("io.spring.asciidoctor:spring-asciidoctor-extensions:0.2.0.RELEASE") +} + /** * Produce Javadoc for all Spring Framework modules in "build/docs/javadoc" */ @@ -93,11 +101,21 @@ task extractDocResources(type: Copy, dependsOn: downloadResources) { into "$buildDir/docs/spring-docs-resources/" } +asciidoctorj { + modules { + pdf { + version '1.5.0-beta.8' + } + } +} + /** * Produce the Spring Framework Reference documentation * from "src/docs/asciidoc" into "build/asciidoc/html5" */ asciidoctor { + baseDirFollowsSourceDir() + configurations 'asciidoctorExt' sources { include '*.adoc' } @@ -106,13 +124,15 @@ asciidoctor { from(sourceDir) { include 'images/*', 'css/**', 'js/**' } - from "$buildDir/docs/spring-docs-resources/" + from extractDocResources } logDocuments = true - backends = ["html5"] - // only ouput PDF documentation for non-SNAPSHOT builds - if (!project.getVersion().toString().contains("BUILD-SNAPSHOT")) { - backends += "pdf" + outputOptions { + backends = ["html5"] + // only ouput PDF documentation for non-SNAPSHOT builds + if (!project.getVersion().toString().contains("BUILD-SNAPSHOT")) { + backends += "pdf" + } } options doctype: 'book', eruby: 'erubis' attributes([ @@ -132,8 +152,6 @@ asciidoctor { ]) } -asciidoctor.dependsOn extractDocResources - /** * Zip all docs (API and reference) into a single archive */ From 1ec15ba9c2c3a61fa93a67c074732d6de65fd2e1 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 16 Dec 2019 09:15:46 +0000 Subject: [PATCH 0288/2315] Always configure PDF backend as task will only run on cache miss Previously, the Asciidoctor task was not cacheable and generating the PDF documentation was very slow. To improve build times, the PDF documentation was not generated for snapshot builds. The upgrade to 2.4.0 of the Asciidoctor Gradle pluging means that the Asciidoctor task is now cacheable. As such, its tasks will only run when the documentation has changed. This should allow PDF documentation to be published for every build without slowing things down too much and the cost of generating the documentation will only be incurred when there is a change to the documentation. See gh-24216 --- gradle/docs.gradle | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gradle/docs.gradle b/gradle/docs.gradle index 934015c2615c..591832d681ab 100644 --- a/gradle/docs.gradle +++ b/gradle/docs.gradle @@ -128,11 +128,7 @@ asciidoctor { } logDocuments = true outputOptions { - backends = ["html5"] - // only ouput PDF documentation for non-SNAPSHOT builds - if (!project.getVersion().toString().contains("BUILD-SNAPSHOT")) { - backends += "pdf" - } + backends = ["html5", "pdf"] } options doctype: 'book', eruby: 'erubis' attributes([ From 34d32402d352fe7bca2f45d3bc5c7243459ec556 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 8 Jan 2020 17:55:23 +0000 Subject: [PATCH 0289/2315] Return 500 if producible attribute present When a request is mapped through a producible condition on an @RequestMapping, then a failure to find a converter/decoder should be a 500 because the return type + media type pair were declared by the controller and that should be possible to render. Closes gh-23287 --- .../AbstractMessageWriterResultHandler.java | 9 +++++-- .../ResponseEntityResultHandlerTests.java | 25 ++++++++++++++++++- ...stractMessageConverterMethodProcessor.java | 8 ++++-- .../HttpEntityMethodProcessorMockTests.java | 22 ++++++++++++++-- 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java index 68919bf82ac9..8d13a1f46e0c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -19,6 +19,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import java.util.Set; import kotlin.reflect.KFunction; import kotlin.reflect.jvm.ReflectJvmMapping; @@ -36,6 +37,8 @@ import org.springframework.http.converter.HttpMessageNotWritableException; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; +import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.reactive.accept.RequestedContentTypeResolver; import org.springframework.web.reactive.result.HandlerResultHandlerSupport; import org.springframework.web.server.NotAcceptableStatusException; @@ -163,7 +166,9 @@ protected Mono writeBody(@Nullable Object body, MethodParameter bodyParame } MediaType contentType = exchange.getResponse().getHeaders().getContentType(); - if (contentType != null && contentType.equals(bestMediaType)) { + boolean isPresentMediaType = (contentType != null && contentType.equals(bestMediaType)); + Set producibleTypes = exchange.getAttribute(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE); + if (isPresentMediaType || !CollectionUtils.isEmpty(producibleTypes)) { return Mono.error(new HttpMessageNotWritableException( "No Encoder for [" + elementType + "] with preset Content-Type '" + contentType + "'")); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java index a000cf08587f..f7a5f5afa792 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -26,6 +26,7 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.CompletableFuture; import org.junit.jupiter.api.BeforeEach; @@ -371,6 +372,28 @@ public void handleWithPresetContentTypeShouldFailWithServerError() { .verify(); } + @Test // gh-23287 + public void handleWithProducibleContentTypeShouldFailWithServerError() { + ResponseEntity value = ResponseEntity.ok().body(""); + MethodParameter returnType = on(TestController.class).resolveReturnType(entity(String.class)); + HandlerResult result = handlerResult(value, returnType); + + MockServerWebExchange exchange = MockServerWebExchange.from(get("/path")); + Set mediaTypes = Collections.singleton(MediaType.APPLICATION_XML); + exchange.getAttributes().put(PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, mediaTypes); + + ResponseEntityResultHandler resultHandler = new ResponseEntityResultHandler( + Collections.singletonList(new EncoderHttpMessageWriter<>(CharSequenceEncoder.textPlainOnly())), + new RequestedContentTypeResolverBuilder().build() + ); + + StepVerifier.create(resultHandler.handleResult(exchange, result)) + .consumeErrorWith(ex -> assertThat(ex) + .isInstanceOf(HttpMessageNotWritableException.class) + .hasMessageContaining("with preset Content-Type")) + .verify(); + } + private void testHandle(Object returnValue, MethodParameter returnType) { MockServerWebExchange exchange = MockServerWebExchange.from(get("/path")); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java index c19c519d122d..61eaeac00d73 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -309,7 +309,11 @@ else if (mediaType.isPresentIn(ALL_APPLICATION_MEDIA_TYPES)) { } if (body != null) { - if (isContentTypePreset) { + Set producibleMediaTypes = + (Set) inputMessage.getServletRequest() + .getAttribute(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE); + + if (isContentTypePreset || !CollectionUtils.isEmpty(producibleMediaTypes)) { throw new HttpMessageNotWritableException( "No converter for [" + valueType + "] with preset Content-Type '" + contentType + "'"); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java index b2e85cdf567a..dde74a7ceb39 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.Date; +import java.util.Set; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -323,7 +324,24 @@ public void shouldFailWithServerErrorIfContentTypeFromResponseEntity() { .contentType(MediaType.APPLICATION_XML) .body(""); - given(stringHttpMessageConverter.canWrite(String.class, null)).willReturn(true); + given(stringHttpMessageConverter.canWrite(String.class, TEXT_PLAIN)).willReturn(true); + given(stringHttpMessageConverter.getSupportedMediaTypes()).willReturn(Collections.singletonList(TEXT_PLAIN)); + + assertThatThrownBy(() -> + processor.handleReturnValue( + returnValue, returnTypeResponseEntity, mavContainer, webRequest)) + .isInstanceOf(HttpMessageNotWritableException.class) + .hasMessageContaining("with preset Content-Type"); + } + + @Test // gh-23287 + public void shouldFailWithServerErrorIfContentTypeFromProducibleAttribute() { + Set mediaTypes = Collections.singleton(MediaType.APPLICATION_XML); + servletRequest.setAttribute(PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, mediaTypes); + + ResponseEntity returnValue = ResponseEntity.ok().body(""); + + given(stringHttpMessageConverter.canWrite(String.class, TEXT_PLAIN)).willReturn(true); given(stringHttpMessageConverter.getSupportedMediaTypes()).willReturn(Collections.singletonList(TEXT_PLAIN)); assertThatThrownBy(() -> From 08e9372ded3c36255389727465158007daae34f4 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 9 Jan 2020 11:09:06 +0000 Subject: [PATCH 0290/2315] Restore response after beforeCommit action errors See gh-24186 --- .../reactive/AbstractServerHttpResponse.java | 56 +++++++++++-------- .../reactive/ServerHttpResponseTests.java | 47 +++++++++++++--- 2 files changed, 73 insertions(+), 30 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java index a87126791415..f4841a705250 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java @@ -176,22 +176,25 @@ public boolean isCommitted() { @Override @SuppressWarnings("unchecked") public final Mono writeWith(Publisher body) { - // Write as Mono if possible as an optimization hint to Reactor Netty - // ChannelSendOperator not necessary for Mono + // For Mono we can avoid ChannelSendOperator and Reactor Netty is more optimized for Mono. + // We must resolve value first however, for a chance to handle potential error. if (body instanceof Mono) { - return ((Mono) body).flatMap(buffer -> - doCommit(() -> writeWithInternal(Mono.just(buffer))) - .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release)) - .doOnError(t -> this.getHeaders().clearContentHeaders()); + return ((Mono) body) + .flatMap(buffer -> doCommit(() -> + writeWithInternal(Mono.fromCallable(() -> buffer) + .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release)))) + .doOnError(t -> getHeaders().clearContentHeaders()); + } + else { + return new ChannelSendOperator<>(body, inner -> doCommit(() -> writeWithInternal(inner))) + .doOnError(t -> getHeaders().clearContentHeaders()); } - return new ChannelSendOperator<>(body, inner -> doCommit(() -> writeWithInternal(inner))) - .doOnError(t -> this.getHeaders().clearContentHeaders()); } @Override public final Mono writeAndFlushWith(Publisher> body) { return new ChannelSendOperator<>(body, inner -> doCommit(() -> writeAndFlushWithInternal(inner))) - .doOnError(t -> this.getHeaders().clearContentHeaders()); + .doOnError(t -> getHeaders().clearContentHeaders()); } @Override @@ -217,21 +220,30 @@ protected Mono doCommit(@Nullable Supplier> writeActi if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) { return Mono.empty(); } - this.commitActions.add(() -> - Mono.fromRunnable(() -> { - applyStatusCode(); - applyHeaders(); - applyCookies(); - this.state.set(State.COMMITTED); - })); - if (writeAction != null) { - this.commitActions.add(writeAction); + + Flux allActions = Flux.empty(); + + if (!this.commitActions.isEmpty()) { + allActions = Flux.concat(Flux.fromIterable(this.commitActions).map(Supplier::get)) + .doOnError(ex -> { + if (this.state.compareAndSet(State.COMMITTING, State.NEW)) { + getHeaders().clearContentHeaders(); + } + }); } - Flux commit = Flux.empty(); - for (Supplier> action : this.commitActions) { - commit = commit.concatWith(action.get()); + + allActions = allActions.concatWith(Mono.fromRunnable(() -> { + applyStatusCode(); + applyHeaders(); + applyCookies(); + this.state.set(State.COMMITTED); + })); + + if (writeAction != null) { + allActions = allActions.concatWith(writeAction.get()); } - return commit.then(); + + return allActions.then(); } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java index c8a8552dd346..cdb4225381ab 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java @@ -20,11 +20,14 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; +import java.util.function.Supplier; import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DefaultDataBuffer; @@ -36,6 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat; /** + * Unit tests for {@link AbstractServerHttpRequest}. + * * @author Rossen Stoyanchev * @author Sebastien Deleuze * @author Brian Clozel @@ -43,7 +48,7 @@ public class ServerHttpResponseTests { @Test - void writeWith() throws Exception { + void writeWith() { TestServerHttpResponse response = new TestServerHttpResponse(); response.writeWith(Flux.just(wrap("a"), wrap("b"), wrap("c"))).block(); @@ -58,7 +63,7 @@ void writeWith() throws Exception { } @Test // SPR-14952 - void writeAndFlushWithFluxOfDefaultDataBuffer() throws Exception { + void writeAndFlushWithFluxOfDefaultDataBuffer() { TestServerHttpResponse response = new TestServerHttpResponse(); Flux> flux = Flux.just(Flux.just(wrap("foo"))); response.writeAndFlushWith(flux).block(); @@ -72,18 +77,18 @@ void writeAndFlushWithFluxOfDefaultDataBuffer() throws Exception { } @Test - void writeWithFluxError() throws Exception { + void writeWithFluxError() { IllegalStateException error = new IllegalStateException("boo"); writeWithError(Flux.error(error)); } @Test - void writeWithMonoError() throws Exception { + void writeWithMonoError() { IllegalStateException error = new IllegalStateException("boo"); writeWithError(Mono.error(error)); } - void writeWithError(Publisher body) throws Exception { + void writeWithError(Publisher body) { TestServerHttpResponse response = new TestServerHttpResponse(); HttpHeaders headers = response.getHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); @@ -100,7 +105,7 @@ void writeWithError(Publisher body) throws Exception { } @Test - void setComplete() throws Exception { + void setComplete() { TestServerHttpResponse response = new TestServerHttpResponse(); response.setComplete().block(); @@ -111,7 +116,7 @@ void setComplete() throws Exception { } @Test - void beforeCommitWithComplete() throws Exception { + void beforeCommitWithComplete() { ResponseCookie cookie = ResponseCookie.from("ID", "123").build(); TestServerHttpResponse response = new TestServerHttpResponse(); response.beforeCommit(() -> Mono.fromRunnable(() -> response.getCookies().add(cookie.getName(), cookie))); @@ -129,7 +134,7 @@ void beforeCommitWithComplete() throws Exception { } @Test - void beforeCommitActionWithSetComplete() throws Exception { + void beforeCommitActionWithSetComplete() { ResponseCookie cookie = ResponseCookie.from("ID", "123").build(); TestServerHttpResponse response = new TestServerHttpResponse(); response.beforeCommit(() -> { @@ -145,6 +150,32 @@ void beforeCommitActionWithSetComplete() throws Exception { assertThat(response.getCookies().getFirst("ID")).isSameAs(cookie); } + @Test // gh-24186 + void beforeCommitErrorShouldLeaveResponseNotCommitted() { + + Consumer>> tester = preCommitAction -> { + TestServerHttpResponse response = new TestServerHttpResponse(); + response.getHeaders().setContentType(MediaType.APPLICATION_JSON); + response.getHeaders().setContentLength(3); + response.beforeCommit(preCommitAction); + + StepVerifier.create(response.writeWith(Flux.just(wrap("body")))) + .expectErrorMessage("Max sessions") + .verify(); + + assertThat(response.statusCodeWritten).isFalse(); + assertThat(response.headersWritten).isFalse(); + assertThat(response.cookiesWritten).isFalse(); + assertThat(response.isCommitted()).isFalse(); + assertThat(response.getHeaders()).isEmpty(); + }; + + tester.accept(() -> Mono.error(new IllegalStateException("Max sessions"))); + tester.accept(() -> { + throw new IllegalStateException("Max sessions"); + }); + } + private DefaultDataBuffer wrap(String a) { return new DefaultDataBufferFactory().wrap(ByteBuffer.wrap(a.getBytes(StandardCharsets.UTF_8))); From b0e4b7e29cb66016dd2421241b8ed3224d0bbe08 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 9 Jan 2020 15:39:04 +0100 Subject: [PATCH 0291/2315] Re-calculate SimpleKey's hashCode field on deserialization Closes gh-24320 --- .../cache/interceptor/SimpleKey.java | 20 +++++++++++++--- .../interceptor/SimpleKeyGeneratorTests.java | 24 +++++++++++++------ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/SimpleKey.java b/spring-context/src/main/java/org/springframework/cache/interceptor/SimpleKey.java index da97487d4a4d..e6a2556e4a58 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/SimpleKey.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/SimpleKey.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -16,6 +16,8 @@ package org.springframework.cache.interceptor; +import java.io.IOException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Arrays; @@ -27,19 +29,23 @@ * A simple key as returned from the {@link SimpleKeyGenerator}. * * @author Phillip Webb + * @author Juergen Hoeller * @since 4.0 * @see SimpleKeyGenerator */ @SuppressWarnings("serial") public class SimpleKey implements Serializable { - /** An empty key. */ + /** + * An empty key. + */ public static final SimpleKey EMPTY = new SimpleKey(); private final Object[] params; - private final int hashCode; + // Effectively final, just re-calculated on deserialization + private transient int hashCode; /** @@ -49,6 +55,7 @@ public class SimpleKey implements Serializable { public SimpleKey(Object... elements) { Assert.notNull(elements, "Elements must not be null"); this.params = elements.clone(); + // Pre-calculate hashCode field this.hashCode = Arrays.deepHashCode(this.params); } @@ -61,6 +68,7 @@ public boolean equals(@Nullable Object other) { @Override public final int hashCode() { + // Expose pre-calculated hashCode field return this.hashCode; } @@ -69,4 +77,10 @@ public String toString() { return getClass().getSimpleName() + " [" + StringUtils.arrayToCommaDelimitedString(this.params) + "]"; } + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + ois.defaultReadObject(); + // Re-calculate hashCode field on deserialization + this.hashCode = Arrays.deepHashCode(this.params); + } + } diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java index 5357949f4451..2d9398ccb1a1 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -18,17 +18,16 @@ import org.junit.jupiter.api.Test; -import static org.assertj.core.api.Assertions.assertThat; - - - +import org.springframework.core.testfixture.io.SerializationTestUtils; +import static org.assertj.core.api.Assertions.assertThat; /** * Tests for {@link SimpleKeyGenerator} and {@link SimpleKey}. * * @author Phillip Webb * @author Stephane Nicoll + * @author Juergen Hoeller */ public class SimpleKeyGeneratorTests { @@ -47,7 +46,7 @@ public void noValues() { } @Test - public void singleValue(){ + public void singleValue() { Object k1 = generateKey(new Object[] { "a" }); Object k2 = generateKey(new Object[] { "a" }); Object k3 = generateKey(new Object[] { "different" }); @@ -59,7 +58,7 @@ public void singleValue(){ } @Test - public void multipleValues() { + public void multipleValues() { Object k1 = generateKey(new Object[] { "a", 1, "b" }); Object k2 = generateKey(new Object[] { "a", 1, "b" }); Object k3 = generateKey(new Object[] { "b", 1, "a" }); @@ -114,6 +113,17 @@ public void arrayWithExtraParameter() { assertThat(k1).isNotEqualTo(k3); } + @Test + public void serializedKeys() throws Exception { + Object k1 = SerializationTestUtils.serializeAndDeserialize(generateKey(new Object[] { "a", 1, "b" })); + Object k2 = SerializationTestUtils.serializeAndDeserialize(generateKey(new Object[] { "a", 1, "b" })); + Object k3 = SerializationTestUtils.serializeAndDeserialize(generateKey(new Object[] { "b", 1, "a" })); + assertThat(k1.hashCode()).isEqualTo(k2.hashCode()); + assertThat(k1.hashCode()).isNotEqualTo(k3.hashCode()); + assertThat(k1).isEqualTo(k2); + assertThat(k1).isNotEqualTo(k3); + } + private Object generateKey(Object[] arguments) { return this.generator.generate(null, null, arguments); From 047eefd2e29551a60dac2519e7f8cc7522be6864 Mon Sep 17 00:00:00 2001 From: lixiaolong11000 Date: Sat, 4 Jan 2020 22:45:00 +0800 Subject: [PATCH 0292/2315] Improve exception message in AopContext.currentProxy() Closes gh-24321 --- .../java/org/springframework/aop/framework/AopContext.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java b/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java index 36b5635d4abf..6a2f2ebb42b6 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java @@ -67,7 +67,8 @@ public static Object currentProxy() throws IllegalStateException { Object proxy = currentProxy.get(); if (proxy == null) { throw new IllegalStateException( - "Cannot find current proxy: Set 'exposeProxy' property on Advised to 'true' to make it available."); + "Cannot find current proxy: Set 'exposeProxy' property on Advised to 'true' to make it available. " + + "Also Check AopContext.currentProxy() invoke in the origin thread."); } return proxy; } From e8ef93c508d27f7e90e90b0fd1be388000a00f0e Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 9 Jan 2020 15:55:56 +0100 Subject: [PATCH 0293/2315] Polish contribution See gh-24321 --- .../java/org/springframework/aop/framework/AopContext.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java b/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java index 6a2f2ebb42b6..9653ced6bc8b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -67,8 +67,8 @@ public static Object currentProxy() throws IllegalStateException { Object proxy = currentProxy.get(); if (proxy == null) { throw new IllegalStateException( - "Cannot find current proxy: Set 'exposeProxy' property on Advised to 'true' to make it available. " + - "Also Check AopContext.currentProxy() invoke in the origin thread."); + "Cannot find current proxy: Set 'exposeProxy' property on Advised to 'true' to make it available, and " + + "ensure that AopContext.currentProxy() is invoked in the same thread as the AOP invocation context."); } return proxy; } From 4936a637fe4386c4a483cd686c0651e0a4ba2921 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 9 Jan 2020 17:03:17 +0100 Subject: [PATCH 0294/2315] Polishing --- .../InterfaceBasedMBeanInfoAssembler.java | 2 +- .../springframework/core/MethodParameter.java | 16 +++++++++------- .../http/server/DefaultPathContainer.java | 4 ++-- .../web/method/ControllerAdviceBean.java | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java b/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java index 3b4ef961f6ed..72bbaa32423a 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. diff --git a/spring-core/src/main/java/org/springframework/core/MethodParameter.java b/spring-core/src/main/java/org/springframework/core/MethodParameter.java index bcb1a357ef92..675229f2c73d 100644 --- a/spring-core/src/main/java/org/springframework/core/MethodParameter.java +++ b/spring-core/src/main/java/org/springframework/core/MethodParameter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -867,8 +867,8 @@ private static class KotlinDelegate { /** * Check whether the specified {@link MethodParameter} represents a nullable Kotlin type, - * an optional parameter (with a default value in the Kotlin declaration) or a {@code Continuation} parameter - * used in suspending functions. + * an optional parameter (with a default value in the Kotlin declaration) or a + * {@code Continuation} parameter used in suspending functions. */ public static boolean isOptional(MethodParameter param) { Method method = param.getMethod(); @@ -880,16 +880,18 @@ public static boolean isOptional(MethodParameter param) { KFunction function; Predicate predicate; if (method != null) { - if (param.parameterType.getName().equals("kotlin.coroutines.Continuation")) { + if (param.getParameterType().getName().equals("kotlin.coroutines.Continuation")) { return true; } function = ReflectJvmMapping.getKotlinFunction(method); predicate = p -> KParameter.Kind.VALUE.equals(p.getKind()); } else { - function = ReflectJvmMapping.getKotlinFunction(param.getConstructor()); - predicate = p -> KParameter.Kind.VALUE.equals(p.getKind()) || - KParameter.Kind.INSTANCE.equals(p.getKind()); + Constructor ctor = param.getConstructor(); + Assert.state(ctor != null, "Neither method nor constructor found"); + function = ReflectJvmMapping.getKotlinFunction(ctor); + predicate = p -> (KParameter.Kind.VALUE.equals(p.getKind()) || + KParameter.Kind.INSTANCE.equals(p.getKind())); } if (function != null) { int i = 0; diff --git a/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java b/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java index 2098f4594166..4476df73914a 100644 --- a/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java +++ b/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -107,7 +107,7 @@ static PathContainer createFromUrlPath(String path, Options options) { } List elements = new ArrayList<>(); int begin; - if (path.length() > 0 && path.charAt(0) == separator) { + if (path.charAt(0) == separator) { begin = 1; elements.add(separatorElement); } diff --git a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java index dc424a862752..21846840809f 100644 --- a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java +++ b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -149,7 +149,7 @@ public ControllerAdviceBean(String beanName, BeanFactory beanFactory, @Nullable public int getOrder() { if (this.order == null) { Object resolvedBean = null; - if (this.beanOrName instanceof String) { + if (this.beanFactory != null && this.beanOrName instanceof String) { String beanName = (String) this.beanOrName; String targetBeanName = ScopedProxyUtils.getTargetBeanName(beanName); boolean isScopedProxy = this.beanFactory.containsBean(targetBeanName); From f6ca21f6a4e86a7794bedcbec8f6971990b7300f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 9 Jan 2020 17:03:30 +0100 Subject: [PATCH 0295/2315] Upgrade to SLF4J 1.7.30 and Checkstyle 8.28 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index b375eec539f1..c282759e8ff9 100644 --- a/build.gradle +++ b/build.gradle @@ -50,7 +50,7 @@ configure(allprojects) { project -> entry 'log4j-slf4j-impl' entry 'log4j-jul' } - dependency "org.slf4j:slf4j-api:1.7.29" + dependency "org.slf4j:slf4j-api:1.7.30" dependency "com.google.code.findbugs:jsr305:3.0.2" @@ -332,7 +332,7 @@ configure([rootProject] + javaProjects) { project -> } checkstyle { - toolVersion = "8.27" + toolVersion = "8.28" configDir = rootProject.file("src/checkstyle") } From bdb9f9570e3c325999167415e66fc1339f9400ff Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 Jan 2020 17:08:48 +0100 Subject: [PATCH 0296/2315] Polish --- .../AbstractApplicationEventListenerTests.java | 13 +------------ .../event/ApplicationContextEventTests.java | 6 +++--- .../ApplicationListenerMethodAdapterTests.java | 10 +++++----- ...GenericApplicationListenerAdapterTests.java | 18 ++++++++++-------- 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/context/event/AbstractApplicationEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AbstractApplicationEventListenerTests.java index 31bd07444651..bf4360ef589b 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AbstractApplicationEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AbstractApplicationEventListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -16,8 +16,6 @@ package org.springframework.context.event; -import java.io.IOException; - import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; import org.springframework.core.ResolvableType; @@ -125,17 +123,8 @@ public void onApplicationEvent(ApplicationEvent event) { static class TestEvents { - public ApplicationEvent applicationEvent; - public GenericTestEvent wildcardEvent; - public GenericTestEvent stringEvent; - - public GenericTestEvent longEvent; - - public GenericTestEvent illegalStateExceptionEvent; - - public GenericTestEvent ioExceptionEvent; } } diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java index 2e92dbcaa19a..3b40c090d76c 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -79,13 +79,13 @@ public void multicastSimpleEvent() { @Test public void multicastGenericEvent() { multicastEvent(true, StringEventListener.class, createGenericTestEvent("test"), - getGenericApplicationEventType("stringEvent")); + ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } @Test public void multicastGenericEventWrongType() { multicastEvent(false, StringEventListener.class, createGenericTestEvent(123L), - getGenericApplicationEventType("longEvent")); + ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class)); } @Test diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java index 9d989d33cef2..c8fa0fcfe679 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -56,27 +56,27 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @Test public void rawListener() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleRaw", ApplicationEvent.class); - supportsEventType(true, method, getGenericApplicationEventType("applicationEvent")); + supportsEventType(true, method, ResolvableType.forClass(ApplicationEvent.class)); } @Test public void rawListenerWithGenericEvent() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleRaw", ApplicationEvent.class); - supportsEventType(true, method, getGenericApplicationEventType("stringEvent")); + supportsEventType(true, method, ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } @Test public void genericListener() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleGenericString", GenericTestEvent.class); - supportsEventType(true, method, getGenericApplicationEventType("stringEvent")); + supportsEventType(true, method, ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } @Test public void genericListenerWrongParameterizedType() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleGenericString", GenericTestEvent.class); - supportsEventType(false, method, getGenericApplicationEventType("longEvent")); + supportsEventType(false, method, ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class)); } @Test diff --git a/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java b/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java index 18bbae405218..4ef4fdee3960 100644 --- a/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -16,6 +16,8 @@ package org.springframework.context.event; +import java.io.IOException; + import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationEvent; @@ -51,7 +53,7 @@ public void supportsSourceTypeWithSmartApplicationListener() { @Test public void genericListenerStrictType() { - supportsEventType(true, StringEventListener.class, getGenericApplicationEventType("stringEvent")); + supportsEventType(true, StringEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } @Test // Demonstrates we can't inject that event because the generic type is lost @@ -83,7 +85,7 @@ public void genericListenerStrictTypeEventSubType() { @Test public void genericListenerStrictTypeNotMatching() { - supportsEventType(false, StringEventListener.class, getGenericApplicationEventType("longEvent")); + supportsEventType(false, StringEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class)); } @Test @@ -102,25 +104,25 @@ public void genericListenerStrictTypeNotMatchTypeErasure() { @Test public void genericListenerStrictTypeSubClass() { - supportsEventType(false, ObjectEventListener.class, getGenericApplicationEventType("longEvent")); + supportsEventType(false, ObjectEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class)); } @Test public void genericListenerUpperBoundType() { supportsEventType(true, UpperBoundEventListener.class, - getGenericApplicationEventType("illegalStateExceptionEvent")); + ResolvableType.forClassWithGenerics(GenericTestEvent.class, IllegalStateException.class)); } @Test public void genericListenerUpperBoundTypeNotMatching() { supportsEventType(false, UpperBoundEventListener.class, - getGenericApplicationEventType("ioExceptionEvent")); + ResolvableType.forClassWithGenerics(GenericTestEvent.class, IOException.class)); } @Test public void genericListenerWildcardType() { supportsEventType(true, GenericEventListener.class, - getGenericApplicationEventType("stringEvent")); + ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } @Test // Demonstrates we cant inject that event because the listener has a wildcard @@ -133,7 +135,7 @@ public void genericListenerWildcardTypeTypeErasure() { @Test public void genericListenerRawType() { supportsEventType(true, RawApplicationListener.class, - getGenericApplicationEventType("stringEvent")); + ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } @Test // Demonstrates we cant inject that event because the listener has a raw type From a31a4f8148fa1ea9003e35c3719896ddd5878200 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 10 Jan 2020 15:59:59 +0100 Subject: [PATCH 0297/2315] Copy strategiesConfigurers when cloning WebClient.Builder This commit fixes the missing `strategiesConfigurers` copy when the `WebClient.Builder` is cloned. Fixes gh-24329 --- .../client/DefaultWebClientBuilder.java | 3 ++- .../client/DefaultWebClientTests.java | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java index c255c439d326..dfd1087598b2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -114,6 +114,7 @@ public DefaultWebClientBuilder(DefaultWebClientBuilder other) { this.filters = other.filters != null ? new ArrayList<>(other.filters) : null; this.connector = other.connector; this.strategies = other.strategies; + this.strategiesConfigurers = other.strategiesConfigurers != null ? new ArrayList<>(other.strategiesConfigurers) : null; this.exchangeFunction = other.exchangeFunction; } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java index 7b4a06277413..61943fc0b5c7 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -20,6 +20,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.function.Consumer; import java.util.function.Predicate; import org.junit.jupiter.api.BeforeEach; @@ -36,6 +37,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.codec.ClientCodecConfigurer; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -231,6 +233,23 @@ public void mutateDoesCopy() { builder1a.defaultCookies(cookies -> assertThat(cookies.size()).isEqualTo(2)); } + @Test + void cloneBuilder() { + Consumer codecsConfig = c -> {}; + ExchangeFunction exchangeFunction = request -> Mono.empty(); + WebClient.Builder builder = WebClient.builder().baseUrl("https://example.org") + .exchangeFunction(exchangeFunction) + .filter((request, next) -> Mono.empty()) + .codecs(codecsConfig); + + WebClient.Builder clonedBuilder = builder.clone(); + + assertThat(clonedBuilder).extracting("baseUrl").isEqualTo("https://example.org"); + assertThat(clonedBuilder).extracting("filters").isNotNull(); + assertThat(clonedBuilder).extracting("strategiesConfigurers").isNotNull(); + assertThat(clonedBuilder).extracting("exchangeFunction").isEqualTo(exchangeFunction); + } + @Test public void withStringAttribute() { Map actual = new HashMap<>(); From cb8db1e6df7c375af2636a1a733f4de6caa8e818 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 10 Jan 2020 16:05:33 +0100 Subject: [PATCH 0298/2315] Polish Javadoc --- .../java/org/springframework/util/AntPathMatcher.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java index 0e5b1a91ae45..e8f8372e0306 100644 --- a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java +++ b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java @@ -614,14 +614,15 @@ else if (path1EndsWithSeparator || path2StartsWithSeparator) { /** * Given a full path, returns a {@link Comparator} suitable for sorting patterns in order of * explicitness. - *

    This{@code Comparator} will {@linkplain java.util.List#sort(Comparator) sort} - * a list so that more specific patterns (without uri templates or wild cards) come before - * generic patterns. So given a list with the following patterns: + *

    This {@code Comparator} will {@linkplain java.util.List#sort(Comparator) sort} + * a list so that more specific patterns (without URI templates or wild cards) come before + * generic patterns. So given a list with the following patterns, the returned comparator + * will sort this list so that the order will be as indicated. *

      *
    1. {@code /hotels/new}
    2. - *
    3. {@code /hotels/{hotel}}
    4. {@code /hotels/*}
    5. + *
    6. {@code /hotels/{hotel}}
    7. + *
    8. {@code /hotels/*}
    9. *
    - * the returned comparator will sort this list so that the order will be as indicated. *

    The full path given as parameter is used to test for exact matches. So when the given path * is {@code /hotels/2}, the pattern {@code /hotels/2} will be sorted before {@code /hotels/1}. * @param path the full path to use for comparison From 8396e6bdd1c03b2fb32e5cf468f7f04b192d8474 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 11 Jan 2020 13:11:17 +0100 Subject: [PATCH 0299/2315] Link to ADJT in the Eclipse Marketplace --- import-into-eclipse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/import-into-eclipse.md b/import-into-eclipse.md index e2175748ad61..42eda6eeaeed 100644 --- a/import-into-eclipse.md +++ b/import-into-eclipse.md @@ -23,7 +23,7 @@ _When instructed to execute `./gradlew` from the command line, be sure to execut 1. Switch to Groovy 2.5 (Preferences -> Groovy -> Compiler -> Switch to 2.5...) in Eclipse. 1. Change the _Forbidden reference (access rule)_ in Eclipse from Error to Warning (Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rule)). -1. Optionally install the [AspectJ Development Tools](https://www.eclipse.org/ajdt/downloads/) (_AJDT_) if you need to work with the `spring-aspects` project. Please note that as of January 2020, the AJDT _Development builds for Eclipse 4.10_ are known to work with versions of Eclipse greater than 4.10. For example, this has been tested with STS 4.5 (Eclipse 4.14). +1. Optionally install the [AspectJ Development Tools](https://marketplace.eclipse.org/content/aspectj-development-tools) (_AJDT_) if you need to work with the `spring-aspects` project. Please note that as of January 2020, the AspectJ Development Tools available in the Eclipse Marketplace are known to work with versions of Eclipse greater than 4.10 even though 4.10 may be listed as the last supported version. For example, this has been tested with STS 4.5 (Eclipse 4.14). 1. Optionally install the [TestNG plugin](https://testng.org/doc/eclipse.html) in Eclipse if you need to execute TestNG tests in the `spring-test` module. 1. Build `spring-oxm` from the command line with `./gradlew :spring-oxm:check`. 1. To apply project specific settings, run `./gradlew eclipseBuildship` from the command line. From bc7d01048579430b4b2df668178809b63d3f1929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Fri, 10 Jan 2020 14:51:55 +0100 Subject: [PATCH 0300/2315] Update CORS support This commit updates CORS support in order to check Origin header in CorsUtils#isPreFlightRequest which does not change how Spring MVC or WebFlux process CORS request but is more correct in term of behavior since it is a public API potentially used in another contexts. It also removes an unnecessary check in AbstractHandlerMethodMapping#hasCorsConfigurationSource and processes every preflight request with PreFlightHandler. Closes gh-24327 --- .../springframework/web/cors/CorsUtils.java | 8 +++--- .../web/cors/reactive/CorsUtils.java | 12 +++++---- .../handler/AbstractHandlerMapping.java | 6 ++--- .../method/AbstractHandlerMethodMapping.java | 5 ++-- .../handler/CorsUrlHandlerMappingTests.java | 4 +-- ...CrossOriginAnnotationIntegrationTests.java | 26 ++++++++++++++++++- .../handler/AbstractHandlerMapping.java | 4 +-- .../handler/AbstractHandlerMethodMapping.java | 5 ++-- .../CorsAbstractHandlerMappingTests.java | 5 ++-- .../method/annotation/CrossOriginTests.java | 25 +++++++++++++++++- 10 files changed, 74 insertions(+), 26 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/cors/CorsUtils.java b/spring-web/src/main/java/org/springframework/web/cors/CorsUtils.java index d24594cef060..eec489d6cc27 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/CorsUtils.java +++ b/spring-web/src/main/java/org/springframework/web/cors/CorsUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -66,12 +66,12 @@ else if ("https".equals(scheme) || "wss".equals(scheme)) { } /** - * Returns {@code true} if the request is a valid CORS pre-flight one. - * To be used in combination with {@link #isCorsRequest(HttpServletRequest)} since - * regular CORS checks are not invoked here for performance reasons. + * Returns {@code true} if the request is a valid CORS pre-flight one by checking {code OPTIONS} method with + * {@code Origin} and {@code Access-Control-Request-Method} headers presence. */ public static boolean isPreFlightRequest(HttpServletRequest request) { return (HttpMethod.OPTIONS.matches(request.getMethod()) && + request.getHeader(HttpHeaders.ORIGIN) != null && request.getHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD) != null); } diff --git a/spring-web/src/main/java/org/springframework/web/cors/reactive/CorsUtils.java b/spring-web/src/main/java/org/springframework/web/cors/reactive/CorsUtils.java index 006f32f684c3..a9f52082a5fe 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/reactive/CorsUtils.java +++ b/spring-web/src/main/java/org/springframework/web/cors/reactive/CorsUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -45,12 +45,14 @@ public static boolean isCorsRequest(ServerHttpRequest request) { } /** - * Returns {@code true} if the request is a valid CORS pre-flight one. - * To be used in combination with {@link #isCorsRequest(ServerHttpRequest)} since - * regular CORS checks are not invoked here for performance reasons. + * Returns {@code true} if the request is a valid CORS pre-flight one by checking {code OPTIONS} method with + * {@code Origin} and {@code Access-Control-Request-Method} headers presence. */ public static boolean isPreFlightRequest(ServerHttpRequest request) { - return (request.getMethod() == HttpMethod.OPTIONS && request.getHeaders().containsKey(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD)); + HttpHeaders headers = request.getHeaders(); + return (request.getMethod() == HttpMethod.OPTIONS + && headers.containsKey(HttpHeaders.ORIGIN) + && headers.containsKey(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD)); } /** diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/handler/AbstractHandlerMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/handler/AbstractHandlerMapping.java index 848249f976db..b3311348a67f 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/handler/AbstractHandlerMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/handler/AbstractHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -182,8 +182,8 @@ public Mono getHandler(ServerWebExchange exchange) { if (logger.isDebugEnabled()) { logger.debug(exchange.getLogPrefix() + "Mapped to " + handler); } - if (hasCorsConfigurationSource(handler)) { - ServerHttpRequest request = exchange.getRequest(); + ServerHttpRequest request = exchange.getRequest(); + if (hasCorsConfigurationSource(handler) || CorsUtils.isPreFlightRequest(request)) { CorsConfiguration config = (this.corsConfigurationSource != null ? this.corsConfigurationSource.getCorsConfiguration(exchange) : null); CorsConfiguration handlerConfig = getCorsConfiguration(handler, exchange); config = (config != null ? config.combine(handlerConfig) : handlerConfig); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java index bc7b46e41643..c7a65fc6236d 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -374,8 +374,7 @@ protected HandlerMethod handleNoMatch(Set mappings, ServerWebExchange exchang @Override protected boolean hasCorsConfigurationSource(Object handler) { return super.hasCorsConfigurationSource(handler) || - (handler instanceof HandlerMethod && this.mappingRegistry.getCorsConfiguration((HandlerMethod) handler) != null) || - handler.equals(PREFLIGHT_AMBIGUOUS_MATCH); + (handler instanceof HandlerMethod && this.mappingRegistry.getCorsConfiguration((HandlerMethod) handler) != null); } @Override diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java index b9385f0b9ceb..634233264552 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -70,7 +70,7 @@ public void preflightRequestWithoutCorsConfigurationProvider() throws Exception Object actual = this.handlerMapping.getHandler(exchange).block(); assertThat(actual).isNotNull(); - assertThat(actual).isSameAs(this.welcomeController); + assertThat(actual).isNotSameAs(this.welcomeController); } @Test diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java index f89c653109f9..93d08ce936c0 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -35,11 +35,13 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.config.EnableWebFlux; import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; /** * Integration tests with {@code @CrossOrigin} and {@code @RequestMapping} @@ -89,6 +91,28 @@ void actualGetRequestWithoutAnnotation(HttpServer httpServer) throws Exception { assertThat(entity.getBody()).isEqualTo("no"); } + @ParameterizedHttpServerTest + void optionsRequestWithAccessControlRequestMethod(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.clear(); + this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); + ResponseEntity entity = performOptions("/no", this.headers, String.class); + assertThat(entity.getBody()).isNull(); + } + + @ParameterizedHttpServerTest + void preflightRequestWithoutAnnotation(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); + try { + performOptions("/no", this.headers, Void.class); + fail("Preflight request without CORS configuration should fail"); + } + catch (HttpClientErrorException ex) { + assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN); + } + } + @ParameterizedHttpServerTest void actualPostRequestWithoutAnnotation(HttpServer httpServer) throws Exception { startServer(httpServer); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java index df7096c5239b..beee0ce55d3b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -414,7 +414,7 @@ else if (logger.isDebugEnabled() && !request.getDispatcherType().equals(Dispatch logger.debug("Mapped to " + executionChain.getHandler()); } - if (hasCorsConfigurationSource(handler)) { + if (hasCorsConfigurationSource(handler) || CorsUtils.isPreFlightRequest(request)) { CorsConfiguration config = (this.corsConfigurationSource != null ? this.corsConfigurationSource.getCorsConfiguration(request) : null); CorsConfiguration handlerConfig = getCorsConfiguration(handler, request); config = (config != null ? config.combine(handlerConfig) : handlerConfig); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java index 5a1c7ece0442..0fbfc988c1be 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -458,8 +458,7 @@ protected HandlerMethod handleNoMatch(Set mappings, String lookupPath, HttpSe @Override protected boolean hasCorsConfigurationSource(Object handler) { return super.hasCorsConfigurationSource(handler) || - (handler instanceof HandlerMethod && this.mappingRegistry.getCorsConfiguration((HandlerMethod) handler) != null) || - handler.equals(PREFLIGHT_AMBIGUOUS_MATCH); + (handler instanceof HandlerMethod && this.mappingRegistry.getCorsConfiguration((HandlerMethod) handler) != null); } @Override diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java index e3dc67c9ebfd..5a37e119c9d8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -86,7 +86,8 @@ void preflightRequestWithoutCorsConfigurationProvider() throws Exception { HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); assertThat(chain).isNotNull(); - assertThat(chain.getHandler()).isInstanceOf(SimpleHandler.class); + assertThat(chain.getHandler()).isNotNull(); + assertThat(chain.getHandler().getClass().getSimpleName()).isEqualTo("PreFlightHandler"); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java index 5934fa43d495..e135d7f76f92 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -69,6 +69,10 @@ public class CrossOriginTests { private final MockHttpServletRequest request = new MockHttpServletRequest(); + private final String optionsHandler = "org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping$HttpOptionsHandler#handle()"; + + private final String corsPreflightHandler = "org.springframework.web.servlet.handler.AbstractHandlerMapping$PreFlightHandler"; + @BeforeEach @SuppressWarnings("resource") @@ -96,6 +100,25 @@ public void noAnnotationWithoutOrigin() throws Exception { assertThat(getCorsConfiguration(chain, false)).isNull(); } + @Test + public void noAnnotationWithAccessControlRequestMethod() throws Exception { + this.handlerMapping.registerHandler(new MethodLevelController()); + MockHttpServletRequest request = new MockHttpServletRequest("OPTIONS", "/no"); + request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); + HandlerExecutionChain chain = this.handlerMapping.getHandler(request); + assertThat(chain.getHandler().toString()).isEqualTo(optionsHandler); + } + + @Test + public void noAnnotationWithPreflightRequest() throws Exception { + this.handlerMapping.registerHandler(new MethodLevelController()); + MockHttpServletRequest request = new MockHttpServletRequest("OPTIONS", "/no"); + request.addHeader(HttpHeaders.ORIGIN, "https://domain.com/"); + request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); + HandlerExecutionChain chain = this.handlerMapping.getHandler(request); + assertThat(chain.getHandler().getClass().getName()).isEqualTo(corsPreflightHandler); + } + @Test // SPR-12931 public void noAnnotationWithOrigin() throws Exception { this.handlerMapping.registerHandler(new MethodLevelController()); From 6747cc135375f4eb5772207d01aab658a5ebed8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Mon, 13 Jan 2020 10:05:17 +0100 Subject: [PATCH 0301/2315] Make WebTestClientExtensions.expectBody generics compliant Closes gh-24142 --- .../test/web/reactive/server/WebTestClientExtensions.kt | 4 ++-- .../test/web/reactive/server/WebTestClientExtensionsTests.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt b/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt index fd0dd0b794af..d7277f9d36fd 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -68,7 +68,7 @@ inline fun RequestBodySpec.body(flow: Flow): RequestHeaders */ @Suppress("EXTENSION_SHADOWED_BY_MEMBER") inline fun ResponseSpec.expectBody(): KotlinBodySpec = - expectBody(B::class.java).returnResult().let { + expectBody(object : ParameterizedTypeReference() {}).returnResult().let { object : KotlinBodySpec { override fun isEqualTo(expected: B): KotlinBodySpec = it diff --git a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt index e59069c3f290..cac68a1b55a4 100644 --- a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt +++ b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -62,7 +62,7 @@ class WebTestClientExtensionsTests { @Test fun `ResponseSpec#expectBody with reified type parameters`() { responseSpec.expectBody() - verify { responseSpec.expectBody(Foo::class.java) } + verify { responseSpec.expectBody(object : ParameterizedTypeReference() {}) } } @Test From 0801a7d7e4d3ffbc50cfe99a009d75983d966ddd Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 13 Jan 2020 10:40:01 +0100 Subject: [PATCH 0302/2315] Upgrade to RxJava 2.2.17, OkHttp 3.14.6, Jetty Reactive HttpClient 1.1.1 --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index c282759e8ff9..cfc486f8e032 100644 --- a/build.gradle +++ b/build.gradle @@ -69,7 +69,7 @@ configure(allprojects) { project -> dependency "io.reactivex:rxjava:1.3.8" dependency "io.reactivex:rxjava-reactive-streams:1.2.1" - dependency "io.reactivex.rxjava2:rxjava:2.2.16" + dependency "io.reactivex.rxjava2:rxjava:2.2.17" dependency "com.caucho:hessian:4.0.62" dependency "com.fasterxml:aalto-xml:1.2.2" @@ -150,7 +150,7 @@ configure(allprojects) { project -> } } - dependencySet(group: 'com.squareup.okhttp3', version: '3.14.5') { + dependencySet(group: 'com.squareup.okhttp3', version: '3.14.6') { entry 'okhttp' entry 'mockwebserver' } @@ -160,7 +160,7 @@ configure(allprojects) { project -> dependency("org.apache.httpcomponents:httpasyncclient:4.1.4") { exclude group: "commons-logging", name: "commons-logging" } - dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.0.3" + dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.1.1" dependency "org.jruby:jruby:9.2.9.0" dependency "org.python:jython-standalone:2.7.1" From 3f1882c4eb2ec7a749555d0b7ef05e1262e35447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Mon, 13 Jan 2020 10:51:19 +0100 Subject: [PATCH 0303/2315] Support noarg callable references in Kotlin beans DSL Closes gh-23395 --- .../context/support/BeanDefinitionDsl.kt | 36 +++++++++++++++++++ .../context/support/BeanDefinitionDslTests.kt | 4 ++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/spring-context/src/main/kotlin/org/springframework/context/support/BeanDefinitionDsl.kt b/spring-context/src/main/kotlin/org/springframework/context/support/BeanDefinitionDsl.kt index 19bf94c0384c..a2c9773e2335 100644 --- a/spring-context/src/main/kotlin/org/springframework/context/support/BeanDefinitionDsl.kt +++ b/spring-context/src/main/kotlin/org/springframework/context/support/BeanDefinitionDsl.kt @@ -236,6 +236,42 @@ open class BeanDefinitionDsl internal constructor (private val init: BeanDefinit context.registerBean(beanName, T::class.java, Supplier { function.invoke(BeanSupplierContext(context)) }, customizer) } + /** + * Declare a bean definition using the given callable reference with no parameter + * for obtaining a new instance. + * + * @param f the callable reference + * @param name the name of the bean + * @param scope Override the target scope of this bean, specifying a new scope name. + * @param isLazyInit Set whether this bean should be lazily initialized. + * @param isPrimary Set whether this bean is a primary autowire candidate. + * @param isAutowireCandidate Set whether this bean is a candidate for getting + * autowired into some other bean. + * @param initMethodName Set the name of the initializer method + * @param destroyMethodName Set the name of the destroy method + * @param description Set a human-readable description of this bean definition + * @param role Set the role hint for this bean definition + * @see GenericApplicationContext.registerBean + * @see org.springframework.beans.factory.config.BeanDefinition + * @since 5.2.3 + */ + inline fun + bean(crossinline f: () -> T, + name: String? = null, + scope: BeanDefinitionDsl.Scope? = null, + isLazyInit: Boolean? = null, + isPrimary: Boolean? = null, + isAutowireCandidate: Boolean? = null, + initMethodName: String? = null, + destroyMethodName: String? = null, + description: String? = null, + role: BeanDefinitionDsl.Role? = null) { + + bean(name, scope, isLazyInit, isPrimary, isAutowireCandidate, initMethodName, destroyMethodName, description, role) { + f.invoke() + } + } + /** * Declare a bean definition using the given callable reference with 1 parameter * autowired by type for obtaining a new instance. diff --git a/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt b/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt index cc315fcddecd..5ac22c8d64f6 100644 --- a/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -156,6 +156,7 @@ class BeanDefinitionDslTests { val beans = beans { bean() bean(::baz) + bean(::foo) } val context = GenericApplicationContext().apply { beans.initialize(this) @@ -205,3 +206,4 @@ class FooFoo(val name: String) class BarBar(val foos: Collection) fun baz(bar: Bar) = Baz(bar) +fun foo() = Foo() From 798744838c6cc96c5989cc6ed5944e7dfe8f2cc3 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 13 Jan 2020 12:51:31 +0100 Subject: [PATCH 0304/2315] Revise exception handling in AbstractEmbeddedDatabaseConfigurer See gh-24337 --- .../AbstractEmbeddedDatabaseConfigurer.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java index 82816ba95392..05a8321ca7f3 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -25,6 +25,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.jdbc.support.JdbcUtils; + /** * Base class for {@link EmbeddedDatabaseConfigurer} implementations * providing common shutdown behavior through a "SHUTDOWN" statement. @@ -53,14 +55,7 @@ public void shutdown(DataSource dataSource, String databaseName) { logger.info("Could not shut down embedded database", ex); } finally { - if (con != null) { - try { - con.close(); - } - catch (Throwable ex) { - logger.debug("Could not close JDBC Connection on shutdown", ex); - } - } + JdbcUtils.closeConnection(con); } } From a566083a073428c452a090b1284753ddd7b49ae8 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 13 Jan 2020 13:16:50 +0100 Subject: [PATCH 0305/2315] Update ASM and CBLIB versions in license.txt --- src/docs/dist/license.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/docs/dist/license.txt b/src/docs/dist/license.txt index 1a517dfdf79b..643d4d8709a3 100644 --- a/src/docs/dist/license.txt +++ b/src/docs/dist/license.txt @@ -212,7 +212,7 @@ code for these subcomponents is subject to the terms and conditions of the following licenses. ->>> ASM 4.0 (org.ow2.asm:asm:4.0, org.ow2.asm:asm-commons:4.0): +>>> ASM 7.1 (org.ow2.asm:asm:7.1, org.ow2.asm:asm-commons:7.1): Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. @@ -247,11 +247,11 @@ THE POSSIBILITY OF SUCH DAMAGE. Copyright (c) 1999-2009, OW2 Consortium ->>> CGLIB 3.0 (cglib:cglib:3.0): +>>> CGLIB 3.3 (cglib:cglib:3.3): Per the LICENSE file in the CGLIB JAR distribution downloaded from -https://sourceforge.net/projects/cglib/files/cglib3/3.0/cglib-3.0.jar/download, -CGLIB 3.0 is licensed under the Apache License, version 2.0, the text of which +https://github.com/cglib/cglib/releases/download/RELEASE_3_3_0/cglib-3.3.0.jar, +CGLIB 3.3 is licensed under the Apache License, version 2.0, the text of which is included above. From 850cbf032bf763f6f648a3d621cd56d94171b81a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 13 Jan 2020 14:41:52 +0100 Subject: [PATCH 0306/2315] Document Objenesis license in license.txt Closes gh-24340 --- src/docs/dist/license.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/docs/dist/license.txt b/src/docs/dist/license.txt index 643d4d8709a3..8d2de8d0d44d 100644 --- a/src/docs/dist/license.txt +++ b/src/docs/dist/license.txt @@ -255,6 +255,13 @@ CGLIB 3.3 is licensed under the Apache License, version 2.0, the text of which is included above. +>>> Objenesis 3.1 (org.objenesis:objenesis:3.1): + +Per the LICENSE file in the Objenesis ZIP distribution downloaded from +http://objenesis.org/download.html, Objenesis 3.1 is licensed under the +Apache License, version 2.0, the text of which is included above. + + =============================================================================== To the extent any open source components are licensed under the EPL and/or From a741ae422b75e330dac655718ad91e0067a2caeb Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 13 Jan 2020 14:55:29 +0000 Subject: [PATCH 0307/2315] Improve limit handling in StringDecoder The case of one data buffer containing multiple lines can could cause a buffer leak due to a suspected issue in concatMapIterable. This commit adds workarounds for that until the underlying issue is addressed. Closes gh-24339 --- .../core/codec/StringDecoder.java | 132 ++++++++++++------ .../core/codec/StringDecoderTests.java | 31 ++-- 2 files changed, 109 insertions(+), 54 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java b/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java index 2fa3cf0a4056..abbe66a3b3b0 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -94,20 +94,44 @@ public Flux decode(Publisher input, ResolvableType elementTy byte[][] delimiterBytes = getDelimiterBytes(mimeType); - // TODO: Drop Consumer and use bufferUntil with Supplier (reactor-core#1925) - // TODO: Drop doOnDiscard(LimitedDataBufferList.class, ...) (reactor-core#1924) - LimitedDataBufferConsumer limiter = new LimitedDataBufferConsumer(getMaxInMemorySize()); - Flux inputFlux = Flux.defer(() -> { DataBufferUtils.Matcher matcher = DataBufferUtils.matcher(delimiterBytes); - return Flux.from(input) - .concatMapIterable(buffer -> endFrameAfterDelimiter(buffer, matcher)) - .doOnNext(limiter) - .bufferUntil(buffer -> buffer instanceof EndFrameBuffer) - .map(buffers -> joinAndStrip(buffers, this.stripDelimiter)) - .doOnDiscard(LimitedDataBufferList.class, LimitedDataBufferList::releaseAndClear) - .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release); + if (getMaxInMemorySize() != -1) { + + // Passing limiter into endFrameAfterDelimiter helps to ensure that in case of one DataBuffer + // containing multiple lines, the limit is checked and raised immediately without accumulating + // subsequent lines. This is necessary because concatMapIterable doesn't respect doOnDiscard. + // When reactor-core#1925 is resolved, we could replace bufferUntil with: + + // .windowUntil(buffer -> buffer instanceof EndFrameBuffer) + // .concatMap(fluxes -> fluxes.collect(() -> new LimitedDataBufferList(getMaxInMemorySize()), LimitedDataBufferList::add)) + + LimitedDataBufferList limiter = new LimitedDataBufferList(getMaxInMemorySize()); + + return Flux.from(input) + .concatMapIterable(buffer -> endFrameAfterDelimiter(buffer, matcher, limiter)) + .bufferUntil(buffer -> buffer instanceof EndFrameBuffer) + .map(buffers -> joinAndStrip(buffers, this.stripDelimiter)) + .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release); + } + else { + // When the decoder is unlimited (-1), concatMapIterable will cache buffers that may not + // be released if cancel is signalled before they are turned into String lines + // (see test maxInMemoryLimitReleasesUnprocessedLinesWhenUnlimited). + // When reactor-core#1925 is resolved, the workaround can be removed and the entire + // else clause possibly dropped. + + ConcatMapIterableDiscardWorkaroundCache cache = new ConcatMapIterableDiscardWorkaroundCache(); + + return Flux.from(input) + .concatMapIterable(buffer -> cache.addAll(endFrameAfterDelimiter(buffer, matcher, null))) + .doOnNext(cache) + .doOnCancel(cache) + .bufferUntil(buffer -> buffer instanceof EndFrameBuffer) + .map(buffers -> joinAndStrip(buffers, this.stripDelimiter)) + .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release); + } }); return super.decode(inputFlux, elementType, mimeType, hints); @@ -152,29 +176,49 @@ private static Charset getCharset(@Nullable MimeType mimeType) { * * @param dataBuffer the buffer to find delimiters in * @param matcher used to find the first delimiters + * @param limiter to enforce maxInMemorySize with * @return a flux of buffers, containing {@link EndFrameBuffer} after each delimiter that was * found in {@code dataBuffer}. Returns Flux, because returning List (w/ flatMapIterable) * results in memory leaks due to pre-fetching. */ - private static List endFrameAfterDelimiter(DataBuffer dataBuffer, DataBufferUtils.Matcher matcher) { + private static List endFrameAfterDelimiter( + DataBuffer dataBuffer, DataBufferUtils.Matcher matcher, @Nullable LimitedDataBufferList limiter) { + List result = new ArrayList<>(); - do { - int endIdx = matcher.match(dataBuffer); - if (endIdx != -1) { - int readPosition = dataBuffer.readPosition(); - int length = endIdx - readPosition + 1; - result.add(dataBuffer.retainedSlice(readPosition, length)); - result.add(new EndFrameBuffer(matcher.delimiter())); - dataBuffer.readPosition(endIdx + 1); + try { + do { + int endIdx = matcher.match(dataBuffer); + if (endIdx != -1) { + int readPosition = dataBuffer.readPosition(); + int length = (endIdx - readPosition + 1); + DataBuffer slice = dataBuffer.retainedSlice(readPosition, length); + result.add(slice); + result.add(new EndFrameBuffer(matcher.delimiter())); + dataBuffer.readPosition(endIdx + 1); + if (limiter != null) { + limiter.add(slice); // enforce the limit + limiter.clear(); + } + } + else { + result.add(DataBufferUtils.retain(dataBuffer)); + if (limiter != null) { + limiter.add(dataBuffer); + } + break; + } } - else { - result.add(DataBufferUtils.retain(dataBuffer)); - break; + while (dataBuffer.readableByteCount() > 0); + } + catch (DataBufferLimitException ex) { + if (limiter != null) { + limiter.releaseAndClear(); } + throw ex; + } + finally { + DataBufferUtils.release(dataBuffer); } - while (dataBuffer.readableByteCount() > 0); - - DataBufferUtils.release(dataBuffer); return result; } @@ -288,34 +332,32 @@ public byte[] delimiter() { } - /** - * Temporary measure for reactor-core#1925. - * Consumer that adds to a {@link LimitedDataBufferList} to enforce limits. - */ - private static class LimitedDataBufferConsumer implements Consumer { + private class ConcatMapIterableDiscardWorkaroundCache implements Consumer, Runnable { - private final LimitedDataBufferList bufferList; + private final List buffers = new ArrayList<>(); - public LimitedDataBufferConsumer(int maxInMemorySize) { - this.bufferList = new LimitedDataBufferList(maxInMemorySize); + public List addAll(List buffersToAdd) { + this.buffers.addAll(buffersToAdd); + return buffersToAdd; } + @Override + public void accept(DataBuffer dataBuffer) { + this.buffers.remove(dataBuffer); + } @Override - public void accept(DataBuffer buffer) { - if (buffer instanceof EndFrameBuffer) { - this.bufferList.clear(); - } - else { + public void run() { + this.buffers.forEach(buffer -> { try { - this.bufferList.add(buffer); - } - catch (DataBufferLimitException ex) { DataBufferUtils.release(buffer); - throw ex; } - } + catch (Throwable ex) { + // Keep going.. + } + }); } } + } diff --git a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java index 0d3d29ceef55..fad7a1ec102c 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -130,17 +130,30 @@ void decodeNewLine() { } @Test - void decodeNewLineWithLimit() { + void maxInMemoryLimit() { Flux input = Flux.just( - stringBuffer("abc\n"), - stringBuffer("defg\n"), - stringBuffer("hijkl\n") - ); - this.decoder.setMaxInMemorySize(5); + stringBuffer("abc\n"), stringBuffer("defg\n"), stringBuffer("hijkl\n")); + this.decoder.setMaxInMemorySize(5); testDecode(input, String.class, step -> - step.expectNext("abc", "defg") - .verifyError(DataBufferLimitException.class)); + step.expectNext("abc", "defg").verifyError(DataBufferLimitException.class)); + } + + @Test // gh-24312 + void maxInMemoryLimitReleaseUnprocessedLinesFromCurrentBuffer() { + Flux input = Flux.just( + stringBuffer("TOO MUCH DATA\nanother line\n\nand another\n")); + + this.decoder.setMaxInMemorySize(5); + testDecode(input, String.class, step -> step.verifyError(DataBufferLimitException.class)); + } + + @Test // gh-24339 + void maxInMemoryLimitReleaseUnprocessedLinesWhenUnlimited() { + Flux input = Flux.just(stringBuffer("Line 1\nLine 2\nLine 3\n")); + + this.decoder.setMaxInMemorySize(-1); + testDecodeCancel(input, ResolvableType.forClass(String.class), null, Collections.emptyMap()); } @Test From cbc57460b7d8316c8bfd748962e37691a6a64f8b Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 13 Jan 2020 14:56:48 +0000 Subject: [PATCH 0308/2315] Support for maxInMemorySize in SSE reader Closes gh-24312 --- .../io/buffer/DataBufferLimitException.java | 2 +- .../ServerSentEventHttpMessageReader.java | 76 +++++++++++++++++-- .../http/codec/support/BaseDefaultCodecs.java | 9 ++- ...ServerSentEventHttpMessageReaderTests.java | 76 +++++++++++++++---- .../support/ClientCodecConfigurerTests.java | 1 + 5 files changed, 138 insertions(+), 26 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferLimitException.java b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferLimitException.java index ee606aed57f0..c03839056bb3 100644 --- a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferLimitException.java +++ b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferLimitException.java @@ -21,7 +21,7 @@ * This can be raised when data buffers are cached and aggregated, e.g. * {@link DataBufferUtils#join}. Or it could also be raised when data buffers * have been released but a parsed representation is being aggregated, e.g. async - * parsing with Jackson. + * parsing with Jackson, SSE parsing and aggregating lines per event. * * @author Rossen Stoyanchev * @since 5.1.11 diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java index a6de190d5104..7677c48ebfc9 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -31,6 +31,7 @@ import org.springframework.core.codec.StringDecoder; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; +import org.springframework.core.io.buffer.DataBufferLimitException; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpInputMessage; @@ -48,14 +49,16 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader decoder; + private final StringDecoder lineDecoder = StringDecoder.textPlainOnly(); + + + /** * Constructor without a {@code Decoder}. In this mode only {@code String} @@ -82,6 +85,29 @@ public Decoder getDecoder() { return this.decoder; } + /** + * Configure a limit on the maximum number of bytes per SSE event which are + * buffered before the event is parsed. + *

    Note that the {@link #getDecoder() data decoder}, if provided, must + * also be customized accordingly to raise the limit if necessary in order + * to be able to parse the data portion of the event. + *

    By default this is set to 256K. + * @param byteCount the max number of bytes to buffer, or -1 for unlimited + * @since 5.1.13 + */ + public void setMaxInMemorySize(int byteCount) { + this.lineDecoder.setMaxInMemorySize(byteCount); + } + + /** + * Return the {@link #setMaxInMemorySize configured} byte count limit. + * @since 5.1.13 + */ + public int getMaxInMemorySize() { + return this.lineDecoder.getMaxInMemorySize(); + } + + @Override public List getReadableMediaTypes() { return Collections.singletonList(MediaType.TEXT_EVENT_STREAM); @@ -101,12 +127,15 @@ private boolean isServerSentEvent(ResolvableType elementType) { public Flux read( ResolvableType elementType, ReactiveHttpInputMessage message, Map hints) { + LimitTracker limitTracker = new LimitTracker(); + boolean shouldWrap = isServerSentEvent(elementType); ResolvableType valueType = (shouldWrap ? elementType.getGeneric() : elementType); - return stringDecoder.decode(message.getBody(), STRING_TYPE, null, hints) + return this.lineDecoder.decode(message.getBody(), STRING_TYPE, null, hints) + .doOnNext(limitTracker::afterLineParsed) .bufferUntil(String::isEmpty) - .concatMap(lines -> Mono.justOrEmpty(buildEvent(lines, valueType, shouldWrap, hints))); + .map(lines -> buildEvent(lines, valueType, shouldWrap, hints)); } @Nullable @@ -172,16 +201,47 @@ private Object decodeData(String data, ResolvableType dataType, Map readMono( ResolvableType elementType, ReactiveHttpInputMessage message, Map hints) { - // We're ahead of String + "*/*" - // Let's see if we can aggregate the output (lest we time out)... + // In order of readers, we're ahead of String + "*/*" + // If this is called, simply delegate to StringDecoder if (elementType.resolve() == String.class) { Flux body = message.getBody(); - return stringDecoder.decodeToMono(body, elementType, null, null).cast(Object.class); + return this.lineDecoder.decodeToMono(body, elementType, null, null).cast(Object.class); } return Mono.error(new UnsupportedOperationException( "ServerSentEventHttpMessageReader only supports reading stream of events as a Flux")); } + + private class LimitTracker { + + private int accumulated = 0; + + + public void afterLineParsed(String line) { + if (getMaxInMemorySize() < 0) { + return; + } + if (line.isEmpty()) { + this.accumulated = 0; + } + if (line.length() > Integer.MAX_VALUE - this.accumulated) { + raiseLimitException(); + } + else { + this.accumulated += line.length(); + if (this.accumulated > getMaxInMemorySize()) { + raiseLimitException(); + } + } + } + + private void raiseLimitException() { + // Do not release here, it's likely down via doOnDiscard.. + throw new DataBufferLimitException( + "Exceeded limit on max bytes to buffer : " + getMaxInMemorySize()); + } + } + } diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java index 72ac98593957..186267838897 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -238,9 +238,6 @@ private void initCodec(@Nullable Object codec) { if (codec instanceof DecoderHttpMessageReader) { codec = ((DecoderHttpMessageReader) codec).getDecoder(); } - else if (codec instanceof ServerSentEventHttpMessageReader) { - codec = ((ServerSentEventHttpMessageReader) codec).getDecoder(); - } if (codec == null) { return; @@ -269,6 +266,10 @@ else if (codec instanceof ServerSentEventHttpMessageReader) { if (codec instanceof FormHttpMessageReader) { ((FormHttpMessageReader) codec).setMaxInMemorySize(size); } + if (codec instanceof ServerSentEventHttpMessageReader) { + ((ServerSentEventHttpMessageReader) codec).setMaxInMemorySize(size); + initCodec(((ServerSentEventHttpMessageReader) codec).getDecoder()); + } if (synchronossMultipartPresent) { if (codec instanceof SynchronossPartHttpMessageReader) { ((SynchronossPartHttpMessageReader) codec).setMaxInMemorySize(size); diff --git a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java index 01d9a34376fb..c5a5983f07b6 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -27,6 +27,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.io.buffer.DataBufferLimitException; import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests; import org.springframework.http.MediaType; import org.springframework.http.codec.json.Jackson2JsonDecoder; @@ -42,20 +43,21 @@ */ public class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingTests { - private ServerSentEventHttpMessageReader messageReader = - new ServerSentEventHttpMessageReader(new Jackson2JsonDecoder()); + private Jackson2JsonDecoder jsonDecoder = new Jackson2JsonDecoder(); + + private ServerSentEventHttpMessageReader reader = new ServerSentEventHttpMessageReader(this.jsonDecoder); @Test public void cantRead() { - assertThat(messageReader.canRead(ResolvableType.forClass(Object.class), new MediaType("foo", "bar"))).isFalse(); - assertThat(messageReader.canRead(ResolvableType.forClass(Object.class), null)).isFalse(); + assertThat(reader.canRead(ResolvableType.forClass(Object.class), new MediaType("foo", "bar"))).isFalse(); + assertThat(reader.canRead(ResolvableType.forClass(Object.class), null)).isFalse(); } @Test public void canRead() { - assertThat(messageReader.canRead(ResolvableType.forClass(Object.class), new MediaType("text", "event-stream"))).isTrue(); - assertThat(messageReader.canRead(ResolvableType.forClass(ServerSentEvent.class), new MediaType("foo", "bar"))).isTrue(); + assertThat(reader.canRead(ResolvableType.forClass(Object.class), new MediaType("text", "event-stream"))).isTrue(); + assertThat(reader.canRead(ResolvableType.forClass(ServerSentEvent.class), new MediaType("foo", "bar"))).isTrue(); } @Test @@ -66,7 +68,7 @@ public void readServerSentEvents() { "id:c42\nevent:foo\nretry:123\n:bla\n:bla bla\n:bla bla bla\ndata:bar\n\n" + "id:c43\nevent:bar\nretry:456\ndata:baz\n\n"))); - Flux events = this.messageReader + Flux events = this.reader .read(ResolvableType.forClassWithGenerics(ServerSentEvent.class, String.class), request, Collections.emptyMap()).cast(ServerSentEvent.class); @@ -98,7 +100,7 @@ public void readServerSentEventsWithMultipleChunks() { stringBuffer("ent:foo\nretry:123\n:bla\n:bla bla\n:bla bla bla\ndata:"), stringBuffer("bar\n\nid:c43\nevent:bar\nretry:456\ndata:baz\n\n"))); - Flux events = messageReader + Flux events = reader .read(ResolvableType.forClassWithGenerics(ServerSentEvent.class, String.class), request, Collections.emptyMap()).cast(ServerSentEvent.class); @@ -126,7 +128,7 @@ public void readString() { MockServerHttpRequest request = MockServerHttpRequest.post("/") .body(Mono.just(stringBuffer("data:foo\ndata:bar\n\ndata:baz\n\n"))); - Flux data = messageReader.read(ResolvableType.forClass(String.class), + Flux data = reader.read(ResolvableType.forClass(String.class), request, Collections.emptyMap()).cast(String.class); StepVerifier.create(data) @@ -143,7 +145,7 @@ public void readPojo() { "data:{\"foo\": \"foofoo\", \"bar\": \"barbar\"}\n\n" + "data:{\"foo\": \"foofoofoo\", \"bar\": \"barbarbar\"}\n\n"))); - Flux data = messageReader.read(ResolvableType.forClass(Pojo.class), request, + Flux data = reader.read(ResolvableType.forClass(Pojo.class), request, Collections.emptyMap()).cast(Pojo.class); StepVerifier.create(data) @@ -165,7 +167,7 @@ public void decodeFullContentAsString() { MockServerHttpRequest request = MockServerHttpRequest.post("/") .body(Mono.just(stringBuffer(body))); - String actual = messageReader + String actual = reader .readMono(ResolvableType.forClass(String.class), request, Collections.emptyMap()) .cast(String.class) .block(Duration.ZERO); @@ -182,7 +184,7 @@ public void readError() { MockServerHttpRequest request = MockServerHttpRequest.post("/") .body(body); - Flux data = messageReader.read(ResolvableType.forClass(String.class), + Flux data = reader.read(ResolvableType.forClass(String.class), request, Collections.emptyMap()).cast(String.class); StepVerifier.create(data) @@ -192,6 +194,54 @@ public void readError() { .verify(); } + @Test + public void maxInMemoryLimit() { + + this.reader.setMaxInMemorySize(17); + + MockServerHttpRequest request = MockServerHttpRequest.post("/") + .body(Flux.just(stringBuffer("data:\"TOO MUCH DATA\"\ndata:bar\n\ndata:baz\n\n"))); + + Flux data = this.reader.read(ResolvableType.forClass(String.class), + request, Collections.emptyMap()).cast(String.class); + + StepVerifier.create(data) + .expectError(DataBufferLimitException.class) + .verify(); + } + + @Test // gh-24312 + public void maxInMemoryLimitAllowsReadingPojoLargerThanDefaultSize() { + + int limit = this.jsonDecoder.getMaxInMemorySize(); + + String fooValue = getStringOfSize(limit) + "and then some more"; + String content = "data:{\"foo\": \"" + fooValue + "\"}\n\n"; + MockServerHttpRequest request = MockServerHttpRequest.post("/").body(Mono.just(stringBuffer(content))); + + Jackson2JsonDecoder jacksonDecoder = new Jackson2JsonDecoder(); + ServerSentEventHttpMessageReader messageReader = new ServerSentEventHttpMessageReader(jacksonDecoder); + + jacksonDecoder.setMaxInMemorySize(limit + 1024); + messageReader.setMaxInMemorySize(limit + 1024); + + Flux data = messageReader.read(ResolvableType.forClass(Pojo.class), request, + Collections.emptyMap()).cast(Pojo.class); + + StepVerifier.create(data) + .consumeNextWith(pojo -> assertThat(pojo.getFoo()).isEqualTo(fooValue)) + .expectComplete() + .verify(); + } + + private static String getStringOfSize(long size) { + StringBuilder content = new StringBuilder("Aa"); + while (content.length() < size) { + content.append(content); + } + return content.toString(); + } + private DataBuffer stringBuffer(String value) { byte[] bytes = value.getBytes(StandardCharsets.UTF_8); DataBuffer buffer = this.bufferFactory.allocateBuffer(bytes.length); diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java index ca119d5de7e4..fce509efbb8a 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java @@ -140,6 +140,7 @@ public void maxInMemorySize() { assertThat(((Jaxb2XmlDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); ServerSentEventHttpMessageReader reader = (ServerSentEventHttpMessageReader) nextReader(readers); + assertThat(reader.getMaxInMemorySize()).isEqualTo(size); assertThat(((Jackson2JsonDecoder) reader.getDecoder()).getMaxInMemorySize()).isEqualTo(size); assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size); From c84dd55863c4d872fef4f4334fd94051d266490a Mon Sep 17 00:00:00 2001 From: Qimiao Chen Date: Mon, 13 Jan 2020 23:27:05 +0800 Subject: [PATCH 0309/2315] Fix typo in ReflectionUtilsTests Closes gh-24344 --- .../java/org/springframework/util/ReflectionUtilsTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java index f9ed283756bd..b1e5908c647b 100644 --- a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java @@ -362,7 +362,7 @@ void m95() { } void m96() { } void m97() { } void m98() { } void m99() { } } @Test - void getDecalredMethodsReturnsCopy() { + void getDeclaredMethodsReturnsCopy() { Method[] m1 = ReflectionUtils.getDeclaredMethods(A.class); Method[] m2 = ReflectionUtils.getDeclaredMethods(A.class); assertThat(m1). isNotSameAs(m2); From 33ffdd865d90d935d36c43e38797370bd6422842 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 13 Jan 2020 16:29:23 +0100 Subject: [PATCH 0310/2315] Update copyright date --- .../java/org/springframework/util/ReflectionUtilsTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java index b1e5908c647b..f3ceaaffdead 100644 --- a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. From 8a6086774f4fa1d1713d66494879cb32969c9140 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 13 Jan 2020 17:15:27 +0100 Subject: [PATCH 0311/2315] Polishing regarding AJDT versions --- import-into-eclipse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/import-into-eclipse.md b/import-into-eclipse.md index 42eda6eeaeed..bb665d788a13 100644 --- a/import-into-eclipse.md +++ b/import-into-eclipse.md @@ -23,7 +23,7 @@ _When instructed to execute `./gradlew` from the command line, be sure to execut 1. Switch to Groovy 2.5 (Preferences -> Groovy -> Compiler -> Switch to 2.5...) in Eclipse. 1. Change the _Forbidden reference (access rule)_ in Eclipse from Error to Warning (Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rule)). -1. Optionally install the [AspectJ Development Tools](https://marketplace.eclipse.org/content/aspectj-development-tools) (_AJDT_) if you need to work with the `spring-aspects` project. Please note that as of January 2020, the AspectJ Development Tools available in the Eclipse Marketplace are known to work with versions of Eclipse greater than 4.10 even though 4.10 may be listed as the last supported version. For example, this has been tested with STS 4.5 (Eclipse 4.14). +1. Optionally install the [AspectJ Development Tools](https://marketplace.eclipse.org/content/aspectj-development-tools) (_AJDT_) if you need to work with the `spring-aspects` project. The AspectJ Development Tools available in the Eclipse Marketplace have been tested with these instructions using STS 4.5 (Eclipse 4.14). 1. Optionally install the [TestNG plugin](https://testng.org/doc/eclipse.html) in Eclipse if you need to execute TestNG tests in the `spring-test` module. 1. Build `spring-oxm` from the command line with `./gradlew :spring-oxm:check`. 1. To apply project specific settings, run `./gradlew eclipseBuildship` from the command line. From 29fe65d23c01ce60bc34141990accb3454eca621 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 13 Jan 2020 16:37:19 +0000 Subject: [PATCH 0312/2315] Upgrade to Dysprosium snapshots See gh-24349 --- build.gradle | 3 ++- .../http/server/reactive/ErrorHandlerIntegrationTests.java | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index cfc486f8e032..02f7e4d8fc3c 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ configure(allprojects) { project -> imports { mavenBom "com.fasterxml.jackson:jackson-bom:2.10.2" mavenBom "io.netty:netty-bom:4.1.44.Final" - mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR2" + mavenBom "io.projectreactor:reactor-bom:Dysprosium-BUILD-SNAPSHOT" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" mavenBom "org.eclipse.jetty:jetty-bom:9.4.25.v20191220" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.61" @@ -286,6 +286,7 @@ configure(allprojects) { project -> } repositories { mavenCentral() + maven { url "https://repo.spring.io/snapshot" } // Reactor Dysprosium snapshots maven { url "https://repo.spring.io/libs-spring-framework-build" } } } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java index 3e58088cd5e7..41113324e70f 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java @@ -18,6 +18,8 @@ import java.net.URI; +import org.junit.Assume; +import org.junit.jupiter.api.Assumptions; import reactor.core.publisher.Mono; import org.springframework.http.HttpStatus; @@ -27,6 +29,7 @@ import org.springframework.web.client.RestTemplate; import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.ReactorHttpServer; import static org.assertj.core.api.Assertions.assertThat; @@ -72,6 +75,10 @@ void handlingError(HttpServer httpServer) throws Exception { @ParameterizedHttpServerTest // SPR-15560 void emptyPathSegments(HttpServer httpServer) throws Exception { + + /* Temporarily necessary for https://github.com/reactor/reactor-netty/issues/948 */ + Assumptions.assumeFalse(httpServer instanceof ReactorHttpServer); + startServer(httpServer); RestTemplate restTemplate = new RestTemplate(); From 1c270d8d067bec08bbf419adeb354f96a3731780 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 13 Jan 2020 18:21:36 +0100 Subject: [PATCH 0313/2315] Fix Checkstyle violation --- .../http/server/reactive/ErrorHandlerIntegrationTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java index 41113324e70f..c7a925b47201 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java @@ -18,7 +18,6 @@ import java.net.URI; -import org.junit.Assume; import org.junit.jupiter.api.Assumptions; import reactor.core.publisher.Mono; From 5debd866d4ad398cacbc7ef6746d3f26596979b8 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 Jan 2020 20:22:47 +0100 Subject: [PATCH 0314/2315] Upgrade to Reactor Dysprosium SR3 Closes gh-24349 --- build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 02f7e4d8fc3c..94bff5e468b1 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ configure(allprojects) { project -> imports { mavenBom "com.fasterxml.jackson:jackson-bom:2.10.2" mavenBom "io.netty:netty-bom:4.1.44.Final" - mavenBom "io.projectreactor:reactor-bom:Dysprosium-BUILD-SNAPSHOT" + mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR3" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" mavenBom "org.eclipse.jetty:jetty-bom:9.4.25.v20191220" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.61" @@ -286,7 +286,6 @@ configure(allprojects) { project -> } repositories { mavenCentral() - maven { url "https://repo.spring.io/snapshot" } // Reactor Dysprosium snapshots maven { url "https://repo.spring.io/libs-spring-framework-build" } } } From 8740c2dc18482747c9e6d489718c08967f1e3f7c Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 13 Jan 2020 21:32:39 +0000 Subject: [PATCH 0315/2315] Warning against split URL handling in docs Closes gh-24304 --- .../servlet/config/annotation/ViewControllerRegistry.java | 6 +++++- src/docs/asciidoc/web/webmvc.adoc | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java index cf940cca2af1..a367eed58c43 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -61,6 +61,10 @@ public ViewControllerRegistry(@Nullable ApplicationContext applicationContext) { *

    Patterns like {@code "/admin/**"} or {@code "/articles/{articlename:\\w+}"} * are allowed. See {@link org.springframework.util.AntPathMatcher} for more details on the * syntax. + *

    Note: If an {@code @RequestMapping} method is mapped + * to a URL for any HTTP method then a view controller cannot handle the + * same URL. For this reason it is recommended to avoid splitting URL + * handling across an annotated controller and a view controller. */ public ViewControllerRegistration addViewController(String urlPath) { ViewControllerRegistration registration = new ViewControllerRegistration(urlPath); diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index c993a6de3f51..6de7b41083c7 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -5399,6 +5399,13 @@ using the `` element: ---- +If an `@RequestMapping` method is mapped to a URL for any HTTP method then a view +controller cannot be used to handle the same URL. This is because a match by URL to an +annotated controller is considered a strong enough indication of endpoint ownership so +that a 405 (METHOD_NOT_ALLOWED), a 415 (UNSUPPORTED_MEDIA_TYPE), or similar response can +be sent to the client to help with debugging. For this reason it is recommended to avoid +splitting URL handling across an annotated controller and a view controller. + [[mvc-config-view-resolvers]] From 0f5103de450e6a30f6814586108155e32ab90456 Mon Sep 17 00:00:00 2001 From: Spring Buildmaster Date: Tue, 14 Jan 2020 08:00:45 +0000 Subject: [PATCH 0316/2315] Next Development Version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index ba11054b2e55..534dc0514131 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=5.2.3.BUILD-SNAPSHOT +version=5.2.4.BUILD-SNAPSHOT org.gradle.jvmargs=-Xmx1536M org.gradle.caching=true org.gradle.parallel=true From f1827cb1f94b365f31531002a6bf1aa43c51fe9e Mon Sep 17 00:00:00 2001 From: hyeonisism <54709431+hyeonisism@users.noreply.github.com> Date: Wed, 15 Jan 2020 01:20:38 +0900 Subject: [PATCH 0317/2315] Add tests for StringUtils split() method Closes gh-24351 --- .../springframework/util/StringUtilsTests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java index 701eee3f9694..e1f3ecef57b0 100644 --- a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java @@ -745,4 +745,20 @@ void invalidLocaleWithLanguageTag() { assertThat(StringUtils.parseLocale("")).isNull(); } + @Test + void split() { + assertThat(StringUtils.split("Hello, world", ",")).isEqualTo(new String[]{"Hello", " world"}); + assertThat(StringUtils.split(",Hello world", ",")).isEqualTo(new String[]{"", "Hello world"}); + assertThat(StringUtils.split("Hello world,", ",")).isEqualTo(new String[]{"Hello world", ""}); + assertThat(StringUtils.split("Hello, world,", ",")).isEqualTo(new String[]{"Hello", " world,"}); + } + + @Test + void splitWithEmptyString() { + assertThat(StringUtils.split("Hello, world", "")).isNull(); + assertThat(StringUtils.split("", ",")).isNull(); + assertThat(StringUtils.split(null, ",")).isNull(); + assertThat(StringUtils.split("Hello, world", null)).isNull(); + assertThat(StringUtils.split(null, null)).isNull(); + } } From 6c2cb8ecf5d1d755f09aff80489aa8b6e49d70b1 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 14 Jan 2020 17:33:02 +0100 Subject: [PATCH 0318/2315] Polish contribution See gh-24351 --- .../org/springframework/util/StringUtilsTests.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java index e1f3ecef57b0..9191b3f79df3 100644 --- a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -747,18 +747,19 @@ void invalidLocaleWithLanguageTag() { @Test void split() { - assertThat(StringUtils.split("Hello, world", ",")).isEqualTo(new String[]{"Hello", " world"}); - assertThat(StringUtils.split(",Hello world", ",")).isEqualTo(new String[]{"", "Hello world"}); - assertThat(StringUtils.split("Hello world,", ",")).isEqualTo(new String[]{"Hello world", ""}); - assertThat(StringUtils.split("Hello, world,", ",")).isEqualTo(new String[]{"Hello", " world,"}); + assertThat(StringUtils.split("Hello, world", ",")).containsExactly("Hello", " world"); + assertThat(StringUtils.split(",Hello world", ",")).containsExactly("", "Hello world"); + assertThat(StringUtils.split("Hello world,", ",")).containsExactly("Hello world", ""); + assertThat(StringUtils.split("Hello, world,", ",")).containsExactly("Hello", " world,"); } @Test - void splitWithEmptyString() { + void splitWithEmptyStringOrNull() { assertThat(StringUtils.split("Hello, world", "")).isNull(); assertThat(StringUtils.split("", ",")).isNull(); assertThat(StringUtils.split(null, ",")).isNull(); assertThat(StringUtils.split("Hello, world", null)).isNull(); assertThat(StringUtils.split(null, null)).isNull(); } + } From 152254ab0a7b61e742f35cb67acadcfc8b867b46 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 15 Jan 2020 13:53:22 +0100 Subject: [PATCH 0319/2315] Document supported characters for identifiers in SpEL expressions Closes gh-24359 --- src/docs/asciidoc/core/core-expressions.adoc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/docs/asciidoc/core/core-expressions.adoc b/src/docs/asciidoc/core/core-expressions.adoc index 0c2e823fc8b2..5a833d20764c 100644 --- a/src/docs/asciidoc/core/core-expressions.adoc +++ b/src/docs/asciidoc/core/core-expressions.adoc @@ -1382,8 +1382,20 @@ example shows how to use the `new` operator to invoke constructors: === Variables You can reference variables in the expression by using the `#variableName` syntax. Variables -are set by using the `setVariable` method on `EvaluationContext` implementations. The -following example shows how to use variables: +are set by using the `setVariable` method on `EvaluationContext` implementations. + +[NOTE] +==== +Valid variable names must be composed of one or more of the following supported +characters. + +* letters: `A` to `Z` and `a` to `z` +* digits: `0` to `9` +* underscore: `_` +* dollar sign: `$` +==== + +The following example shows how to use variables. [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java From 89b8449999769cbc412cd3301614630bbe98ae34 Mon Sep 17 00:00:00 2001 From: hyeonisism <54709431+hyeonisism@users.noreply.github.com> Date: Wed, 15 Jan 2020 22:01:38 +0900 Subject: [PATCH 0320/2315] Simplify getParsedSql() method in NamedParameterJdbcTemplate Closes gh-24358 --- .../jdbc/core/namedparam/NamedParameterJdbcTemplate.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java index fba392392c9b..8d175cca3a11 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java @@ -430,12 +430,7 @@ protected ParsedSql getParsedSql(String sql) { return NamedParameterUtils.parseSqlStatement(sql); } synchronized (this.parsedSqlCache) { - ParsedSql parsedSql = this.parsedSqlCache.get(sql); - if (parsedSql == null) { - parsedSql = NamedParameterUtils.parseSqlStatement(sql); - this.parsedSqlCache.put(sql, parsedSql); - } - return parsedSql; + return parsedSqlCache.computeIfAbsent(sql, NamedParameterUtils::parseSqlStatement); } } From f527ca7515dce934594235861e6361405d551f96 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 15 Jan 2020 14:04:50 +0100 Subject: [PATCH 0321/2315] Update copyright date --- .../jdbc/core/namedparam/NamedParameterJdbcTemplate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java index 8d175cca3a11..a4c8b839835d 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. From 734db23f4eb99e4489a9349dd77de78e53f7f33d Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 15 Jan 2020 14:09:11 +0100 Subject: [PATCH 0322/2315] Fix Checkstyle violation See gh-gh-24358 --- .../jdbc/core/namedparam/NamedParameterJdbcTemplate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java index a4c8b839835d..5d0e6ada4f01 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java @@ -430,7 +430,7 @@ protected ParsedSql getParsedSql(String sql) { return NamedParameterUtils.parseSqlStatement(sql); } synchronized (this.parsedSqlCache) { - return parsedSqlCache.computeIfAbsent(sql, NamedParameterUtils::parseSqlStatement); + return this.parsedSqlCache.computeIfAbsent(sql, NamedParameterUtils::parseSqlStatement); } } From 3b983e21650a02b24e5c48d97a296f1ab760de5e Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 15 Jan 2020 14:18:30 +0100 Subject: [PATCH 0323/2315] Include Objenesis NOTICE file contents in binary distributions Closes gh-24326 --- src/docs/dist/license.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/docs/dist/license.txt b/src/docs/dist/license.txt index 8d2de8d0d44d..97bee37bea99 100644 --- a/src/docs/dist/license.txt +++ b/src/docs/dist/license.txt @@ -261,6 +261,13 @@ Per the LICENSE file in the Objenesis ZIP distribution downloaded from http://objenesis.org/download.html, Objenesis 3.1 is licensed under the Apache License, version 2.0, the text of which is included above. +Per the NOTICE file in the Objenesis ZIP distribution downloaded from +http://objenesis.org/download.html and corresponding to section 4d of the +Apache License, Version 2.0, in this case for Objenesis: + +Objenesis +Copyright 2006-2019 Joe Walnes, Henri Tremblay, Leonardo Mesquita + =============================================================================== From e864409c5faeaaa59130e81474cf337cad870cc2 Mon Sep 17 00:00:00 2001 From: Gary Hale Date: Thu, 16 Jan 2020 04:50:18 -0500 Subject: [PATCH 0324/2315] Update Artifactory plugin to 4.12.0 Closes gh-24250 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 94bff5e468b1..ecc52e56737e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { id 'io.spring.nohttp' version '0.0.4.RELEASE' id 'de.undercouch.download' version '4.0.0' id 'com.gradle.build-scan' version '3.1.1' - id "com.jfrog.artifactory" version '4.11.0' apply false + id "com.jfrog.artifactory" version '4.12.0' apply false id "io.freefair.aspectj" version "4.1.1" apply false id "com.github.ben-manes.versions" version "0.24.0" } From 61d9787b984a573a7a22a9f86321572506082485 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 16 Jan 2020 10:26:36 +0000 Subject: [PATCH 0325/2315] Publish a build scan only if authenticated Previously, anyone could publish a scan and publishing was performed if the GRADLE_ENTERPRISE_URL environment variable was set. ge.spring.io has now been locked down to prohibit anonymous build scan publishing. This commit aligns with this change by only attempting to publish a build scan when authenticated with the server. Authentication is achieved via an access token that is made available via an environment variable on CI and locally via a file in ~/.gradle. One can obtain an access key by running the following command: ./gradlew provisionGradleEnterpriseAccessKey Closes gh-24371 --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ecc52e56737e..a19754ee99f6 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,8 @@ buildScan { obfuscation { ipAddresses { addresses -> addresses.collect { address -> '0.0.0.0'} } } - publishAlwaysIf(System.getenv('GRADLE_ENTERPRISE_URL') != null) + publishAlways() + publishIfAuthenticated() server = 'https://ge.spring.io' } From 16e49bf0c92f9387ccf10426f77ba3b02f4c24fb Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 16 Jan 2020 15:07:14 +0100 Subject: [PATCH 0326/2315] Simplify getCache() implementation in CaffeineCacheManager Closes gh-24376 --- .../cache/caffeine/CaffeineCacheManager.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java index 54331f8909d0..0d43e94389fd 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -50,6 +50,7 @@ * @author Ben Manes * @author Juergen Hoeller * @author Stephane Nicoll + * @author Sam Brannen * @since 4.3 * @see CaffeineCache */ @@ -178,17 +179,8 @@ public Collection getCacheNames() { @Override @Nullable public Cache getCache(String name) { - Cache cache = this.cacheMap.get(name); - if (cache == null && this.dynamic) { - synchronized (this.cacheMap) { - cache = this.cacheMap.get(name); - if (cache == null) { - cache = createCaffeineCache(name); - this.cacheMap.put(name, cache); - } - } - } - return cache; + return this.cacheMap.computeIfAbsent(name, cacheName -> + this.dynamic ? createCaffeineCache(cacheName) : null); } /** From 3c0c0c0597e19b66d6cfebbf93b42f1c1fb2b4e5 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 15 Jan 2020 17:42:33 +0000 Subject: [PATCH 0327/2315] Fix issue with new line handling in StompDecoder Closes gh-23713 --- .../messaging/simp/stomp/StompDecoder.java | 13 ++++++++---- .../simp/stomp/StompDecoderTests.java | 20 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java index 60e5bb4ebb56..3c1b82ba8a73 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -114,6 +114,10 @@ public List> decode(ByteBuffer byteBuffer, Message message = decodeMessage(byteBuffer, partialMessageHeaders); if (message != null) { messages.add(message); + skipEol(byteBuffer); + if (!byteBuffer.hasRemaining()) { + break; + } } else { break; @@ -128,7 +132,7 @@ public List> decode(ByteBuffer byteBuffer, @Nullable private Message decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValueMap headers) { Message decodedMessage = null; - skipLeadingEol(byteBuffer); + skipEol(byteBuffer); // Explicit mark/reset access via Buffer base type for compatibility // with covariant return type on JDK 9's ByteBuffer... @@ -196,9 +200,10 @@ private void initHeaders(StompHeaderAccessor headerAccessor) { /** * Skip one ore more EOL characters at the start of the given ByteBuffer. - * Those are STOMP heartbeat frames. + * STOMP, section 2.1 says: "The NULL octet can be optionally followed by + * multiple EOLs." */ - protected void skipLeadingEol(ByteBuffer byteBuffer) { + protected void skipEol(ByteBuffer byteBuffer) { while (true) { if (!tryConsumeEndOfLine(byteBuffer)) { break; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java index 35734d0ea54d..439b157d2d6e 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -16,7 +16,6 @@ package org.springframework.messaging.simp.stomp; -import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.util.List; @@ -78,7 +77,7 @@ public void decodeFrameWithNoBody() { } @Test - public void decodeFrame() throws UnsupportedEncodingException { + public void decodeFrame() { Message frame = decode("SEND\ndestination:test\n\nThe body of the message\0"); StompHeaderAccessor headers = StompHeaderAccessor.wrap(frame); @@ -166,6 +165,17 @@ public void decodeFrameBodyNotAllowed() { decode("CONNECT\naccept-version:1.2\n\nThe body of the message\0")); } + @Test // gh-23713 + public void decodeFramesWithExtraNewLines() { + String frame1 = "SEND\ndestination:test\n\nbody\0\n\n\n"; + ByteBuffer buffer = ByteBuffer.wrap((frame1).getBytes()); + + final List> messages = decoder.decode(buffer); + + assertThat(messages.size()).isEqualTo(1); + assertThat(StompHeaderAccessor.wrap(messages.get(0)).getCommand()).isEqualTo(StompCommand.SEND); + } + @Test public void decodeMultipleFramesFromSameBuffer() { String frame1 = "SEND\ndestination:test\n\nThe body of the message\0"; @@ -179,9 +189,7 @@ public void decodeMultipleFramesFromSameBuffer() { assertThat(StompHeaderAccessor.wrap(messages.get(1)).getCommand()).isEqualTo(StompCommand.DISCONNECT); } - // SPR-13111 - - @Test + @Test // SPR-13111 public void decodeFrameWithHeaderWithEmptyValue() { String accept = "accept-version:1.1\n"; String valuelessKey = "key:\n"; From ac8eaca475b848619cfea60c248af1a224d13c92 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 16 Jan 2020 14:35:45 +0000 Subject: [PATCH 0328/2315] HttpWebHandlerAdapter#formatRequest is protected Closes gh-24352 --- .../web/server/adapter/HttpWebHandlerAdapter.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java index bd3edea6aced..63a87d2d0434 100644 --- a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java +++ b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -243,7 +243,13 @@ protected ServerWebExchange createExchange(ServerHttpRequest request, ServerHttp getCodecConfigurer(), getLocaleContextResolver(), this.applicationContext); } - private String formatRequest(ServerHttpRequest request) { + /** + * Format the request for logging purposes including HTTP method and URL. + *

    By default this prints the HTTP method, the URL path, and the query. + * @param request the request to format + * @return the String to display, never empty or @code null} + */ + protected String formatRequest(ServerHttpRequest request) { String rawQuery = request.getURI().getRawQuery(); String query = StringUtils.hasText(rawQuery) ? "?" + rawQuery : ""; return "HTTP " + request.getMethod() + " \"" + request.getPath() + query + "\""; From 3d33cf37649d6000c679ff2763c1e47a702c4365 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 16 Jan 2020 15:42:15 +0000 Subject: [PATCH 0329/2315] Updates to Validation section in reference Closes gh-24338 --- src/docs/asciidoc/core/core-validation.adoc | 157 ++++++++++++-------- 1 file changed, 94 insertions(+), 63 deletions(-) diff --git a/src/docs/asciidoc/core/core-validation.adoc b/src/docs/asciidoc/core/core-validation.adoc index 7b34fe64099a..ee2c5245c620 100644 --- a/src/docs/asciidoc/core/core-validation.adoc +++ b/src/docs/asciidoc/core/core-validation.adoc @@ -5,14 +5,14 @@ There are pros and cons for considering validation as business logic, and Spring a design for validation (and data binding) that does not exclude either one of them. Specifically, validation should not be tied to the web tier and should be easy to localize, and it should be possible to plug in any available validator. Considering these concerns, -Spring has come up with a `Validator` interface that is both basic and eminently usable +Spring provides a `Validator` contract that is both basic and eminently usable in every layer of an application. Data binding is useful for letting user input be dynamically bound to the domain model of an application (or whatever objects you use to process user input). Spring provides the aptly named `DataBinder` to do exactly that. The `Validator` and the `DataBinder` make up the `validation` package, which is primarily used in but not -limited to the MVC framework. +limited to the web layer. The `BeanWrapper` is a fundamental concept in the Spring Framework and is used in a lot of places. However, you probably do not need to use the `BeanWrapper` @@ -28,19 +28,12 @@ general type conversion facility, as well as a higher-level "`format`" package f formatting UI field values. You can use these packages as simpler alternatives to `PropertyEditorSupport` implementations. They are also discussed in this chapter. -.JSR-303/JSR-349 Bean Validation -**** -As of version 4.0, Spring Framework supports Bean Validation 1.0 (JSR-303) and -Bean Validation 1.1 (JSR-349) for setup support and adapting them to Spring's -`Validator` interface. - -An application can choose to enable Bean Validation once globally, as described in -<>, and use it exclusively for all validation needs. - -An application can also register additional Spring `Validator` instances for each -`DataBinder` instance, as described in <>. This may be useful for -plugging in validation logic without the use of annotations. -**** +Spring supports Java Bean Validation through setup infrastructure and an adaptor to +Spring's own `Validator` contract. Application can enable Bean Validation once globally, +as described in <>, and use it exclusively for all validation +needs. In the web layer, they can further register controller-local local Spring +`Validator` instances per `DataBinder`, as described in <>, which can +be useful for plugging in custom validation logic creating annotations. @@ -1811,22 +1804,20 @@ See <> for details. [[validation-beanvalidation]] -== Spring Validation +== Java Bean Validation -Spring 3 introduced several enhancements to its validation support. First, the JSR-303 -Bean Validation API is fully supported. Second, when used programmatically, Spring's -`DataBinder` can validate objects as well as bind to them. Third, Spring MVC has -support for declaratively validating `@Controller` inputs. +The Spring Framework provides support for the +https://beanvalidation.org/[Java Bean Validation] API. [[validation-beanvalidation-overview]] -=== Overview of the JSR-303 Bean Validation API +=== Overview of Bean Validation -JSR-303 standardizes validation constraint declaration and metadata for the Java -platform. By using this API, you annotate domain model properties with declarative -validation constraints and the runtime enforces them. You can use a number of built-in -constraints. You can also define your own custom constraints. +Bean Validation provides a common way of validation through constraint declaration and +metadata for Java applications. To use it, you annotate domain model properties with +declarative validation constraints which are then enforced by the runtime. There are +built-in constraints, and you can also define your own custom constraints. Consider the following example, which shows a simple `PersonForm` model with two properties: @@ -1847,8 +1838,7 @@ Consider the following example, which shows a simple `PersonForm` model with two ) ---- -JSR-303 lets you define declarative validation constraints against such properties, as the -following example shows: +Bean Validation lets you declare constraints as the following example shows: [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java @@ -1874,13 +1864,10 @@ following example shows: ) ---- -When a JSR-303 Validator validates an instance of this class, these constraints -are enforced. - -For general information on JSR-303 and JSR-349, see the https://beanvalidation.org/[Bean -Validation website]. For information on the specific capabilities of the default -reference implementation, see the https://www.hibernate.org/412.html[Hibernate -Validator] documentation. To learn how to set up a bean validation provider as a Spring +A Bean Validation validator then validates instances of this class based on the declared +constraints. See https://beanvalidation.org/[Bean Validation] for general information about +the API. See the https://hibernate.org/validator/[Hibernate Validator] documentation for +specific constraints. To learn how to set up a bean validation provider as a Spring bean, keep reading. @@ -1888,32 +1875,48 @@ bean, keep reading. [[validation-beanvalidation-spring]] === Configuring a Bean Validation Provider -Spring provides full support for the Bean Validation API. This includes convenient -support for bootstrapping a JSR-303 or JSR-349 Bean Validation provider as a Spring bean. -This lets you inject a `javax.validation.ValidatorFactory` or `javax.validation.Validator` -wherever validation is needed in your application. +Spring provides full support for the Bean Validation API including the bootstrapping of a +Bean Validation provider as a Spring bean. This lets you inject a +`javax.validation.ValidatorFactory` or `javax.validation.Validator` wherever validation is +needed in your application. -You can use the `LocalValidatorFactoryBean` to configure a default Validator as a Spring bean, -as the following example shows: +You can use the `LocalValidatorFactoryBean` to configure a default Validator as a Spring +bean, as the following example shows: -[source,xml,indent=0,subs="verbatim,quotes"] +[source,java,indent=0,subs="verbatim,quotes",role="primary"] +.Java +---- + import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; + + @Configuration + + public class AppConfig { + + @Bean + public LocalValidatorFactoryBean validator() { + return new LocalValidatorFactoryBean; + } + } +---- +[source,xml,indent=0,subs="verbatim,quotes",role="secondary"] +.XML ---- ---- -The basic configuration in the preceding example triggers bean validation to initialize by using its -default bootstrap mechanism. A JSR-303 or JSR-349 provider, such as the Hibernate Validator, -is expected to be present in the classpath and is automatically detected. +The basic configuration in the preceding example triggers bean validation to initialize by +using its default bootstrap mechanism. A Bean Validation provider, such as the Hibernate +Validator, is expected to be present in the classpath and is automatically detected. [[validation-beanvalidation-spring-inject]] ==== Injecting a Validator `LocalValidatorFactoryBean` implements both `javax.validation.ValidatorFactory` and -`javax.validation.Validator`, as well as Spring's -`org.springframework.validation.Validator`. You can inject a reference to either of -these interfaces into beans that need to invoke validation logic. +`javax.validation.Validator`, as well as Spring's `org.springframework.validation.Validator`. +You can inject a reference to either of these interfaces into beans that need to invoke +validation logic. You can inject a reference to `javax.validation.Validator` if you prefer to work with the Bean Validation API directly, as the following example shows: @@ -1939,8 +1942,8 @@ Validation API directly, as the following example shows: class MyService(@Autowired private val validator: Validator) ---- -You can inject a reference to `org.springframework.validation.Validator` if your bean requires -the Spring Validation API, as the following example shows: +You can inject a reference to `org.springframework.validation.Validator` if your bean +requires the Spring Validation API, as the following example shows: [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java @@ -1968,11 +1971,9 @@ the Spring Validation API, as the following example shows: ==== Configuring Custom Constraints Each bean validation constraint consists of two parts: -* A `@Constraint` annotation -that declares the constraint and its configurable properties. -* An implementation -of the `javax.validation.ConstraintValidator` interface that implements the constraint's -behavior. +* A `@Constraint` annotation that declares the constraint and its configurable properties. +* An implementation of the `javax.validation.ConstraintValidator` interface that implements +the constraint's behavior. To associate a declaration with an implementation, each `@Constraint` annotation references a corresponding `ConstraintValidator` implementation class. At runtime, a @@ -2036,19 +2037,48 @@ As the preceding example shows, a `ConstraintValidator` implementation can have [[validation-beanvalidation-spring-method]] ==== Spring-driven Method Validation -You can integrate the method validation feature supported by Bean Validation 1.1 (and, as a custom -extension, also by Hibernate Validator 4.3) into a Spring context -through a `MethodValidationPostProcessor` bean definition, as follows: +You can integrate the method validation feature supported by Bean Validation 1.1 (and, as +a custom extension, also by Hibernate Validator 4.3) into a Spring context through a +`MethodValidationPostProcessor` bean definition: -[source,xml,indent=0,subs="verbatim,quotes"] +[source,java,indent=0,subs="verbatim,quotes",role="primary"] +.Java +---- + import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; + + @Configuration + + public class AppConfig { + + @Bean + public MethodValidationPostProcessor validationPostProcessor() { + return new MethodValidationPostProcessor; + } + } + +---- +[source,xml,indent=0,subs="verbatim,quotes",role="secondary"] +.XML ---- ---- -To be eligible for Spring-driven method validation, all target classes need to be annotated with -Spring's `@Validated` annotation. (Optionally, you can also declare the validation groups to use.) -See the {api-spring-framework}/validation/beanvalidation/MethodValidationPostProcessor.html[`MethodValidationPostProcessor`] -javadoc for setup details with the Hibernate Validator and Bean Validation 1.1 providers. +To be eligible for Spring-driven method validation, all target classes need to be annotated +with Spring's `@Validated` annotation, which can optionally also declare the validation +groups to use. See +{api-spring-framework}/validation/beanvalidation/MethodValidationPostProcessor.html[`MethodValidationPostProcessor`] +for setup details with the Hibernate Validator and Bean Validation 1.1 providers. + +[TIP] +==== +Method validation relies on <> around the +target classes, either JDK dynamic proxies for methods on interfaces or CGLIB proxies. +There are certain limitations with the use of proxies, some of which are described in +<>. In addition remember +to always use methods and accessors on proxied classes; direct field access will not work. +==== + + [[validation-beanvalidation-spring-other]] @@ -2108,7 +2138,8 @@ logic after binding to a target object: You can also configure a `DataBinder` with multiple `Validator` instances through `dataBinder.addValidators` and `dataBinder.replaceValidators`. This is useful when combining globally configured bean validation with a Spring `Validator` configured -locally on a DataBinder instance. See <>. +locally on a DataBinder instance. See +<>. From 8e67b7b2cf8e769ac56f779ea81fe8285e5f7020 Mon Sep 17 00:00:00 2001 From: Jacob Severson Date: Thu, 5 Dec 2019 21:09:38 -0600 Subject: [PATCH 0330/2315] Expose proxyPing Reactor Netty WebSocket See gh-24331 --- .../client/ReactorNettyWebSocketClient.java | 26 ++++++++++++++++++- .../ReactorNettyRequestUpgradeStrategy.java | 26 ++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java index d3e9f6f85ecc..c106b3a3c49d 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java @@ -46,6 +46,8 @@ public class ReactorNettyWebSocketClient implements WebSocketClient { private int maxFramePayloadLength = NettyWebSocketSessionSupport.DEFAULT_FRAME_MAX_SIZE; + private boolean proxyPing = false; + private final HttpClient httpClient; @@ -95,6 +97,28 @@ public int getMaxFramePayloadLength() { return this.maxFramePayloadLength; } + /** + * Configure how the client handles incoming Websocket Ping frames. Setting this value to + * {@code true} causes the client to handle Ping frames as any other, allowing the + * Ping to be sent downstream if the client is used within a proxying application. Setting + * this value to {@code false} causes the client to respond automatically with a Pong frame. + * Default is {@code false}. + * + * @param proxyPing whether the client should proxy Ping frames or respond automatically + * @since 5.2 + */ + public void setProxyPing(boolean proxyPing) { + this.proxyPing = proxyPing; + } + + /** + * Return the configured {@link #setProxyPing(boolean)} + * + * @since 5.2 + */ + public boolean getProxyPing() { + return this.proxyPing; + } @Override public Mono execute(URI url, WebSocketHandler handler) { @@ -106,7 +130,7 @@ public Mono execute(URI url, HttpHeaders requestHeaders, WebSocketHandler String protocols = StringUtils.collectionToCommaDelimitedString(handler.getSubProtocols()); return getHttpClient() .headers(nettyHeaders -> setNettyHeaders(requestHeaders, nettyHeaders)) - .websocket(protocols, getMaxFramePayloadLength()) + .websocket(protocols, getMaxFramePayloadLength(), this.proxyPing) .uri(url.toString()) .handle((inbound, outbound) -> { HttpHeaders responseHeaders = toHttpHeaders(inbound); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java index 85edc7485225..db5ad508ad49 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java @@ -44,6 +44,7 @@ public class ReactorNettyRequestUpgradeStrategy implements RequestUpgradeStrateg private int maxFramePayloadLength = NettyWebSocketSessionSupport.DEFAULT_FRAME_MAX_SIZE; + private boolean proxyPing = false; /** * Configure the maximum allowable frame payload length. Setting this value @@ -68,6 +69,29 @@ public int getMaxFramePayloadLength() { return this.maxFramePayloadLength; } + /** + * Configure how the server handles incoming Websocket Ping frames. Setting this value to + * {@code true} causes the server to handle Ping frames as any other, allowing the + * Ping to be sent downstream if the server is used within a proxying application. Setting + * this value to {@code false} causes the server to respond automatically with a Pong frame. + * Default is {@code false}. + * + * @param proxyPing whether the server should proxy Ping frames or respond automatically + * @since 5.2 + */ + public void setProxyPing(boolean proxyPing) { + this.proxyPing = proxyPing; + } + + /** + * Return the configured {@link #setProxyPing(boolean)} + * + * @since 5.2 + */ + public boolean getProxyPing() { + return this.proxyPing; + } + @Override public Mono upgrade(ServerWebExchange exchange, WebSocketHandler handler, @@ -78,7 +102,7 @@ public Mono upgrade(ServerWebExchange exchange, WebSocketHandler handler, HandshakeInfo handshakeInfo = handshakeInfoFactory.get(); NettyDataBufferFactory bufferFactory = (NettyDataBufferFactory) response.bufferFactory(); - return reactorResponse.sendWebsocket(subProtocol, this.maxFramePayloadLength, + return reactorResponse.sendWebsocket(subProtocol, this.maxFramePayloadLength, this.proxyPing, (in, out) -> { ReactorNettyWebSocketSession session = new ReactorNettyWebSocketSession( From b1d93bb307ed7ff1d63492251fe4f584bd716d7e Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 16 Jan 2020 14:16:56 +0000 Subject: [PATCH 0331/2315] Polishing contribution See gh-24367 --- .../client/ReactorNettyWebSocketClient.java | 42 ++++++++++--------- .../ReactorNettyRequestUpgradeStrategy.java | 37 ++++++++-------- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java index c106b3a3c49d..e53038163298 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -44,12 +44,13 @@ public class ReactorNettyWebSocketClient implements WebSocketClient { private static final Log logger = LogFactory.getLog(ReactorNettyWebSocketClient.class); - private int maxFramePayloadLength = NettyWebSocketSessionSupport.DEFAULT_FRAME_MAX_SIZE; - - private boolean proxyPing = false; private final HttpClient httpClient; + private int maxFramePayloadLength = NettyWebSocketSessionSupport.DEFAULT_FRAME_MAX_SIZE; + + private boolean handlePing; + /** * Default constructor. @@ -67,6 +68,7 @@ public ReactorNettyWebSocketClient(HttpClient httpClient) { this.httpClient = httpClient; } + /** * Return the configured {@link HttpClient}. */ @@ -98,26 +100,26 @@ public int getMaxFramePayloadLength() { } /** - * Configure how the client handles incoming Websocket Ping frames. Setting this value to - * {@code true} causes the client to handle Ping frames as any other, allowing the - * Ping to be sent downstream if the client is used within a proxying application. Setting - * this value to {@code false} causes the client to respond automatically with a Pong frame. - * Default is {@code false}. - * - * @param proxyPing whether the client should proxy Ping frames or respond automatically - * @since 5.2 + * Configure whether to let ping frames through to be handled by the + * {@link WebSocketHandler} given to the execute method. By default, Reactor + * Netty automatically replies with pong frames in response to pings. This is + * useful in a proxy for allowing ping and pong frames through. + *

    By default this is set to {@code false} in which case ping frames are + * handled automatically by Reactor Netty. If set to {@code true}, ping + * frames will be passed through to the {@link WebSocketHandler}. + * @param handlePing whether to let Ping frames through for handling + * @since 5.2.4 */ - public void setProxyPing(boolean proxyPing) { - this.proxyPing = proxyPing; + public void setHandlePing(boolean handlePing) { + this.handlePing = handlePing; } /** - * Return the configured {@link #setProxyPing(boolean)} - * - * @since 5.2 + * Return the configured {@link #setHandlePing(boolean)}. + * @since 5.2.4 */ - public boolean getProxyPing() { - return this.proxyPing; + public boolean getHandlePing() { + return this.handlePing; } @Override @@ -130,7 +132,7 @@ public Mono execute(URI url, HttpHeaders requestHeaders, WebSocketHandler String protocols = StringUtils.collectionToCommaDelimitedString(handler.getSubProtocols()); return getHttpClient() .headers(nettyHeaders -> setNettyHeaders(requestHeaders, nettyHeaders)) - .websocket(protocols, getMaxFramePayloadLength(), this.proxyPing) + .websocket(protocols, getMaxFramePayloadLength(), this.handlePing) .uri(url.toString()) .handle((inbound, outbound) -> { HttpHeaders responseHeaders = toHttpHeaders(inbound); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java index db5ad508ad49..afd8315f6cbf 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -44,7 +44,8 @@ public class ReactorNettyRequestUpgradeStrategy implements RequestUpgradeStrateg private int maxFramePayloadLength = NettyWebSocketSessionSupport.DEFAULT_FRAME_MAX_SIZE; - private boolean proxyPing = false; + private boolean handlePing = false; + /** * Configure the maximum allowable frame payload length. Setting this value @@ -70,26 +71,26 @@ public int getMaxFramePayloadLength() { } /** - * Configure how the server handles incoming Websocket Ping frames. Setting this value to - * {@code true} causes the server to handle Ping frames as any other, allowing the - * Ping to be sent downstream if the server is used within a proxying application. Setting - * this value to {@code false} causes the server to respond automatically with a Pong frame. - * Default is {@code false}. - * - * @param proxyPing whether the server should proxy Ping frames or respond automatically - * @since 5.2 + * Configure whether to let ping frames through to be handled by the + * {@link WebSocketHandler} given to the upgrade method. By default, Reactor + * Netty automatically replies with pong frames in response to pings. This is + * useful in a proxy for allowing ping and pong frames through. + *

    By default this is set to {@code false} in which case ping frames are + * handled automatically by Reactor Netty. If set to {@code true}, ping + * frames will be passed through to the {@link WebSocketHandler}. + * @param handlePing whether to let Ping frames through for handling + * @since 5.2.4 */ - public void setProxyPing(boolean proxyPing) { - this.proxyPing = proxyPing; + public void setHandlePing(boolean handlePing) { + this.handlePing = handlePing; } /** - * Return the configured {@link #setProxyPing(boolean)} - * - * @since 5.2 + * Return the configured {@link #setHandlePing(boolean)}. + * @since 5.2.4 */ - public boolean getProxyPing() { - return this.proxyPing; + public boolean getHandlePing() { + return this.handlePing; } @@ -102,7 +103,7 @@ public Mono upgrade(ServerWebExchange exchange, WebSocketHandler handler, HandshakeInfo handshakeInfo = handshakeInfoFactory.get(); NettyDataBufferFactory bufferFactory = (NettyDataBufferFactory) response.bufferFactory(); - return reactorResponse.sendWebsocket(subProtocol, this.maxFramePayloadLength, this.proxyPing, + return reactorResponse.sendWebsocket(subProtocol, this.maxFramePayloadLength, this.handlePing, (in, out) -> { ReactorNettyWebSocketSession session = new ReactorNettyWebSocketSession( From 2a2efbe6119621f3ac3667820ef28e9d9a90692b Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 16 Jan 2020 16:34:21 +0100 Subject: [PATCH 0332/2315] Introduce @Disabled regression test for gh-24375 --- .../src/test/java/example/gh24375/A.java | 35 +++++++++++++++++++ .../src/test/java/example/gh24375/B.java | 29 +++++++++++++++ .../java/example/gh24375/MyComponent.java | 24 +++++++++++++ ...anningCandidateComponentProviderTests.java | 14 +++++++- 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 spring-context/src/test/java/example/gh24375/A.java create mode 100644 spring-context/src/test/java/example/gh24375/B.java create mode 100644 spring-context/src/test/java/example/gh24375/MyComponent.java diff --git a/spring-context/src/test/java/example/gh24375/A.java b/spring-context/src/test/java/example/gh24375/A.java new file mode 100644 index 000000000000..a55f3406c247 --- /dev/null +++ b/spring-context/src/test/java/example/gh24375/A.java @@ -0,0 +1,35 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package example.gh24375; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.core.annotation.AliasFor; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface A { + + @AliasFor("value") + B other() default @B; + + @AliasFor("other") + B value() default @B; +} diff --git a/spring-context/src/test/java/example/gh24375/B.java b/spring-context/src/test/java/example/gh24375/B.java new file mode 100644 index 000000000000..7d79502d71a4 --- /dev/null +++ b/spring-context/src/test/java/example/gh24375/B.java @@ -0,0 +1,29 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package example.gh24375; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.ANNOTATION_TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface B { + + String name() default ""; +} \ No newline at end of file diff --git a/spring-context/src/test/java/example/gh24375/MyComponent.java b/spring-context/src/test/java/example/gh24375/MyComponent.java new file mode 100644 index 000000000000..ce21ae567ef9 --- /dev/null +++ b/spring-context/src/test/java/example/gh24375/MyComponent.java @@ -0,0 +1,24 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package example.gh24375; + +import org.springframework.stereotype.Component; + +@Component +@A(other = @B) +public class MyComponent { +} diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java index 7b63c97ad847..9d46c7d3f162 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -21,6 +21,7 @@ import java.util.Set; import java.util.regex.Pattern; +import example.gh24375.MyComponent; import example.profilescan.DevComponent; import example.profilescan.ProfileAnnotatedComponent; import example.profilescan.ProfileMetaAnnotatedComponent; @@ -38,6 +39,7 @@ import example.scannable.StubFooDao; import example.scannable.sub.BarComponent; import org.aspectj.lang.annotation.Aspect; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; @@ -500,6 +502,16 @@ public void testIntegrationWithAnnotationConfigApplicationContext_metaProfile() } } + @Test + @Disabled("Disabled until gh-24375 is resolved") + public void gh24375() { + ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true); + Set components = provider.findCandidateComponents(MyComponent.class.getPackage().getName()); + assertThat(components).hasSize(1); + assertThat(components.iterator().next().getBeanClassName()).isEqualTo(MyComponent.class.getName()); + } + + private boolean containsBeanClass(Set candidates, Class beanClass) { for (BeanDefinition candidate : candidates) { if (beanClass.getName().equals(candidate.getBeanClassName())) { From 984f9de191b6efad763bf64168ddf40c6377b000 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 16 Jan 2020 18:14:14 +0100 Subject: [PATCH 0333/2315] Fix Checkstyle violation See gh-24375 --- spring-context/src/test/java/example/gh24375/B.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-context/src/test/java/example/gh24375/B.java b/spring-context/src/test/java/example/gh24375/B.java index 7d79502d71a4..96f3e9c94aa7 100644 --- a/spring-context/src/test/java/example/gh24375/B.java +++ b/spring-context/src/test/java/example/gh24375/B.java @@ -26,4 +26,4 @@ public @interface B { String name() default ""; -} \ No newline at end of file +} From daa30a9f0b6bcc33cbb452e7a1df27776acfa935 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 16 Jan 2020 18:19:11 +0100 Subject: [PATCH 0334/2315] Consistent use of AnnotationUtils.rethrowAnnotationConfigurationException() Closes gh-24379 --- .../core/annotation/AnnotationTypeMappings.java | 6 ++---- .../springframework/core/annotation/AnnotationUtils.java | 4 ++-- .../core/annotation/TypeMappedAnnotation.java | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMappings.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMappings.java index e6fee398763e..e60231ed6dab 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMappings.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMappings.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -116,9 +116,7 @@ private void addIfPossible(Deque queue, @Nullable Annotat queue.addLast(new AnnotationTypeMapping(source, annotationType, ann)); } catch (Exception ex) { - if (ex instanceof AnnotationConfigurationException) { - throw (AnnotationConfigurationException) ex; - } + AnnotationUtils.rethrowAnnotationConfigurationException(ex); if (failureLogger.isEnabled()) { failureLogger.log("Failed to introspect meta-annotation " + annotationType.getName(), (source != null ? source.getAnnotationType() : null), ex); diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index f80d0c7c335c..b7f7f959fd15 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -1076,7 +1076,7 @@ public static Object getValue(@Nullable Annotation annotation, @Nullable String *

    Otherwise, this method does nothing. * @param ex the throwable to inspect */ - private static void rethrowAnnotationConfigurationException(Throwable ex) { + static void rethrowAnnotationConfigurationException(Throwable ex) { if (ex instanceof AnnotationConfigurationException) { throw (AnnotationConfigurationException) ex; } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java index b2939c59dcdc..8975dc3f63ee 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -672,9 +672,7 @@ private static TypeMappedAnnotation createIfPossible( valueExtractor, aggregateIndex); } catch (Exception ex) { - if (ex instanceof AnnotationConfigurationException) { - throw (AnnotationConfigurationException) ex; - } + AnnotationUtils.rethrowAnnotationConfigurationException(ex); if (logger.isEnabled()) { String type = mapping.getAnnotationType().getName(); String item = (mapping.getDistance() == 0 ? "annotation " + type : From 59bef2223518c8be3cac558bd27a531ed7a94eac Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 17 Jan 2020 15:01:58 +0100 Subject: [PATCH 0335/2315] Avoid setting special Content-* response headers for Tomcat As of gh-21783, Spring WebFlux uses a `TomcatHeadersAdapter` implementation to directly address the native headers used by the server. In the case of Tomcat, "Content-Length" and "Content-Type" headers are processed separately and should not be added to the native headers map. This commit improves the `HandlerAdapter` implementation for Tomcat and removes those headers, if previously set in the map. The adapter already has a section that handles the Tomcat-specific calls for such headers. Fixes gh-24361 --- .../http/server/reactive/TomcatHttpHandlerAdapter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/TomcatHttpHandlerAdapter.java b/spring-web/src/main/java/org/springframework/http/server/reactive/TomcatHttpHandlerAdapter.java index 055869ed0bbe..c01a11b5a7ef 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/TomcatHttpHandlerAdapter.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/TomcatHttpHandlerAdapter.java @@ -216,6 +216,7 @@ protected void applyHeaders() { if (response.getContentType() == null && contentType != null) { response.setContentType(contentType.toString()); } + getHeaders().remove(HttpHeaders.CONTENT_TYPE); Charset charset = (contentType != null ? contentType.getCharset() : null); if (response.getCharacterEncoding() == null && charset != null) { response.setCharacterEncoding(charset.name()); @@ -224,6 +225,7 @@ protected void applyHeaders() { if (contentLength != -1) { response.setContentLengthLong(contentLength); } + getHeaders().remove(HttpHeaders.CONTENT_LENGTH); } @Override From 3adc7c30598252a4844bf4ee9833228059048d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A6=D1=8B=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Fri, 17 Jan 2020 17:59:39 +0200 Subject: [PATCH 0336/2315] Hoist concatenation of two constant Strings out of loops Closes gh-24388 --- .../factory/support/PropertiesBeanDefinitionReader.java | 7 +++++-- .../classreading/AnnotationMetadataReadingVisitor.java | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java index 3e0e744dcbb2..84d68e5dc9b2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java @@ -422,10 +422,13 @@ protected void registerBeanDefinition(String beanName, Map map, String pre ConstructorArgumentValues cas = new ConstructorArgumentValues(); MutablePropertyValues pvs = new MutablePropertyValues(); + String prefixWithSep = prefix + SEPARATOR; + int beginIndex = prefix.length() + SEPARATOR.length(); + for (Map.Entry entry : map.entrySet()) { String key = StringUtils.trimWhitespace((String) entry.getKey()); - if (key.startsWith(prefix + SEPARATOR)) { - String property = key.substring(prefix.length() + SEPARATOR.length()); + if (key.startsWith(prefixWithSep)) { + String property = key.substring(beginIndex); if (CLASS_KEY.equals(property)) { className = StringUtils.trimWhitespace((String) entry.getValue()); } diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java index d879b94fa082..2531a251b6fb 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java @@ -166,9 +166,10 @@ public MultiValueMap getAllAnnotationAttributes(String annotatio if (attributes == null) { return null; } + String annotatedElement = "class '" + getClassName() + "'"; for (AnnotationAttributes raw : attributes) { for (Map.Entry entry : AnnotationReadingVisitorUtils.convertClassValues( - "class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString).entrySet()) { + annotatedElement, this.classLoader, raw, classValuesAsString).entrySet()) { allAttributes.add(entry.getKey(), entry.getValue()); } } From b34404916a6640e2b30ca030db61186313b7a957 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 17 Jan 2020 18:15:16 +0100 Subject: [PATCH 0337/2315] Update copyright date --- .../beans/factory/support/PropertiesBeanDefinitionReader.java | 2 +- .../type/classreading/AnnotationMetadataReadingVisitor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java index 84d68e5dc9b2..02807b031157 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java index 2531a251b6fb..5ca315cf07f2 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. From c20a7b4636c9849f02f8b544eef3fef77a5a2ae5 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 20 Jan 2020 09:17:02 +0100 Subject: [PATCH 0338/2315] Upgrade to Reactor Dysprosium-SR4 Closes gh-24355 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a19754ee99f6..f0296022d156 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ configure(allprojects) { project -> imports { mavenBom "com.fasterxml.jackson:jackson-bom:2.10.2" mavenBom "io.netty:netty-bom:4.1.44.Final" - mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR3" + mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR4" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" mavenBom "org.eclipse.jetty:jetty-bom:9.4.25.v20191220" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.61" From 5d8c5b0d9bf1ecb3b902ed55c320a4ea4fae0b38 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 20 Jan 2020 11:26:58 +0000 Subject: [PATCH 0339/2315] Avoid NPE on comment SSE event Closes gh-24389 --- .../http/codec/ServerSentEventHttpMessageReader.java | 9 ++++++--- .../codec/ServerSentEventHttpMessageReaderTests.java | 11 +++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java index 7677c48ebfc9..86ee2988bea8 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java @@ -135,7 +135,10 @@ public Flux read( return this.lineDecoder.decode(message.getBody(), STRING_TYPE, null, hints) .doOnNext(limitTracker::afterLineParsed) .bufferUntil(String::isEmpty) - .map(lines -> buildEvent(lines, valueType, shouldWrap, hints)); + .concatMap(lines -> { + Object event = buildEvent(lines, valueType, shouldWrap, hints); + return (event != null ? Mono.just(event) : Mono.empty()); + }); } @Nullable @@ -168,7 +171,7 @@ else if (line.startsWith(":")) { } } - Object decodedData = data != null ? decodeData(data.toString(), valueType, hints) : null; + Object decodedData = (data != null ? decodeData(data.toString(), valueType, hints) : null); if (shouldWrap) { if (comment != null) { @@ -180,7 +183,7 @@ else if (line.startsWith(":")) { return sseBuilder.build(); } else { - return decodedData; + return (decodedData); } } diff --git a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java index c5a5983f07b6..22b77fd693de 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java @@ -161,6 +161,17 @@ public void readPojo() { .verify(); } + @Test // gh-24389 + void readPojoWithCommentOnly() { + MockServerHttpRequest request = MockServerHttpRequest.post("/") + .body(Flux.just(stringBuffer(":ping\n"), stringBuffer("\n"))); + + Flux data = this.reader.read( + ResolvableType.forType(String.class), request, Collections.emptyMap()); + + StepVerifier.create(data).expectComplete().verify(); + } + @Test // SPR-15331 public void decodeFullContentAsString() { String body = "data:foo\ndata:bar\n\ndata:baz\n\n"; From a234b90abba77907032604ad7bb60137b19a7808 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 20 Jan 2020 17:09:47 +0000 Subject: [PATCH 0340/2315] Explicit content-type for resources BodyInserters.ofResource now respects the Content-Type, if specified on the client request or server response. Closes gh-24366 --- .../web/reactive/function/BodyInserters.java | 5 +-- .../reactive/function/BodyInsertersTests.java | 33 ++++++++++++++++--- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java index 56f1b41d78a6..15f6ad99fa03 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -218,7 +218,8 @@ public static BodyInserter fr return (outputMessage, context) -> { ResolvableType elementType = RESOURCE_TYPE; HttpMessageWriter writer = findWriter(context, elementType, null); - return write(Mono.just(resource), elementType, null, outputMessage, context, writer); + MediaType contentType = outputMessage.getHeaders().getContentType(); + return write(Mono.just(resource), elementType, contentType, outputMessage, context, writer); }; } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java index 11141262083f..bc68dc96d9a0 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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,6 +48,7 @@ import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.HttpMethod; import org.springframework.http.HttpRange; +import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpOutputMessage; import org.springframework.http.client.reactive.ClientHttpRequest; import org.springframework.http.codec.EncoderHttpMessageWriter; @@ -224,14 +225,13 @@ public void ofPublisher() { @Test public void ofResource() throws IOException { - Resource body = new ClassPathResource("response.txt", getClass()); - BodyInserter inserter = BodyInserters.fromResource(body); + Resource resource = new ClassPathResource("response.txt", getClass()); MockServerHttpResponse response = new MockServerHttpResponse(); - Mono result = inserter.insert(response, this.context); + Mono result = BodyInserters.fromResource(resource).insert(response, this.context); StepVerifier.create(result).expectComplete().verify(); - byte[] expectedBytes = Files.readAllBytes(body.getFile().toPath()); + byte[] expectedBytes = Files.readAllBytes(resource.getFile().toPath()); StepVerifier.create(response.getBody()) .consumeNextWith(dataBuffer -> { @@ -244,6 +244,29 @@ public void ofResource() throws IOException { .verify(); } + @Test // gh-24366 + public void ofResourceWithExplicitMediaType() throws IOException { + Resource resource = new ClassPathResource("response.txt", getClass()); + + MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.POST, "/"); + request.getHeaders().setContentType(MediaType.TEXT_MARKDOWN); + Mono result = BodyInserters.fromResource(resource).insert(request, this.context); + StepVerifier.create(result).expectComplete().verify(); + + byte[] expectedBytes = Files.readAllBytes(resource.getFile().toPath()); + + assertThat(request.getHeaders().getContentType()).isEqualTo(MediaType.TEXT_MARKDOWN); + StepVerifier.create(request.getBody()) + .consumeNextWith(dataBuffer -> { + byte[] resultBytes = new byte[dataBuffer.readableByteCount()]; + dataBuffer.read(resultBytes); + DataBufferUtils.release(dataBuffer); + assertThat(resultBytes).isEqualTo(expectedBytes); + }) + .expectComplete() + .verify(); + } + @Test public void ofResourceRange() throws IOException { final int rangeStart = 10; From 5e9d29d8134b4be4733ae0a303d1c95b8c3d92c5 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 20 Jan 2020 17:29:59 +0000 Subject: [PATCH 0341/2315] Ability to customize default Smile codecs Closes gh-24382 --- .../http/codec/CodecConfigurer.java | 18 ++++++++- .../http/codec/support/BaseDefaultCodecs.java | 40 ++++++++++++++----- .../codec/support/CodecConfigurerTests.java | 8 +++- 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java index 62d8a0eb3c73..ec850a697c38 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -123,6 +123,22 @@ interface DefaultCodecs { */ void jackson2JsonEncoder(Encoder encoder); + /** + * Override the default Jackson Smile {@code Decoder}. + *

    Note that {@link #maxInMemorySize(int)}, if configured, will be + * applied to the given decoder. + * @param decoder the decoder instance to use + * @see org.springframework.http.codec.json.Jackson2SmileDecoder + */ + void jackson2SmileDecoder(Decoder decoder); + + /** + * Override the default Jackson Smile {@code Encoder}. + * @param encoder the encoder instance to use + * @see org.springframework.http.codec.json.Jackson2SmileEncoder + */ + void jackson2SmileEncoder(Encoder encoder); + /** * Override the default Protobuf {@code Decoder}. *

    Note that {@link #maxInMemorySize(int)}, if configured, will be diff --git a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java index 186267838897..64a2634f90a5 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java +++ b/spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java @@ -95,6 +95,12 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure @Nullable private Encoder jackson2JsonEncoder; + @Nullable + private Encoder jackson2SmileEncoder; + + @Nullable + private Decoder jackson2SmileDecoder; + @Nullable private Decoder protobufDecoder; @@ -125,6 +131,8 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure protected BaseDefaultCodecs(BaseDefaultCodecs other) { this.jackson2JsonDecoder = other.jackson2JsonDecoder; this.jackson2JsonEncoder = other.jackson2JsonEncoder; + this.jackson2SmileDecoder = other.jackson2SmileDecoder; + this.jackson2SmileEncoder = other.jackson2SmileEncoder; this.protobufDecoder = other.protobufDecoder; this.protobufEncoder = other.protobufEncoder; this.jaxb2Decoder = other.jaxb2Decoder; @@ -149,6 +157,16 @@ public void protobufDecoder(Decoder decoder) { this.protobufDecoder = decoder; } + @Override + public void jackson2SmileDecoder(Decoder decoder) { + this.jackson2SmileDecoder = decoder; + } + + @Override + public void jackson2SmileEncoder(Encoder encoder) { + this.jackson2SmileEncoder = encoder; + } + @Override public void protobufEncoder(Encoder encoder) { this.protobufEncoder = encoder; @@ -208,8 +226,8 @@ final List> getTypedReaders() { addCodec(readers, new ResourceHttpMessageReader(new ResourceDecoder())); addCodec(readers, new DecoderHttpMessageReader<>(StringDecoder.textPlainOnly())); if (protobufPresent) { - Decoder decoder = this.protobufDecoder != null ? this.protobufDecoder : new ProtobufDecoder(); - addCodec(readers, new DecoderHttpMessageReader<>(decoder)); + addCodec(readers, new DecoderHttpMessageReader<>(this.protobufDecoder != null ? + (ProtobufDecoder) this.protobufDecoder : new ProtobufDecoder())); } addCodec(readers, new FormHttpMessageReader()); @@ -324,11 +342,12 @@ final List> getObjectReaders() { addCodec(readers, new DecoderHttpMessageReader<>(getJackson2JsonDecoder())); } if (jackson2SmilePresent) { - addCodec(readers, new DecoderHttpMessageReader<>(new Jackson2SmileDecoder())); + addCodec(readers, new DecoderHttpMessageReader<>(this.jackson2SmileDecoder != null ? + (Jackson2SmileDecoder) this.jackson2SmileDecoder : new Jackson2SmileDecoder())); } if (jaxb2Present) { - Decoder decoder = this.jaxb2Decoder != null ? this.jaxb2Decoder : new Jaxb2XmlDecoder(); - addCodec(readers, new DecoderHttpMessageReader<>(decoder)); + addCodec(readers, new DecoderHttpMessageReader<>(this.jaxb2Decoder != null ? + (Jaxb2XmlDecoder) this.jaxb2Decoder : new Jaxb2XmlDecoder())); } // client vs server.. @@ -383,8 +402,8 @@ final List> getBaseTypedWriters() { writers.add(new ResourceHttpMessageWriter()); writers.add(new EncoderHttpMessageWriter<>(CharSequenceEncoder.textPlainOnly())); if (protobufPresent) { - Encoder encoder = this.protobufEncoder != null ? this.protobufEncoder : new ProtobufEncoder(); - writers.add(new ProtobufHttpMessageWriter((Encoder) encoder)); + writers.add(new ProtobufHttpMessageWriter(this.protobufEncoder != null ? + (ProtobufEncoder) this.protobufEncoder : new ProtobufEncoder())); } return writers; } @@ -416,11 +435,12 @@ final List> getBaseObjectWriters() { writers.add(new EncoderHttpMessageWriter<>(getJackson2JsonEncoder())); } if (jackson2SmilePresent) { - writers.add(new EncoderHttpMessageWriter<>(new Jackson2SmileEncoder())); + writers.add(new EncoderHttpMessageWriter<>(this.jackson2SmileEncoder != null ? + (Jackson2SmileEncoder) this.jackson2SmileEncoder : new Jackson2SmileEncoder())); } if (jaxb2Present) { - Encoder encoder = this.jaxb2Encoder != null ? this.jaxb2Encoder : new Jaxb2XmlEncoder(); - writers.add(new EncoderHttpMessageWriter<>(encoder)); + writers.add(new EncoderHttpMessageWriter<>(this.jaxb2Encoder != null ? + (Jaxb2XmlEncoder) this.jaxb2Encoder : new Jaxb2XmlEncoder())); } return writers; } diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java index b2ca4667d5cd..71a1d7a84839 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -252,6 +252,8 @@ public void defaultsOffWithCustomWriters() { public void encoderDecoderOverrides() { Jackson2JsonDecoder jacksonDecoder = new Jackson2JsonDecoder(); Jackson2JsonEncoder jacksonEncoder = new Jackson2JsonEncoder(); + Jackson2SmileDecoder smileDecoder = new Jackson2SmileDecoder(); + Jackson2SmileEncoder smileEncoder = new Jackson2SmileEncoder(); ProtobufDecoder protobufDecoder = new ProtobufDecoder(ExtensionRegistry.newInstance()); ProtobufEncoder protobufEncoder = new ProtobufEncoder(); Jaxb2XmlEncoder jaxb2Encoder = new Jaxb2XmlEncoder(); @@ -259,15 +261,19 @@ public void encoderDecoderOverrides() { this.configurer.defaultCodecs().jackson2JsonDecoder(jacksonDecoder); this.configurer.defaultCodecs().jackson2JsonEncoder(jacksonEncoder); + this.configurer.defaultCodecs().jackson2SmileDecoder(smileDecoder); + this.configurer.defaultCodecs().jackson2SmileEncoder(smileEncoder); this.configurer.defaultCodecs().protobufDecoder(protobufDecoder); this.configurer.defaultCodecs().protobufEncoder(protobufEncoder); this.configurer.defaultCodecs().jaxb2Decoder(jaxb2Decoder); this.configurer.defaultCodecs().jaxb2Encoder(jaxb2Encoder); assertDecoderInstance(jacksonDecoder); + assertDecoderInstance(smileDecoder); assertDecoderInstance(protobufDecoder); assertDecoderInstance(jaxb2Decoder); assertEncoderInstance(jacksonEncoder); + assertEncoderInstance(smileEncoder); assertEncoderInstance(protobufEncoder); assertEncoderInstance(jaxb2Encoder); } From 54669c51c927cda27a80fb4a3e56a3207942bb66 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Fri, 17 Jan 2020 13:43:29 +0100 Subject: [PATCH 0342/2315] Use Jackson SequenceWriter for streaming Before this commit, the AbstractJackson2Encoder instantiated a ObjectWriter per value. This is not an issue for single values or non-streaming scenarios (which effectively are the same, because in the latter values are collected into a list until offered to Jackson). However, this does create a problem for SMILE, because it allows for shared references that do not match up when writing each value with a new ObjectWriter, resulting in errors parsing the result. This commit uses Jackson's SequenceWriter for streaming scenarios, allowing Jackson to reuse the same context for writing multiple values, fixing the issue described above. Closes gh-24198 --- .../codec/json/AbstractJackson2Encoder.java | 165 ++++++++++++------ .../codec/json/Jackson2SmileEncoderTests.java | 78 ++++----- 2 files changed, 143 insertions(+), 100 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java index f0d2ad1b59ce..b195c9acd61f 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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.http.codec.json; import java.io.IOException; -import java.io.OutputStream; import java.lang.annotation.Annotation; import java.nio.charset.Charset; import java.util.ArrayList; @@ -29,9 +28,11 @@ import com.fasterxml.jackson.core.JsonEncoding; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.util.ByteArrayBuilder; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; +import com.fasterxml.jackson.databind.SequenceWriter; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; @@ -44,7 +45,6 @@ import org.springframework.core.codec.Hints; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; -import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.log.LogFormatUtils; import org.springframework.http.MediaType; import org.springframework.http.codec.HttpMessageEncoder; @@ -115,32 +115,37 @@ public Flux encode(Publisher inputStream, DataBufferFactory buffe Assert.notNull(bufferFactory, "'bufferFactory' must not be null"); Assert.notNull(elementType, "'elementType' must not be null"); - JsonEncoding encoding = getJsonEncoding(mimeType); - if (inputStream instanceof Mono) { - return Mono.from(inputStream).map(value -> - encodeValue(value, bufferFactory, elementType, mimeType, hints, encoding)).flux(); + return Mono.from(inputStream) + .map(value -> encodeValue(value, bufferFactory, elementType, mimeType, hints)) + .flux(); } else { - return this.streamingMediaTypes.stream() - .filter(mediaType -> mediaType.isCompatibleWith(mimeType)) - .findFirst() - .map(mediaType -> { - byte[] separator = STREAM_SEPARATORS.getOrDefault(mediaType, NEWLINE_SEPARATOR); - return Flux.from(inputStream).map(value -> { - DataBuffer buffer = encodeValue( - value, bufferFactory, elementType, mimeType, hints, encoding); - if (separator != null) { - buffer.write(separator); - } - return buffer; - }); - }) - .orElseGet(() -> { - ResolvableType listType = ResolvableType.forClassWithGenerics(List.class, elementType); - return Flux.from(inputStream).collectList().map(list -> - encodeValue(list, bufferFactory, listType, mimeType, hints, encoding)).flux(); - }); + byte[] separator = streamSeparator(mimeType); + if (separator != null) { // streaming + try { + ObjectWriter writer = createObjectWriter(elementType, mimeType, hints); + ByteArrayBuilder byteBuilder = new ByteArrayBuilder(writer.getFactory()._getBufferRecycler()); + JsonEncoding encoding = getJsonEncoding(mimeType); + JsonGenerator generator = getObjectMapper().getFactory().createGenerator(byteBuilder, encoding); + SequenceWriter sequenceWriter = writer.writeValues(generator); + + return Flux.from(inputStream) + .map(value -> encodeStreamingValue(value, bufferFactory, hints, sequenceWriter, byteBuilder, + separator)); + } + catch (IOException ex) { + return Flux.error(ex); + } + } + else { // non-streaming + ResolvableType listType = ResolvableType.forClassWithGenerics(List.class, elementType); + return Flux.from(inputStream) + .collectList() + .map(list -> encodeValue(list, bufferFactory, listType, mimeType, hints)) + .flux(); + } + } } @@ -148,39 +153,43 @@ public Flux encode(Publisher inputStream, DataBufferFactory buffe public DataBuffer encodeValue(Object value, DataBufferFactory bufferFactory, ResolvableType valueType, @Nullable MimeType mimeType, @Nullable Map hints) { - return encodeValue(value, bufferFactory, valueType, mimeType, hints, getJsonEncoding(mimeType)); - } + ObjectWriter writer = createObjectWriter(valueType, mimeType, hints); + ByteArrayBuilder byteBuilder = new ByteArrayBuilder(writer.getFactory()._getBufferRecycler()); + JsonEncoding encoding = getJsonEncoding(mimeType); - private DataBuffer encodeValue(Object value, DataBufferFactory bufferFactory, ResolvableType valueType, - @Nullable MimeType mimeType, @Nullable Map hints, JsonEncoding encoding) { + logValue(hints, value); - if (!Hints.isLoggingSuppressed(hints)) { - LogFormatUtils.traceDebug(logger, traceOn -> { - String formatted = LogFormatUtils.formatValue(value, !traceOn); - return Hints.getLogPrefix(hints) + "Encoding [" + formatted + "]"; - }); + try { + JsonGenerator generator = getObjectMapper().getFactory().createGenerator(byteBuilder, encoding); + writer.writeValue(generator, value); + generator.flush(); + } + catch (InvalidDefinitionException ex) { + throw new CodecException("Type definition error: " + ex.getType(), ex); + } + catch (JsonProcessingException ex) { + throw new EncodingException("JSON encoding error: " + ex.getOriginalMessage(), ex); + } + catch (IOException ex) { + throw new IllegalStateException("Unexpected I/O error while writing to byte array builder", + ex); } - JavaType javaType = getJavaType(valueType.getType(), null); - Class jsonView = (hints != null ? (Class) hints.get(Jackson2CodecSupport.JSON_VIEW_HINT) : null); - ObjectWriter writer = (jsonView != null ? - getObjectMapper().writerWithView(jsonView) : getObjectMapper().writer()); + byte[] bytes = byteBuilder.toByteArray(); + DataBuffer buffer = bufferFactory.allocateBuffer(bytes.length); + buffer.write(bytes); - if (javaType.isContainerType()) { - writer = writer.forType(javaType); - } + return buffer; + } - writer = customizeWriter(writer, mimeType, valueType, hints); + private DataBuffer encodeStreamingValue(Object value, DataBufferFactory bufferFactory, @Nullable Map hints, + SequenceWriter sequenceWriter, ByteArrayBuilder byteArrayBuilder, byte[] separator) { - DataBuffer buffer = bufferFactory.allocateBuffer(); - boolean release = true; - OutputStream outputStream = buffer.asOutputStream(); + logValue(hints, value); try { - JsonGenerator generator = getObjectMapper().getFactory().createGenerator(outputStream, encoding); - writer.writeValue(generator, value); - generator.flush(); - release = false; + sequenceWriter.write(value); + sequenceWriter.flush(); } catch (InvalidDefinitionException ex) { throw new CodecException("Type definition error: " + ex.getType(), ex); @@ -189,24 +198,70 @@ private DataBuffer encodeValue(Object value, DataBufferFactory bufferFactory, Re throw new EncodingException("JSON encoding error: " + ex.getOriginalMessage(), ex); } catch (IOException ex) { - throw new IllegalStateException("Unexpected I/O error while writing to data buffer", + throw new IllegalStateException("Unexpected I/O error while writing to byte array builder", ex); } - finally { - if (release) { - DataBufferUtils.release(buffer); - } + + byte[] bytes = byteArrayBuilder.toByteArray(); + byteArrayBuilder.reset(); + + int offset; + int length; + if (bytes.length > 0 && bytes[0] == ' ') { + // SequenceWriter writes an unnecessary space in between values + offset = 1; + length = bytes.length - 1; + } + else { + offset = 0; + length = bytes.length; } + DataBuffer buffer = bufferFactory.allocateBuffer(length + separator.length); + buffer.write(bytes, offset, length); + buffer.write(separator); return buffer; } + private void logValue(@Nullable Map hints, Object value) { + if (!Hints.isLoggingSuppressed(hints)) { + LogFormatUtils.traceDebug(logger, traceOn -> { + String formatted = LogFormatUtils.formatValue(value, !traceOn); + return Hints.getLogPrefix(hints) + "Encoding [" + formatted + "]"; + }); + } + } + + private ObjectWriter createObjectWriter(ResolvableType valueType, @Nullable MimeType mimeType, + @Nullable Map hints) { + JavaType javaType = getJavaType(valueType.getType(), null); + Class jsonView = (hints != null ? (Class) hints.get(Jackson2CodecSupport.JSON_VIEW_HINT) : null); + ObjectWriter writer = (jsonView != null ? + getObjectMapper().writerWithView(jsonView) : getObjectMapper().writer()); + + if (javaType.isContainerType()) { + writer = writer.forType(javaType); + } + + return customizeWriter(writer, mimeType, valueType, hints); + } + protected ObjectWriter customizeWriter(ObjectWriter writer, @Nullable MimeType mimeType, ResolvableType elementType, @Nullable Map hints) { return writer; } + @Nullable + private byte[] streamSeparator(@Nullable MimeType mimeType) { + for (MediaType streamingMediaType : this.streamingMediaTypes) { + if (streamingMediaType.isCompatibleWith(mimeType)) { + return STREAM_SEPARATORS.getOrDefault(streamingMediaType, NEWLINE_SEPARATOR); + } + } + return null; + } + /** * Determine the JSON encoding to use for the given mime type. * @param mimeType the mime type as requested by the caller diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java index ef2a9d84883a..32b15ba0b52f 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -20,17 +20,18 @@ import java.io.UncheckedIOException; import java.util.Arrays; import java.util.List; -import java.util.function.Consumer; +import com.fasterxml.jackson.databind.MappingIterator; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.testfixture.codec.AbstractEncoderTests; -import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils; import org.springframework.http.codec.ServerSentEvent; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.util.MimeType; @@ -59,21 +60,6 @@ public Jackson2SmileEncoderTests() { } - public Consumer pojoConsumer(Pojo expected) { - return dataBuffer -> { - try { - Pojo actual = this.mapper.reader().forType(Pojo.class) - .readValue(DataBufferTestUtils.dumpBytes(dataBuffer)); - assertThat(actual).isEqualTo(expected); - release(dataBuffer); - } - catch (IOException ex) { - throw new UncheckedIOException(ex); - } - }; - } - - @Override @Test public void canEncode() { @@ -106,7 +92,19 @@ public void encode() { Flux input = Flux.fromIterable(list); testEncode(input, Pojo.class, step -> step - .consumeNextWith(expect(list, List.class))); + .consumeNextWith(dataBuffer -> { + try { + Object actual = this.mapper.reader().forType(List.class) + .readValue(dataBuffer.asInputStream()); + assertThat(actual).isEqualTo(list); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + finally { + release(dataBuffer); + } + })); } @Test @@ -127,32 +125,22 @@ public void encodeAsStream() throws Exception { Flux input = Flux.just(pojo1, pojo2, pojo3); ResolvableType type = ResolvableType.forClass(Pojo.class); - testEncodeAll(input, type, step -> step - .consumeNextWith(expect(pojo1, Pojo.class)) - .consumeNextWith(expect(pojo2, Pojo.class)) - .consumeNextWith(expect(pojo3, Pojo.class)) - .verifyComplete(), - STREAM_SMILE_MIME_TYPE, null); + Flux result = this.encoder + .encode(input, bufferFactory, type, STREAM_SMILE_MIME_TYPE, null); + + Mono> joined = DataBufferUtils.join(result) + .map(buffer -> { + try { + return this.mapper.reader().forType(Pojo.class).readValues(buffer.asInputStream(true)); + } + catch (IOException ex) { + throw new UncheckedIOException(ex); + } + }); + + StepVerifier.create(joined) + .assertNext(iter -> assertThat(iter).toIterable().contains(pojo1, pojo2, pojo3)) + .verifyComplete(); } - - private Consumer expect(T expected, Class expectedType) { - return dataBuffer -> { - try { - Object actual = this.mapper.reader().forType(expectedType) - .readValue(dataBuffer.asInputStream()); - assertThat(actual).isEqualTo(expected); - } - catch (IOException e) { - throw new UncheckedIOException(e); - } - finally { - release(dataBuffer); - } - }; - - } - - - } From 7453c0d0cb4646ddea56182ec3511ceeaf179b1f Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 21 Jan 2020 11:06:49 +0000 Subject: [PATCH 0343/2315] Deprecate config options to match by path extension See gh-24179 --- .../annotation/PathMatchConfigurer.java | 59 +++++++++++++------ .../WebMvcConfigurationSupport.java | 3 +- .../condition/PatternsRequestCondition.java | 39 +++++++++--- .../mvc/method/RequestMappingInfo.java | 25 +++++++- .../RequestMappingHandlerMapping.java | 40 +++++++++++-- 5 files changed, 133 insertions(+), 33 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/PathMatchConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/PathMatchConfigurer.java index fc20853ebe3b..50d6716eb98a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/PathMatchConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/PathMatchConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -22,6 +22,7 @@ import org.springframework.lang.Nullable; import org.springframework.util.PathMatcher; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import org.springframework.web.util.UrlPathHelper; /** @@ -37,7 +38,7 @@ * * @author Brian Clozel * @since 4.0.3 - * @see org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping + * @see RequestMappingHandlerMapping * @see org.springframework.web.servlet.handler.SimpleUrlHandlerMapping */ public class PathMatchConfigurer { @@ -46,10 +47,10 @@ public class PathMatchConfigurer { private Boolean suffixPatternMatch; @Nullable - private Boolean trailingSlashMatch; + private Boolean registeredSuffixPatternMatch; @Nullable - private Boolean registeredSuffixPatternMatch; + private Boolean trailingSlashMatch; @Nullable private UrlPathHelper urlPathHelper; @@ -66,22 +67,16 @@ public class PathMatchConfigurer { * requests. If enabled a method mapped to "/users" also matches to "/users.*". *

    By default this is set to {@code true}. * @see #registeredSuffixPatternMatch + * @deprecated as of 5.2.4. See class-level note in + * {@link RequestMappingHandlerMapping} on the deprecation of path extension + * config options. */ + @Deprecated public PathMatchConfigurer setUseSuffixPatternMatch(Boolean suffixPatternMatch) { this.suffixPatternMatch = suffixPatternMatch; return this; } - /** - * Whether to match to URLs irrespective of the presence of a trailing slash. - * If enabled a method mapped to "/users" also matches to "/users/". - *

    The default value is {@code true}. - */ - public PathMatchConfigurer setUseTrailingSlashMatch(Boolean trailingSlashMatch) { - this.trailingSlashMatch = trailingSlashMatch; - return this; - } - /** * Whether suffix pattern matching should work only against path extensions * explicitly registered when you @@ -90,12 +85,26 @@ public PathMatchConfigurer setUseTrailingSlashMatch(Boolean trailingSlashMatch) * avoid issues such as when a "." appears in the path for other reasons. *

    By default this is set to "false". * @see WebMvcConfigurer#configureContentNegotiation + * @deprecated as of 5.2.4. See class-level note in + * {@link RequestMappingHandlerMapping} on the deprecation of path extension + * config options. */ + @Deprecated public PathMatchConfigurer setUseRegisteredSuffixPatternMatch(Boolean registeredSuffixPatternMatch) { this.registeredSuffixPatternMatch = registeredSuffixPatternMatch; return this; } + /** + * Whether to match to URLs irrespective of the presence of a trailing slash. + * If enabled a method mapped to "/users" also matches to "/users/". + *

    The default value is {@code true}. + */ + public PathMatchConfigurer setUseTrailingSlashMatch(Boolean trailingSlashMatch) { + this.trailingSlashMatch = trailingSlashMatch; + return this; + } + /** * Set the UrlPathHelper to use for resolution of lookup paths. *

    Use this to override the default UrlPathHelper with a custom subclass, @@ -137,19 +146,33 @@ public PathMatchConfigurer addPathPrefix(String prefix, Predicate> pred } + /** + * Whether to use registered suffixes for pattern matching. + * @deprecated as of 5.2.4. See class-level note in + * {@link RequestMappingHandlerMapping} on the deprecation of path extension + * config options. + */ @Nullable + @Deprecated public Boolean isUseSuffixPatternMatch() { return this.suffixPatternMatch; } + /** + * Whether to use registered suffixes for pattern matching. + * @deprecated as of 5.2.4. See class-level note in + * {@link RequestMappingHandlerMapping} on the deprecation of path extension + * config options. + */ @Nullable - public Boolean isUseTrailingSlashMatch() { - return this.trailingSlashMatch; + @Deprecated + public Boolean isUseRegisteredSuffixPatternMatch() { + return this.registeredSuffixPatternMatch; } @Nullable - public Boolean isUseRegisteredSuffixPatternMatch() { - return this.registeredSuffixPatternMatch; + public Boolean isUseTrailingSlashMatch() { + return this.trailingSlashMatch; } @Nullable diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java index d8f93bf4e545..1000fe12b7d9 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -275,6 +275,7 @@ public final ServletContext getServletContext() { * requests to annotated controllers. */ @Bean + @SuppressWarnings("deprecation") public RequestMappingHandlerMapping requestMappingHandlerMapping( @Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager, @Qualifier("mvcConversionService") FormattingConversionService conversionService, diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java index 1c1fd482c5f4..f5df9068803e 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -33,6 +33,7 @@ import org.springframework.util.PathMatcher; import org.springframework.util.StringUtils; import org.springframework.web.servlet.HandlerMapping; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import org.springframework.web.util.UrlPathHelper; /** @@ -58,23 +59,42 @@ public final class PatternsRequestCondition extends AbstractRequestCondition fileExtensions) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java index fe79fd341e81..7d7283999617 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -35,6 +35,7 @@ import org.springframework.web.servlet.mvc.condition.RequestCondition; import org.springframework.web.servlet.mvc.condition.RequestConditionHolder; import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import org.springframework.web.util.UrlPathHelper; /** @@ -505,6 +506,7 @@ public Builder options(BuilderConfiguration options) { } @Override + @SuppressWarnings("deprecation") public RequestMappingInfo build() { ContentNegotiationManager manager = this.options.getContentNegotiationManager(); @@ -600,14 +602,22 @@ public boolean useTrailingSlashMatch() { * Set whether to apply suffix pattern matching in PatternsRequestCondition. *

    By default this is set to 'true'. * @see #setRegisteredSuffixPatternMatch(boolean) + * @deprecated as of 5.2.4. See class-level note in + * {@link RequestMappingHandlerMapping} on the deprecation of path + * extension config options. */ + @Deprecated public void setSuffixPatternMatch(boolean suffixPatternMatch) { this.suffixPatternMatch = suffixPatternMatch; } /** * Return whether to apply suffix pattern matching in PatternsRequestCondition. + * @deprecated as of 5.2.4. See class-level note in + * {@link RequestMappingHandlerMapping} on the deprecation of path + * extension config options. */ + @Deprecated public boolean useSuffixPatternMatch() { return this.suffixPatternMatch; } @@ -618,7 +628,12 @@ public boolean useSuffixPatternMatch() { * {@code suffixPatternMatch=true} and requires that a * {@link #setContentNegotiationManager} is also configured in order to * obtain the registered file extensions. + * @deprecated as of 5.2.4. See class-level note in + * {@link RequestMappingHandlerMapping} on the deprecation of path + * extension config options; note also that in 5.3 the default for this + * property switches from {@code false} to {@code true}. */ + @Deprecated public void setRegisteredSuffixPatternMatch(boolean registeredSuffixPatternMatch) { this.registeredSuffixPatternMatch = registeredSuffixPatternMatch; this.suffixPatternMatch = (registeredSuffixPatternMatch || this.suffixPatternMatch); @@ -627,7 +642,11 @@ public void setRegisteredSuffixPatternMatch(boolean registeredSuffixPatternMatch /** * Return whether suffix pattern matching should be restricted to registered * file extensions only. + * @deprecated as of 5.2.4. See class-level note in + * {@link RequestMappingHandlerMapping} on the deprecation of path + * extension config options. */ + @Deprecated public boolean useRegisteredSuffixPatternMatch() { return this.registeredSuffixPatternMatch; } @@ -636,8 +655,12 @@ public boolean useRegisteredSuffixPatternMatch() { * Return the file extensions to use for suffix pattern matching. If * {@code registeredSuffixPatternMatch=true}, the extensions are obtained * from the configured {@code contentNegotiationManager}. + * @deprecated as of 5.2.4. See class-level note in + * {@link RequestMappingHandlerMapping} on the deprecation of path + * extension config options. */ @Nullable + @Deprecated public List getFileExtensions() { if (useRegisteredSuffixPatternMatch() && this.contentNegotiationManager != null) { return this.contentNegotiationManager.getAllFileExtensions(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java index 3dadc61a370e..5b6d42ed49e0 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -59,6 +59,18 @@ * {@link RequestMapping @RequestMapping} annotations in * {@link Controller @Controller} classes. * + *

    Note:

    In 5.2.4, + * {@link #setUseSuffixPatternMatch(boolean) useSuffixPatternMatch} and + * {@link #setUseRegisteredSuffixPatternMatch(boolean) useRegisteredSuffixPatternMatch} + * are deprecated in order to discourage use of path extensions for request + * mapping and for content negotiation (with similar deprecations in + * {@link ContentNegotiationManager}). For further context, please read issue + * #24719. + * + *

    In 5.3, {@link #setUseRegisteredSuffixPatternMatch(boolean) useRegisteredSuffixPatternMatch} + * switches to being on by default so that path matching becomes constrained + * to registered suffixes only. + * * @author Arjen Poutsma * @author Rossen Stoyanchev * @author Sam Brannen @@ -89,7 +101,10 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi *

    The default value is {@code true}. *

    Also see {@link #setUseRegisteredSuffixPatternMatch(boolean)} for * more fine-grained control over specific suffixes to allow. + * @deprecated as of 5.2.4. See class level comment about deprecation of + * path extension config options. */ + @Deprecated public void setUseSuffixPatternMatch(boolean useSuffixPatternMatch) { this.useSuffixPatternMatch = useSuffixPatternMatch; } @@ -100,7 +115,11 @@ public void setUseSuffixPatternMatch(boolean useSuffixPatternMatch) { * is generally recommended to reduce ambiguity and to avoid issues such as * when a "." appears in the path for other reasons. *

    By default this is set to "false". + * @deprecated as of 5.2.4. See class level comment about deprecation of + * path extension config options note also that in 5.3 the default for this + * property will switch from {@code false} to {@code true}. */ + @Deprecated public void setUseRegisteredSuffixPatternMatch(boolean useRegisteredSuffixPatternMatch) { this.useRegisteredSuffixPatternMatch = useRegisteredSuffixPatternMatch; this.useSuffixPatternMatch = (useRegisteredSuffixPatternMatch || this.useSuffixPatternMatch); @@ -159,13 +178,14 @@ public void setEmbeddedValueResolver(StringValueResolver resolver) { } @Override + @SuppressWarnings("deprecation") public void afterPropertiesSet() { this.config = new RequestMappingInfo.BuilderConfiguration(); this.config.setUrlPathHelper(getUrlPathHelper()); this.config.setPathMatcher(getPathMatcher()); - this.config.setSuffixPatternMatch(this.useSuffixPatternMatch); - this.config.setTrailingSlashMatch(this.useTrailingSlashMatch); - this.config.setRegisteredSuffixPatternMatch(this.useRegisteredSuffixPatternMatch); + this.config.setSuffixPatternMatch(useSuffixPatternMatch()); + this.config.setTrailingSlashMatch(useTrailingSlashMatch()); + this.config.setRegisteredSuffixPatternMatch(useRegisteredSuffixPatternMatch()); this.config.setContentNegotiationManager(getContentNegotiationManager()); super.afterPropertiesSet(); @@ -173,15 +193,21 @@ public void afterPropertiesSet() { /** - * Whether to use suffix pattern matching. + * Whether to use registered suffixes for pattern matching. + * @deprecated as of 5.2.4. See class-level note on the deprecation of path + * extension config options. */ + @Deprecated public boolean useSuffixPatternMatch() { return this.useSuffixPatternMatch; } /** * Whether to use registered suffixes for pattern matching. + * @deprecated as of 5.2.4. See class-level note on the deprecation of path + * extension config options. */ + @Deprecated public boolean useRegisteredSuffixPatternMatch() { return this.useRegisteredSuffixPatternMatch; } @@ -195,8 +221,12 @@ public boolean useTrailingSlashMatch() { /** * Return the file extensions to use for suffix pattern matching. + * @deprecated as of 5.2.4. See class-level note on the deprecation of path + * extension config options. */ @Nullable + @Deprecated + @SuppressWarnings("deprecation") public List getFileExtensions() { return this.config.getFileExtensions(); } From 214ba631279461c6fe4a40de354c675231d118bc Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 21 Jan 2020 21:25:36 +0000 Subject: [PATCH 0344/2315] Deprecate config options for content negotiation by path extension See gh-24179 --- .../ContentNegotiationManagerFactoryBean.java | 27 ++++++++++++------- .../ContentNegotiationConfigurer.java | 14 +++++++--- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java index f49cff639527..91c319393408 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -81,15 +81,18 @@ * * * - *

    As of 5.0 you can set the exact strategies to use via + *

    Alternatively you can avoid use of the above convenience builder + * methods and set the exact strategies to use via * {@link #setStrategies(List)}. * - *

    Note: if you must use URL-based content type resolution, - * the use of a query parameter is simpler and preferable to the use of a path - * extension since the latter can cause issues with URI variables, path - * parameters, and URI decoding. Consider setting {@link #setFavorPathExtension} - * to {@literal false} or otherwise set the strategies to use explicitly via - * {@link #setStrategies(List)}. + *

    Note: As of 5.2.4, + * {@link #setFavorPathExtension(boolean) favorPathExtension} and + * {@link #setIgnoreUnknownPathExtensions(boolean) ignoreUnknownPathExtensions} + * are deprecated in order to discourage use of path extensions for content + * negotiation and for request mapping (with similar deprecations in + * {@link org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping + * RequestMappingHandlerMapping}). For further context, please read issue + * #24719. * * @author Rossen Stoyanchev * @author Brian Clozel @@ -145,7 +148,10 @@ public void setStrategies(@Nullable List strategies) *

    By default this is set to {@code true} in which case a request * for {@code /hotels.pdf} will be interpreted as a request for * {@code "application/pdf"} regardless of the 'Accept' header. + * @deprecated as of 5.2.4. See class-level note on the deprecation of path + * extension config options. */ + @Deprecated public void setFavorPathExtension(boolean favorPathExtension) { this.favorPathExtension = favorPathExtension; } @@ -199,7 +205,10 @@ public void addMediaTypes(@Nullable Map mediaTypes) { * to any media type. Setting this to {@code false} will result in an * {@code HttpMediaTypeNotAcceptableException} if there is no match. *

    By default this is set to {@code true}. + * @deprecated as of 5.2.4. See class-level note on the deprecation of path + * extension config options. */ + @Deprecated public void setIgnoreUnknownPathExtensions(boolean ignore) { this.ignoreUnknownPathExtensions = ignore; } @@ -303,7 +312,7 @@ public void afterPropertiesSet() { } /** - * Actually build the {@link ContentNegotiationManager}. + * Create and initialize a {@link ContentNegotiationManager} instance. * @since 5.0 */ public ContentNegotiationManager build() { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java index 6b0c2522ea58..b1ce0732555d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -32,7 +32,6 @@ import org.springframework.web.accept.FixedContentNegotiationStrategy; import org.springframework.web.accept.HeaderContentNegotiationStrategy; import org.springframework.web.accept.ParameterContentNegotiationStrategy; -import org.springframework.web.accept.PathExtensionContentNegotiationStrategy; /** * Creates a {@code ContentNegotiationManager} and configures it with @@ -52,7 +51,8 @@ * * {@link #favorPathExtension} * true - * {@link PathExtensionContentNegotiationStrategy} + * {@link org.springframework.web.accept.PathExtensionContentNegotiationStrategy + * PathExtensionContentNegotiationStrategy} * Enabled * * @@ -129,7 +129,11 @@ public void strategies(@Nullable List strategies) { *

    By default this is set to {@code true} in which case a request * for {@code /hotels.pdf} will be interpreted as a request for * {@code "application/pdf"} regardless of the 'Accept' header. + * @deprecated as of 5.2.4. See class-level note in + * {@link ContentNegotiationManagerFactoryBean} on the deprecation of path + * extension config options. */ + @Deprecated public ContentNegotiationConfigurer favorPathExtension(boolean favorPathExtension) { this.factory.setFavorPathExtension(favorPathExtension); return this; @@ -183,7 +187,11 @@ public ContentNegotiationConfigurer replaceMediaTypes(Map med * to any media type. Setting this to {@code false} will result in an * {@code HttpMediaTypeNotAcceptableException} if there is no match. *

    By default this is set to {@code true}. + * @deprecated as of 5.2.4. See class-level note in + * {@link ContentNegotiationManagerFactoryBean} on the deprecation of path + * extension config options. */ + @Deprecated public ContentNegotiationConfigurer ignoreUnknownPathExtensions(boolean ignore) { this.factory.setIgnoreUnknownPathExtensions(ignore); return this; From 542e1878317c66cbcdd0e1129441a94d12848cdb Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 22 Jan 2020 12:32:52 +0000 Subject: [PATCH 0345/2315] Expose media type mappings in ContentNegotiationManager ContentNegotiationManagerFactoryBean now ensures that ContentNegotiationManager contains the MediaType mappings even if the path extension and the parameter strategies are off. There are also minor fixes to ensure the media type mappings in ContentNegotiationManagerFactoryBean aren't polluted when mapping keys are not lowercase, and likewise MappingMediaTypeFileExtensionResolver filters out duplicates in the list of all file extensions. See gh-24179 --- .../web/accept/ContentNegotiationManager.java | 51 +++++++-- .../ContentNegotiationManagerFactoryBean.java | 65 ++++++----- ...MappingMediaTypeFileExtensionResolver.java | 6 +- ...entNegotiationManagerFactoryBeanTests.java | 102 ++++++++++++++---- ...ngMediaTypeFileExtensionResolverTests.java | 33 +++--- 5 files changed, 185 insertions(+), 72 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManager.java b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManager.java index 8ad0110deb56..5f3b76d7a488 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManager.java +++ b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -20,13 +20,17 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.function.Function; import org.springframework.http.MediaType; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; import org.springframework.web.HttpMediaTypeNotAcceptableException; import org.springframework.web.context.request.NativeWebRequest; @@ -132,11 +136,7 @@ public List resolveMediaTypes(NativeWebRequest request) throws HttpMe @Override public List resolveFileExtensions(MediaType mediaType) { - Set result = new LinkedHashSet<>(); - for (MediaTypeFileExtensionResolver resolver : this.resolvers) { - result.addAll(resolver.resolveFileExtensions(mediaType)); - } - return new ArrayList<>(result); + return doResolveExtensions(resolver -> resolver.resolveFileExtensions(mediaType)); } /** @@ -152,11 +152,44 @@ public List resolveFileExtensions(MediaType mediaType) { */ @Override public List getAllFileExtensions() { - Set result = new LinkedHashSet<>(); + return doResolveExtensions(MediaTypeFileExtensionResolver::getAllFileExtensions); + } + + private List doResolveExtensions(Function> extractor) { + List result = null; + for (MediaTypeFileExtensionResolver resolver : this.resolvers) { + List extensions = extractor.apply(resolver); + if (CollectionUtils.isEmpty(extensions)) { + continue; + } + result = (result != null ? result : new ArrayList<>(4)); + for (String extension : extensions) { + if (!result.contains(extension)) { + result.add(extension); + } + } + } + return (result != null ? result : Collections.emptyList()); + } + + /** + * Return all registered lookup key to media type mappings by iterating + * {@link MediaTypeFileExtensionResolver}s. + * @since 5.2.4 + */ + public Map getMediaTypeMappings() { + Map result = null; for (MediaTypeFileExtensionResolver resolver : this.resolvers) { - result.addAll(resolver.getAllFileExtensions()); + if (resolver instanceof MappingMediaTypeFileExtensionResolver) { + Map map = ((MappingMediaTypeFileExtensionResolver) resolver).getMediaTypes(); + if (CollectionUtils.isEmpty(map)) { + continue; + } + result = (result != null ? result : new HashMap<>(4)); + result.putAll(map); + } } - return new ArrayList<>(result); + return (result != null ? result : Collections.emptyMap()); } } diff --git a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java index 91c319393408..42f515914105 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java @@ -89,7 +89,7 @@ * {@link #setFavorPathExtension(boolean) favorPathExtension} and * {@link #setIgnoreUnknownPathExtensions(boolean) ignoreUnknownPathExtensions} * are deprecated in order to discourage use of path extensions for content - * negotiation and for request mapping (with similar deprecations in + * negotiation as well as for request mapping (with similar deprecations in * {@link org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping * RequestMappingHandlerMapping}). For further context, please read issue * #24719. @@ -157,46 +157,52 @@ public void setFavorPathExtension(boolean favorPathExtension) { } /** - * Add a mapping from a key, extracted from a path extension or a query - * parameter, to a MediaType. This is required in order for the parameter - * strategy to work. Any extensions explicitly registered here are also - * whitelisted for the purpose of Reflected File Download attack detection - * (see Spring Framework reference documentation for more details on RFD - * attack protection). - *

    The path extension strategy will also try to use + * Add a mapping from a key to a MediaType where the key are normalized to + * lowercase and may have been extracted from a path extension, a filename + * extension, or passed as a query parameter. + *

    The {@link #setFavorParameter(boolean) parameter strategy} requires + * such mappings in order to work while the {@link #setFavorPathExtension(boolean) + * path extension strategy} can fall back on lookups via * {@link ServletContext#getMimeType} and - * {@link org.springframework.http.MediaTypeFactory} to resolve path extensions. + * {@link org.springframework.http.MediaTypeFactory}. + *

    Note: Mappings registered here may be accessed via + * {@link ContentNegotiationManager#getMediaTypeMappings()} and may be used + * not only in the parameter and path extension strategies. For example, + * with the Spring MVC config, e.g. {@code @EnableWebMvc} or + * {@code }, the media type mappings are also plugged + * in to: + *

      + *
    • Determine the media type of static resources served with + * {@code ResourceHttpRequestHandler}. + *
    • Determine the media type of views rendered with + * {@code ContentNegotiatingViewResolver}. + *
    • Whitelist extensions for RFD attack detection (check the Spring + * Framework reference docs for details). + *
    * @param mediaTypes media type mappings * @see #addMediaType(String, MediaType) * @see #addMediaTypes(Map) */ public void setMediaTypes(Properties mediaTypes) { if (!CollectionUtils.isEmpty(mediaTypes)) { - mediaTypes.forEach((key, value) -> { - String extension = ((String) key).toLowerCase(Locale.ENGLISH); - MediaType mediaType = MediaType.valueOf((String) value); - this.mediaTypes.put(extension, mediaType); - }); + mediaTypes.forEach((key, value) -> + addMediaType((String) key, MediaType.valueOf((String) value))); } } /** - * An alternative to {@link #setMediaTypes} for use in Java code. - * @see #setMediaTypes - * @see #addMediaTypes + * An alternative to {@link #setMediaTypes} for programmatic registrations. */ - public void addMediaType(String fileExtension, MediaType mediaType) { - this.mediaTypes.put(fileExtension, mediaType); + public void addMediaType(String key, MediaType mediaType) { + this.mediaTypes.put(key.toLowerCase(Locale.ENGLISH), mediaType); } /** - * An alternative to {@link #setMediaTypes} for use in Java code. - * @see #setMediaTypes - * @see #addMediaType + * An alternative to {@link #setMediaTypes} for programmatic registrations. */ public void addMediaTypes(@Nullable Map mediaTypes) { if (mediaTypes != null) { - this.mediaTypes.putAll(mediaTypes); + mediaTypes.forEach(this::addMediaType); } } @@ -315,6 +321,7 @@ public void afterPropertiesSet() { * Create and initialize a {@link ContentNegotiationManager} instance. * @since 5.0 */ + @SuppressWarnings("deprecation") public ContentNegotiationManager build() { List strategies = new ArrayList<>(); @@ -336,7 +343,6 @@ public ContentNegotiationManager build() { } strategies.add(strategy); } - if (this.favorParameter) { ParameterContentNegotiationStrategy strategy = new ParameterContentNegotiationStrategy(this.mediaTypes); strategy.setParameterName(this.parameterName); @@ -348,17 +354,24 @@ public ContentNegotiationManager build() { } strategies.add(strategy); } - if (!this.ignoreAcceptHeader) { strategies.add(new HeaderContentNegotiationStrategy()); } - if (this.defaultNegotiationStrategy != null) { strategies.add(this.defaultNegotiationStrategy); } } this.contentNegotiationManager = new ContentNegotiationManager(strategies); + + // Ensure media type mappings are available via ContentNegotiationManager#getMediaTypeMappings() + // independent of path extension or parameter strategies. + + if (!CollectionUtils.isEmpty(this.mediaTypes) && !this.favorPathExtension && !this.favorParameter) { + this.contentNegotiationManager.addFileExtensionResolvers( + new MappingMediaTypeFileExtensionResolver(this.mediaTypes)); + } + return this.contentNegotiationManager; } diff --git a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java index 25147843b78c..a0ee49a56953 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java +++ b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -18,9 +18,11 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -53,7 +55,7 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten */ public MappingMediaTypeFileExtensionResolver(@Nullable Map mediaTypes) { if (mediaTypes != null) { - List allFileExtensions = new ArrayList<>(); + Set allFileExtensions = new HashSet<>(mediaTypes.size()); mediaTypes.forEach((extension, mediaType) -> { String lowerCaseExtension = extension.toLowerCase(Locale.ENGLISH); this.mediaTypes.put(lowerCaseExtension, mediaType); diff --git a/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java b/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java index 1b5ac13d795f..2c0169c997f9 100644 --- a/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java +++ b/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Properties; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -70,21 +71,29 @@ public void defaultSettings() throws Exception { this.servletRequest.setRequestURI("/flower.gif"); - assertThat(manager.resolveMediaTypes(this.webRequest)).as("Should be able to resolve file extensions by default").isEqualTo(Collections.singletonList(MediaType.IMAGE_GIF)); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .as("Should be able to resolve file extensions by default") + .isEqualTo(Collections.singletonList(MediaType.IMAGE_GIF)); this.servletRequest.setRequestURI("/flower.foobarbaz"); - assertThat(manager.resolveMediaTypes(this.webRequest)).as("Should ignore unknown extensions by default").isEqualTo(ContentNegotiationStrategy.MEDIA_TYPE_ALL_LIST); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .as("Should ignore unknown extensions by default") + .isEqualTo(ContentNegotiationStrategy.MEDIA_TYPE_ALL_LIST); this.servletRequest.setRequestURI("/flower"); this.servletRequest.setParameter("format", "gif"); - assertThat(manager.resolveMediaTypes(this.webRequest)).as("Should not resolve request parameters by default").isEqualTo(ContentNegotiationStrategy.MEDIA_TYPE_ALL_LIST); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .as("Should not resolve request parameters by default") + .isEqualTo(ContentNegotiationStrategy.MEDIA_TYPE_ALL_LIST); this.servletRequest.setRequestURI("/flower"); this.servletRequest.addHeader("Accept", MediaType.IMAGE_GIF_VALUE); - assertThat(manager.resolveMediaTypes(this.webRequest)).as("Should resolve Accept header by default").isEqualTo(Collections.singletonList(MediaType.IMAGE_GIF)); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .as("Should resolve Accept header by default") + .isEqualTo(Collections.singletonList(MediaType.IMAGE_GIF)); } @Test @@ -101,29 +110,33 @@ public void explicitStrategies() throws Exception { this.servletRequest.setRequestURI("/flower"); this.servletRequest.addParameter("format", "bar"); - assertThat(manager.resolveMediaTypes(this.webRequest)).isEqualTo(Collections.singletonList(new MediaType("application", "bar"))); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .isEqualTo(Collections.singletonList(new MediaType("application", "bar"))); } @Test public void favorPath() throws Exception { this.factoryBean.setFavorPathExtension(true); - this.factoryBean.addMediaTypes(Collections.singletonMap("bar", new MediaType("application", "bar"))); + this.factoryBean.addMediaType("bar", new MediaType("application", "bar")); this.factoryBean.afterPropertiesSet(); ContentNegotiationManager manager = this.factoryBean.getObject(); this.servletRequest.setRequestURI("/flower.foo"); - assertThat(manager.resolveMediaTypes(this.webRequest)).isEqualTo(Collections.singletonList(new MediaType("application", "foo"))); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .isEqualTo(Collections.singletonList(new MediaType("application", "foo"))); this.servletRequest.setRequestURI("/flower.bar"); - assertThat(manager.resolveMediaTypes(this.webRequest)).isEqualTo(Collections.singletonList(new MediaType("application", "bar"))); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .isEqualTo(Collections.singletonList(new MediaType("application", "bar"))); this.servletRequest.setRequestURI("/flower.gif"); - assertThat(manager.resolveMediaTypes(this.webRequest)).isEqualTo(Collections.singletonList(MediaType.IMAGE_GIF)); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .isEqualTo(Collections.singletonList(MediaType.IMAGE_GIF)); } @Test // SPR-10170 - public void favorPathWithIgnoreUnknownPathExtensionTurnedOff() throws Exception { + public void favorPathWithIgnoreUnknownPathExtensionTurnedOff() { this.factoryBean.setFavorPathExtension(true); this.factoryBean.setIgnoreUnknownPathExtensions(false); this.factoryBean.afterPropertiesSet(); @@ -139,10 +152,7 @@ public void favorPathWithIgnoreUnknownPathExtensionTurnedOff() throws Exception @Test public void favorParameter() throws Exception { this.factoryBean.setFavorParameter(true); - - Map mediaTypes = new HashMap<>(); - mediaTypes.put("json", MediaType.APPLICATION_JSON); - this.factoryBean.addMediaTypes(mediaTypes); + this.factoryBean.addMediaType("json", MediaType.APPLICATION_JSON); this.factoryBean.afterPropertiesSet(); ContentNegotiationManager manager = this.factoryBean.getObject(); @@ -150,11 +160,12 @@ public void favorParameter() throws Exception { this.servletRequest.setRequestURI("/flower"); this.servletRequest.addParameter("format", "json"); - assertThat(manager.resolveMediaTypes(this.webRequest)).isEqualTo(Collections.singletonList(MediaType.APPLICATION_JSON)); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .isEqualTo(Collections.singletonList(MediaType.APPLICATION_JSON)); } @Test // SPR-10170 - public void favorParameterWithUnknownMediaType() throws HttpMediaTypeNotAcceptableException { + public void favorParameterWithUnknownMediaType() { this.factoryBean.setFavorParameter(true); this.factoryBean.afterPropertiesSet(); ContentNegotiationManager manager = this.factoryBean.getObject(); @@ -162,8 +173,52 @@ public void favorParameterWithUnknownMediaType() throws HttpMediaTypeNotAcceptab this.servletRequest.setRequestURI("/flower"); this.servletRequest.setParameter("format", "invalid"); - assertThatExceptionOfType(HttpMediaTypeNotAcceptableException.class).isThrownBy(() -> - manager.resolveMediaTypes(this.webRequest)); + assertThatExceptionOfType(HttpMediaTypeNotAcceptableException.class) + .isThrownBy(() -> manager.resolveMediaTypes(this.webRequest)); + } + + @Test + public void mediaTypeMappingsWithoutPathAndParameterStrategies() { + + this.factoryBean.setFavorPathExtension(false); + this.factoryBean.setFavorParameter(false); + + Properties properties = new Properties(); + properties.put("JSon", "application/json"); + + this.factoryBean.setMediaTypes(properties); + this.factoryBean.addMediaType("pdF", MediaType.APPLICATION_PDF); + this.factoryBean.addMediaTypes(Collections.singletonMap("xML", MediaType.APPLICATION_XML)); + + ContentNegotiationManager manager = this.factoryBean.build(); + assertThat(manager.getMediaTypeMappings()) + .hasSize(3) + .containsEntry("json", MediaType.APPLICATION_JSON) + .containsEntry("pdf", MediaType.APPLICATION_PDF) + .containsEntry("xml", MediaType.APPLICATION_XML); + } + + @Test + public void fileExtensions() { + + this.factoryBean.setFavorPathExtension(false); + this.factoryBean.setFavorParameter(false); + + Properties properties = new Properties(); + properties.put("json", "application/json"); + properties.put("pdf", "application/pdf"); + properties.put("xml", "application/xml"); + this.factoryBean.setMediaTypes(properties); + + this.factoryBean.addMediaType("jsON", MediaType.APPLICATION_JSON); + this.factoryBean.addMediaType("pdF", MediaType.APPLICATION_PDF); + + this.factoryBean.addMediaTypes(Collections.singletonMap("JSon", MediaType.APPLICATION_JSON)); + this.factoryBean.addMediaTypes(Collections.singletonMap("xML", MediaType.APPLICATION_XML)); + + ContentNegotiationManager manager = this.factoryBean.build(); + assertThat(manager.getAllFileExtensions()).containsExactlyInAnyOrder("json", "xml", "pdf"); + } @Test @@ -175,7 +230,8 @@ public void ignoreAcceptHeader() throws Exception { this.servletRequest.setRequestURI("/flower"); this.servletRequest.addHeader("Accept", MediaType.IMAGE_GIF_VALUE); - assertThat(manager.resolveMediaTypes(this.webRequest)).isEqualTo(ContentNegotiationStrategy.MEDIA_TYPE_ALL_LIST); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .isEqualTo(ContentNegotiationStrategy.MEDIA_TYPE_ALL_LIST); } @Test @@ -210,10 +266,12 @@ public void setDefaultContentTypeWithStrategy() throws Exception { this.factoryBean.afterPropertiesSet(); ContentNegotiationManager manager = this.factoryBean.getObject(); - assertThat(manager.resolveMediaTypes(this.webRequest)).isEqualTo(Collections.singletonList(MediaType.APPLICATION_JSON)); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .isEqualTo(Collections.singletonList(MediaType.APPLICATION_JSON)); this.servletRequest.addHeader("Accept", MediaType.ALL_VALUE); - assertThat(manager.resolveMediaTypes(this.webRequest)).isEqualTo(Collections.singletonList(MediaType.APPLICATION_JSON)); + assertThat(manager.resolveMediaTypes(this.webRequest)) + .isEqualTo(Collections.singletonList(MediaType.APPLICATION_JSON)); } diff --git a/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java b/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java index 873f521a9e7d..7f1907dba51a 100644 --- a/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java @@ -17,6 +17,7 @@ package org.springframework.web.accept; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -34,12 +35,14 @@ */ public class MappingMediaTypeFileExtensionResolverTests { - private final Map mapping = Collections.singletonMap("json", MediaType.APPLICATION_JSON); - private final MappingMediaTypeFileExtensionResolver resolver = new MappingMediaTypeFileExtensionResolver(this.mapping); + private static final Map DEFAULT_MAPPINGS = + Collections.singletonMap("json", MediaType.APPLICATION_JSON); + @Test public void resolveExtensions() { - List extensions = this.resolver.resolveFileExtensions(MediaType.APPLICATION_JSON); + List extensions = new MappingMediaTypeFileExtensionResolver(DEFAULT_MAPPINGS) + .resolveFileExtensions(MediaType.APPLICATION_JSON); assertThat(extensions).hasSize(1); assertThat(extensions.get(0)).isEqualTo("json"); @@ -47,20 +50,24 @@ public void resolveExtensions() { @Test public void resolveExtensionsNoMatch() { - List extensions = this.resolver.resolveFileExtensions(MediaType.TEXT_HTML); + assertThat(new MappingMediaTypeFileExtensionResolver(DEFAULT_MAPPINGS) + .resolveFileExtensions(MediaType.TEXT_HTML)).isEmpty(); + } - assertThat(extensions).isEmpty(); + @Test // SPR-13747 + public void lookupMediaTypeCaseInsensitive() { + assertThat(new MappingMediaTypeFileExtensionResolver(DEFAULT_MAPPINGS).lookupMediaType("JSON")) + .isEqualTo(MediaType.APPLICATION_JSON); } - /** - * Unit test for SPR-13747 - ensures that reverse lookup of media type from media - * type key is case-insensitive. - */ @Test - public void lookupMediaTypeCaseInsensitive() { - MediaType mediaType = this.resolver.lookupMediaType("JSON"); + public void allFileExtensions() { + Map mappings = new HashMap<>(); + mappings.put("json", MediaType.APPLICATION_JSON); + mappings.put("JsOn", MediaType.APPLICATION_JSON); + mappings.put("jSoN", MediaType.APPLICATION_JSON); - assertThat(mediaType).isEqualTo(MediaType.APPLICATION_JSON); + MappingMediaTypeFileExtensionResolver resolver = new MappingMediaTypeFileExtensionResolver(mappings); + assertThat(resolver.getAllFileExtensions()).containsExactly("json"); } - } From c69703ffdb032f70e640755de1b3fc270bea9920 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 22 Jan 2020 13:34:27 +0000 Subject: [PATCH 0346/2315] Deprecate path extension strategies This commit deprecates PathExtensionContentNegotiationStrategy and ServletPathExtensionContentNegotiationStrategy and also updates code that depends on them internally to remove that dependence. See gh-24179 --- .../setup/StandaloneMockMvcBuilder.java | 7 +- ...thExtensionContentNegotiationStrategy.java | 6 +- ...thExtensionContentNegotiationStrategy.java | 6 +- .../annotation/ResourceHandlerRegistry.java | 3 +- ...stractMessageConverterMethodProcessor.java | 39 ++---- .../resource/ResourceHttpRequestHandler.java | 112 +++++++++++++----- .../ResourceHttpRequestHandlerTests.java | 18 +-- src/docs/asciidoc/web/webmvc.adoc | 20 +++- 8 files changed, 138 insertions(+), 73 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java index 46209caddd12..554d7e85da70 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -310,7 +310,11 @@ public StandaloneMockMvcBuilder setFlashMapManager(FlashMapManager flashMapManag * Whether to use suffix pattern match (".*") when matching patterns to * requests. If enabled a method mapped to "/users" also matches to "/users.*". *

    The default value is {@code true}. + * @deprecated as of 5.2.4. See class-level note in + * {@link RequestMappingHandlerMapping} on the deprecation of path extension + * config options. */ + @Deprecated public StandaloneMockMvcBuilder setUseSuffixPatternMatch(boolean useSuffixPatternMatch) { this.useSuffixPatternMatch = useSuffixPatternMatch; return this; @@ -442,6 +446,7 @@ protected Map extendMvcSingletons(@Nullable ServletContext servl /** Using the MVC Java configuration as the starting point for the "standalone" setup. */ private class StandaloneConfiguration extends WebMvcConfigurationSupport { + @SuppressWarnings("deprecation") public RequestMappingHandlerMapping getHandlerMapping( FormattingConversionService mvcConversionService, ResourceUrlProvider mvcResourceUrlProvider) { diff --git a/spring-web/src/main/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategy.java b/spring-web/src/main/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategy.java index 2bee9a7b53e0..3fc337b377b6 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategy.java +++ b/spring-web/src/main/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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,7 +41,11 @@ * * @author Rossen Stoyanchev * @since 3.2 + * @deprecated as of 5.2.4. See class-level note in + * {@link ContentNegotiationManagerFactoryBean} on the deprecation of path + * extension config options. */ +@Deprecated public class PathExtensionContentNegotiationStrategy extends AbstractMappingContentNegotiationStrategy { private UrlPathHelper urlPathHelper = new UrlPathHelper(); diff --git a/spring-web/src/main/java/org/springframework/web/accept/ServletPathExtensionContentNegotiationStrategy.java b/spring-web/src/main/java/org/springframework/web/accept/ServletPathExtensionContentNegotiationStrategy.java index f47af3ca2f82..f2a549589665 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/ServletPathExtensionContentNegotiationStrategy.java +++ b/spring-web/src/main/java/org/springframework/web/accept/ServletPathExtensionContentNegotiationStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -34,7 +34,11 @@ * * @author Rossen Stoyanchev * @since 3.2 + * @deprecated as of 5.2.4. See class-level note in + * {@link ContentNegotiationManagerFactoryBean} on the deprecation of path + * extension config options. */ +@Deprecated public class ServletPathExtensionContentNegotiationStrategy extends PathExtensionContentNegotiationStrategy { private final ServletContext servletContext; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java index 772d8c1489ec..55a92e5a2010 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -151,6 +151,7 @@ public ResourceHandlerRegistry setOrder(int order) { * of no registrations. */ @Nullable + @SuppressWarnings("deprecation") protected AbstractHandlerMapping getHandlerMapping() { if (this.registrations.isEmpty()) { return null; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java index 61eaeac00d73..4e83bab4f837 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java @@ -26,6 +26,7 @@ import java.util.Locale; import java.util.Set; +import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -43,6 +44,7 @@ import org.springframework.http.HttpRange; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.MediaTypeFactory; import org.springframework.http.converter.GenericHttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageNotWritableException; @@ -54,7 +56,6 @@ import org.springframework.util.StringUtils; import org.springframework.web.HttpMediaTypeNotAcceptableException; import org.springframework.web.accept.ContentNegotiationManager; -import org.springframework.web.accept.PathExtensionContentNegotiationStrategy; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.method.support.HandlerMethodReturnValueHandler; @@ -102,8 +103,6 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe private final ContentNegotiationManager contentNegotiationManager; - private final PathExtensionContentNegotiationStrategy pathStrategy; - private final Set safeExtensions = new HashSet<>(); @@ -133,17 +132,10 @@ protected AbstractMessageConverterMethodProcessor(List> super(converters, requestResponseBodyAdvice); this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager()); - this.pathStrategy = initPathStrategy(this.contentNegotiationManager); this.safeExtensions.addAll(this.contentNegotiationManager.getAllFileExtensions()); this.safeExtensions.addAll(WHITELISTED_EXTENSIONS); } - private static PathExtensionContentNegotiationStrategy initPathStrategy(ContentNegotiationManager manager) { - Class clazz = PathExtensionContentNegotiationStrategy.class; - PathExtensionContentNegotiationStrategy strategy = manager.getStrategy(clazz); - return (strategy != null ? strategy : new PathExtensionContentNegotiationStrategy()); - } - /** * Creates a new {@link HttpOutputMessage} from the given {@link NativeWebRequest}. @@ -481,26 +473,21 @@ private boolean safeExtension(HttpServletRequest request, @Nullable String exten return true; } } - return safeMediaTypesForExtension(new ServletWebRequest(request), extension); + MediaType mediaType = resolveMediaType(request, extension); + return (mediaType != null && (safeMediaType(mediaType))); } - private boolean safeMediaTypesForExtension(NativeWebRequest request, String extension) { - List mediaTypes = null; - try { - mediaTypes = this.pathStrategy.resolveMediaTypeKey(request, extension); + @Nullable + private MediaType resolveMediaType(ServletRequest request, String extension) { + MediaType result = null; + String rawMimeType = request.getServletContext().getMimeType("file." + extension); + if (StringUtils.hasText(rawMimeType)) { + result = MediaType.parseMediaType(rawMimeType); } - catch (HttpMediaTypeNotAcceptableException ex) { - // Ignore - } - if (CollectionUtils.isEmpty(mediaTypes)) { - return false; - } - for (MediaType mediaType : mediaTypes) { - if (!safeMediaType(mediaType)) { - return false; - } + if (result == null || MediaType.APPLICATION_OCTET_STREAM.equals(result)) { + result = MediaTypeFactory.getMediaType("file." + extension).orElse(null); } - return true; + return result; } private boolean safeMediaType(MediaType mediaType) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java index 6dcf31c1d52e..186c79d7bb20 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -24,6 +24,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; @@ -43,6 +44,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpRange; import org.springframework.http.MediaType; +import org.springframework.http.MediaTypeFactory; import org.springframework.http.converter.ResourceHttpMessageConverter; import org.springframework.http.converter.ResourceRegionHttpMessageConverter; import org.springframework.http.server.ServletServerHttpRequest; @@ -56,8 +58,6 @@ import org.springframework.util.StringValueResolver; import org.springframework.web.HttpRequestHandler; import org.springframework.web.accept.ContentNegotiationManager; -import org.springframework.web.accept.PathExtensionContentNegotiationStrategy; -import org.springframework.web.accept.ServletPathExtensionContentNegotiationStrategy; import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfigurationSource; @@ -129,8 +129,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator @Nullable private ContentNegotiationManager contentNegotiationManager; - @Nullable - private PathExtensionContentNegotiationStrategy contentNegotiationStrategy; + private final Map mediaTypes = new HashMap<>(4); @Nullable private CorsConfiguration corsConfiguration; @@ -262,7 +261,11 @@ public ResourceRegionHttpMessageConverter getResourceRegionHttpMessageConverter( * media types for resources being served. If the manager contains a path * extension strategy it will be checked for registered file extension. * @since 4.3 + * @deprecated as of 5.2.4 in favor of using {@link #setMediaTypes(Map)} + * with mappings possibly obtained from + * {@link ContentNegotiationManager#getMediaTypeMappings()}. */ + @Deprecated public void setContentNegotiationManager(@Nullable ContentNegotiationManager contentNegotiationManager) { this.contentNegotiationManager = contentNegotiationManager; } @@ -270,12 +273,38 @@ public void setContentNegotiationManager(@Nullable ContentNegotiationManager con /** * Return the configured content negotiation manager. * @since 4.3 + * @deprecated as of 5.2.4. */ @Nullable + @Deprecated public ContentNegotiationManager getContentNegotiationManager() { return this.contentNegotiationManager; } + /** + * Add mappings between file extensions, extracted from the filename of a + * static {@link Resource}, and corresponding media type to set on the + * response. + *

    Use of this method is typically not necessary since mappings are + * otherwise determined via + * {@link javax.servlet.ServletContext#getMimeType(String)} or via + * {@link MediaTypeFactory#getMediaType(Resource)}. + * @param mediaTypes media type mappings + * @since 5.2.4 + */ + public void setMediaTypes(Map mediaTypes) { + mediaTypes.forEach((ext, mediaType) -> + this.mediaTypes.put(ext.toLowerCase(Locale.ENGLISH), mediaType)); + } + + /** + * Return the {@link #setMediaTypes(Map) configured} media types. + * @since 5.2.4 + */ + public Map getMediaTypes() { + return this.mediaTypes; + } + /** * Specify the CORS configuration for resources served by this handler. *

    By default this is not set in which allows cross-origin requests. @@ -344,7 +373,17 @@ public void afterPropertiesSet() throws Exception { this.resourceRegionHttpMessageConverter = new ResourceRegionHttpMessageConverter(); } - this.contentNegotiationStrategy = initContentNegotiationStrategy(); + ContentNegotiationManager manager = getContentNegotiationManager(); + if (manager != null) { + setMediaTypes(manager.getMediaTypeMappings()); + } + + @SuppressWarnings("deprecation") + org.springframework.web.accept.PathExtensionContentNegotiationStrategy strategy = + initContentNegotiationStrategy(); + if (strategy != null) { + setMediaTypes(strategy.getMediaTypes()); + } } private void resolveResourceLocations() { @@ -412,26 +451,20 @@ protected void initAllowedLocations() { } /** - * Initialize the content negotiation strategy depending on the {@code ContentNegotiationManager} - * setup and the availability of a {@code ServletContext}. - * @see ServletPathExtensionContentNegotiationStrategy - * @see PathExtensionContentNegotiationStrategy + * Initialize the strategy to use to determine the media type for a resource. + * @deprecated as of 5.2.4 this method returns {@code null}, and if a + * sub-class returns an actual instance,the instance is used only as a + * source of media type mappings, if it contains any. Please, use + * {@link #setMediaTypes(Map)} instead, or if you need to change behavior, + * you can override {@link #getMediaType(HttpServletRequest, Resource)}. */ - protected PathExtensionContentNegotiationStrategy initContentNegotiationStrategy() { - Map mediaTypes = null; - if (getContentNegotiationManager() != null) { - PathExtensionContentNegotiationStrategy strategy = - getContentNegotiationManager().getStrategy(PathExtensionContentNegotiationStrategy.class); - if (strategy != null) { - mediaTypes = new HashMap<>(strategy.getMediaTypes()); - } - } - return (getServletContext() != null ? - new ServletPathExtensionContentNegotiationStrategy(getServletContext(), mediaTypes) : - new PathExtensionContentNegotiationStrategy(mediaTypes)); + @Nullable + @Deprecated + @SuppressWarnings("deprecation") + protected org.springframework.web.accept.PathExtensionContentNegotiationStrategy initContentNegotiationStrategy() { + return null; } - /** * Processes a resource request. *

    Checks for the existence of the requested resource in the configured list of locations. @@ -659,17 +692,40 @@ protected boolean isInvalidPath(String path) { /** * Determine the media type for the given request and the resource matched - * to it. This implementation tries to determine the MediaType based on the - * file extension of the Resource via - * {@link ServletPathExtensionContentNegotiationStrategy#getMediaTypeForResource}. + * to it. This implementation tries to determine the MediaType using one of + * the following lookups based on the resource filename and its path + * extension: + *

      + *
    1. {@link javax.servlet.ServletContext#getMimeType(String)} + *
    2. {@link #getMediaTypes()} + *
    3. {@link MediaTypeFactory#getMediaType(String)} + *
    * @param request the current request * @param resource the resource to check * @return the corresponding media type, or {@code null} if none found */ @Nullable protected MediaType getMediaType(HttpServletRequest request, Resource resource) { - return (this.contentNegotiationStrategy != null ? - this.contentNegotiationStrategy.getMediaTypeForResource(resource) : null); + MediaType result = null; + String mimeType = request.getServletContext().getMimeType(resource.getFilename()); + if (StringUtils.hasText(mimeType)) { + result = MediaType.parseMediaType(mimeType); + } + if (result == null || MediaType.APPLICATION_OCTET_STREAM.equals(result)) { + MediaType mediaType = null; + String filename = resource.getFilename(); + String ext = StringUtils.getFilenameExtension(filename); + if (ext != null) { + mediaType = this.mediaTypes.get(ext.toLowerCase(Locale.ENGLISH)); + } + if (mediaType == null) { + mediaType = MediaTypeFactory.getMediaType(filename).orElse(null); + } + if (mediaType != null) { + result = mediaType; + } + } + return result; } /** diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerTests.java index 62ff42be8948..9af18827f9e5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -74,13 +74,15 @@ public void setup() throws Exception { paths.add(new ClassPathResource("testalternatepath/", getClass())); paths.add(new ClassPathResource("META-INF/resources/webjars/")); + TestServletContext servletContext = new TestServletContext(); + this.handler = new ResourceHttpRequestHandler(); this.handler.setLocations(paths); this.handler.setCacheSeconds(3600); - this.handler.setServletContext(new TestServletContext()); + this.handler.setServletContext(servletContext); this.handler.afterPropertiesSet(); - this.request = new MockHttpServletRequest("GET", ""); + this.request = new MockHttpServletRequest(servletContext, "GET", ""); this.response = new MockHttpServletResponse(); } @@ -283,15 +285,12 @@ public void getMediaTypeWithFavorPathExtensionOff() throws Exception { @Test // SPR-14368 public void getResourceWithMediaTypeResolvedThroughServletContext() throws Exception { + MockServletContext servletContext = new MockServletContext() { @Override public String getMimeType(String filePath) { return "foo/bar"; } - @Override - public String getVirtualServerName() { - return ""; - } }; List paths = Collections.singletonList(new ClassPathResource("test/", getClass())); @@ -300,8 +299,9 @@ public String getVirtualServerName() { handler.setLocations(paths); handler.afterPropertiesSet(); - this.request.setAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, "foo.css"); - handler.handleRequest(this.request, this.response); + MockHttpServletRequest request = new MockHttpServletRequest(servletContext, "GET", ""); + request.setAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, "foo.css"); + handler.handleRequest(request, this.response); assertThat(this.response.getContentType()).isEqualTo("foo/bar"); assertThat(this.response.getContentAsString()).isEqualTo("h1 { color:red; }"); diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index 6de7b41083c7..af1a83679282 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -1683,6 +1683,18 @@ the issues that come with file extensions. Alternatively, if you must use file e restricting them to a list of explicitly registered extensions through the `mediaTypes` property of <>. +[INFO] +==== +Starting in 5.2.4, path extension related options for request mapping in +{api-spring-framework}/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java[RequestMappingHandlerMapping] +and for content negotiation in +{api-spring-framework}/org.springframework.web.accept/ContentNegotiationManagerFactoryBean.java[ContentNegotiationManagerFactoryBean] +are deprecated. See Spring Framework issue +https://github.com/spring-projects/spring-framework/issues/24179[#24179] and related +issues for further plans. +==== + + [[mvc-ann-requestmapping-rfd]] ==== Suffix Match and RFD @@ -5779,13 +5791,11 @@ The following example shows how to customize path matching in Java configuration @Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer - .setUseSuffixPatternMatch(true) .setUseTrailingSlashMatch(false) .setUseRegisteredSuffixPatternMatch(true) .setPathMatcher(antPathMatcher()) .setUrlPathHelper(urlPathHelper()) - .addPathPrefix("/api", - HandlerTypePredicate.forAnnotation(RestController.class)); + .addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController.class)); } @Bean @@ -5813,8 +5823,7 @@ The following example shows how to customize path matching in Java configuration .setUseRegisteredSuffixPatternMatch(true) .setPathMatcher(antPathMatcher()) .setUrlPathHelper(urlPathHelper()) - .addPathPrefix("/api", - HandlerTypePredicate.forAnnotation(RestController::class.java)) + .addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController::class.java)) } @Bean @@ -5835,7 +5844,6 @@ The following example shows how to achieve the same configuration in XML: ---- Date: Thu, 23 Jan 2020 12:31:00 +0000 Subject: [PATCH 0347/2315] Improve support for generics in Jackson codecs Closes gh-23791 --- .../codec/json/AbstractJackson2Decoder.java | 14 ++++++++--- .../http/codec/json/Jackson2CodecSupport.java | 25 +++++++++++++++++-- ...pingMessageConversionIntegrationTests.java | 4 +-- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java index 8a38d77d4bf4..74cdbe42f544 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -153,8 +153,10 @@ public Object decode(DataBuffer dataBuffer, ResolvableType targetType, private ObjectReader getObjectReader(ResolvableType elementType, @Nullable Map hints) { Assert.notNull(elementType, "'elementType' must not be null"); - MethodParameter param = getParameter(elementType); - Class contextClass = (param != null ? param.getContainingClass() : null); + Class contextClass = getContextClass(elementType); + if (contextClass == null && hints != null) { + contextClass = getContextClass((ResolvableType) hints.get(ACTUAL_TYPE_HINT)); + } JavaType javaType = getJavaType(elementType.getType(), contextClass); Class jsonView = (hints != null ? (Class) hints.get(Jackson2CodecSupport.JSON_VIEW_HINT) : null); return jsonView != null ? @@ -162,6 +164,12 @@ private ObjectReader getObjectReader(ResolvableType elementType, @Nullable Map getContextClass(@Nullable ResolvableType elementType) { + MethodParameter param = (elementType != null ? getParameter(elementType) : null); + return (param != null ? param.getContainingClass() : null); + } + private void logValue(@Nullable Object value, @Nullable Map hints) { if (!Hints.isLoggingSuppressed(hints)) { LogFormatUtils.traceDebug(logger, traceOn -> { diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java index 43eaaaa19931..6162be280c91 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -20,6 +20,7 @@ import java.lang.reflect.Type; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -34,6 +35,8 @@ import org.springframework.core.ResolvableType; import org.springframework.core.codec.Hints; import org.springframework.http.HttpLogging; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.MimeType; @@ -55,6 +58,15 @@ public abstract class Jackson2CodecSupport { */ public static final String JSON_VIEW_HINT = Jackson2CodecSupport.class.getName() + ".jsonView"; + /** + * The key for the hint to access the actual ResolvableType passed into + * {@link org.springframework.http.codec.HttpMessageReader#read(ResolvableType, ResolvableType, ServerHttpRequest, ServerHttpResponse, Map)} + * (server-side only). Currently set when the method argument has generics because + * in case of reactive types, use of {@code ResolvableType.getGeneric()} means no + * MethodParameter source and no knowledge of the containing class. + */ + static final String ACTUAL_TYPE_HINT = Jackson2CodecSupport.class.getName() + ".actualType"; + private static final String JSON_VIEW_HINT_ERROR = "@JsonView only supported for write hints with exactly 1 class argument: "; @@ -106,11 +118,20 @@ protected JavaType getJavaType(Type type, @Nullable Class contextClass) { protected Map getHints(ResolvableType resolvableType) { MethodParameter param = getParameter(resolvableType); if (param != null) { + Map hints = null; + if (resolvableType.hasGenerics()) { + hints = new HashMap<>(2); + hints.put(ACTUAL_TYPE_HINT, resolvableType); + } JsonView annotation = getAnnotation(param, JsonView.class); if (annotation != null) { Class[] classes = annotation.value(); Assert.isTrue(classes.length == 1, JSON_VIEW_HINT_ERROR + param); - return Hints.from(JSON_VIEW_HINT, classes[0]); + hints = (hints != null ? hints : new HashMap<>(1)); + hints.put(JSON_VIEW_HINT, classes[0]); + } + if (hints != null) { + return hints; } } return Hints.none(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java index 266952dbc66c..d967b9560a13 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -28,7 +28,6 @@ import io.reactivex.Flowable; import io.reactivex.Maybe; -import org.junit.jupiter.api.Disabled; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -522,7 +521,6 @@ public void personCreateWithFlowableXml(HttpServer httpServer) throws Exception assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2); } - @Disabled @ParameterizedHttpServerTest // gh-23791 public void personCreateViaDefaultMethodWithGenerics(HttpServer httpServer) throws Exception { startServer(httpServer); From 5a0b768a3d81c7f3190b64162f96f69f91ee90c6 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 23 Jan 2020 16:22:52 +0900 Subject: [PATCH 0348/2315] Fix typo in Javadoc --- .../web/server/adapter/HttpWebHandlerAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java index 63a87d2d0434..06c6340808c3 100644 --- a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java +++ b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java @@ -247,7 +247,7 @@ protected ServerWebExchange createExchange(ServerHttpRequest request, ServerHttp * Format the request for logging purposes including HTTP method and URL. *

    By default this prints the HTTP method, the URL path, and the query. * @param request the request to format - * @return the String to display, never empty or @code null} + * @return the String to display, never empty or {@code null} */ protected String formatRequest(ServerHttpRequest request) { String rawQuery = request.getURI().getRawQuery(); From a2af5a90dc14217b02246b2d733f9c4d25b17600 Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Fri, 24 Jan 2020 19:39:05 +0900 Subject: [PATCH 0349/2315] Simplify UrlFileNameViewController#getViewNameForUrlPath() Closes gh-24419 --- .../web/servlet/mvc/UrlFilenameViewController.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java index e037a817b8d5..31495ada512b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -125,13 +125,7 @@ protected String extractOperableUrl(HttpServletRequest request) { * @see #postProcessViewName */ protected String getViewNameForUrlPath(String uri) { - String viewName = this.viewNameCache.get(uri); - if (viewName == null) { - viewName = extractViewNameFromUrlPath(uri); - viewName = postProcessViewName(viewName); - this.viewNameCache.put(uri, viewName); - } - return viewName; + return this.viewNameCache.computeIfAbsent(uri, u -> postProcessViewName(extractViewNameFromUrlPath(u))); } /** From d085577e0a9267cee2e5b7bde6fb65cdc911d3d2 Mon Sep 17 00:00:00 2001 From: Kalmesh Sambrani Date: Thu, 23 Jan 2020 15:34:18 +0530 Subject: [PATCH 0350/2315] Solve ReflectPermission Issue in Sandbox Security Policy Model --- .../org/springframework/cglib/core/ReflectUtils.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/cglib/core/ReflectUtils.java b/spring-core/src/main/java/org/springframework/cglib/core/ReflectUtils.java index 0b09ad76004a..1af56bd8366f 100644 --- a/spring-core/src/main/java/org/springframework/cglib/core/ReflectUtils.java +++ b/spring-core/src/main/java/org/springframework/cglib/core/ReflectUtils.java @@ -336,7 +336,15 @@ public static Object newInstance(final Constructor cstruct, final Object[] args) public static Constructor getConstructor(Class type, Class[] parameterTypes) { try { Constructor constructor = type.getDeclaredConstructor(parameterTypes); - constructor.setAccessible(true); + if (System.getSecurityManager() != null) { + AccessController.doPrivileged((PrivilegedAction) () -> { + constructor.setAccessible(true); + return null; + }); + } + else { + constructor.setAccessible(true); + } return constructor; } catch (NoSuchMethodException e) { From 60c7af3625a90e29c9aea783714c0675ba479330 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 24 Jan 2020 14:54:02 +0100 Subject: [PATCH 0351/2315] Mention HikariCP next to DBCP and C3P0 in connection pool notes Closes gh-24405 --- .../datasource/DriverManagerDataSource.java | 13 ++++++----- .../datasource/SimpleDriverDataSource.java | 13 ++++++----- .../embedded/DataSourceFactory.java | 20 ++++++++--------- src/docs/asciidoc/data-access.adoc | 22 +++++++++---------- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DriverManagerDataSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DriverManagerDataSource.java index 4ae64d36faf1..f803cd46770c 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DriverManagerDataSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DriverManagerDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -52,12 +52,13 @@ * {@link org.springframework.mock.jndi.SimpleNamingContextBuilder}, or switch the * bean definition to a local DataSource (which is simpler and thus recommended). * - *

    If you need a "real" connection pool outside of a Java EE container, consider + *

    This {@code DriverManagerDataSource} class was originally designed alongside * Apache Commons DBCP - * or C3P0. - * Commons DBCP's BasicDataSource and C3P0's ComboPooledDataSource are full - * connection pool beans, supporting the same basic properties as this class - * plus specific settings (such as minimal/maximal pool size etc). + * and C3P0, featuring bean-style + * {@code BasicDataSource}/{@code ComboPooledDataSource} classes with configuration + * properties for local resource setups. For a modern JDBC connection pool, consider + * HikariCP instead, + * exposing a corresponding {@code HikariDataSource} instance to the application. * * @author Juergen Hoeller * @since 14.03.2003 diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/SimpleDriverDataSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/SimpleDriverDataSource.java index 490780b7bf0f..09e813d13afa 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/SimpleDriverDataSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/SimpleDriverDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -40,12 +40,13 @@ * ApplicationContext via {@link org.springframework.jndi.JndiObjectFactoryBean}, * for seamless switching to and from a local DataSource bean like this class. * - *

    If you need a "real" connection pool outside of a Java EE container, consider + *

    This {@code SimpleDriverDataSource} class was originally designed alongside * Apache Commons DBCP - * or C3P0. - * Commons DBCP's BasicDataSource and C3P0's ComboPooledDataSource are full - * connection pool beans, supporting the same basic properties as this class - * plus specific settings (such as minimal/maximal pool size etc). + * and C3P0, featuring bean-style + * {@code BasicDataSource}/{@code ComboPooledDataSource} classes with configuration + * properties for local resource setups. For a modern JDBC connection pool, consider + * HikariCP instead, + * exposing a corresponding {@code HikariDataSource} instance to the application. * * @author Juergen Hoeller * @since 2.5.5 diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/DataSourceFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/DataSourceFactory.java index e10a8e550169..5ace3dd8afa8 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/DataSourceFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/DataSourceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2020 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. @@ -20,13 +20,13 @@ /** * {@code DataSourceFactory} encapsulates the creation of a particular - * {@link DataSource} implementation such as a - * {@link org.springframework.jdbc.datasource.SimpleDriverDataSource - * SimpleDriverDataSource} or a connection pool such as Apache DBCP or C3P0. + * {@link DataSource} implementation such as a non-pooling + * {@link org.springframework.jdbc.datasource.SimpleDriverDataSource} + * or a HikariCP pool setup in the shape of a {@code HikariDataSource}. * *

    Call {@link #getConnectionProperties()} to configure normalized - * {@code DataSource} properties before calling {@link #getDataSource()} to - * actually get the configured {@code DataSource} instance. + * {@code DataSource} properties before calling {@link #getDataSource()} + * to actually get the configured {@code DataSource} instance. * * @author Keith Donald * @author Sam Brannen @@ -35,14 +35,14 @@ public interface DataSourceFactory { /** - * Get the {@linkplain ConnectionProperties connection properties} of the - * {@link #getDataSource DataSource} to be configured. + * Get the {@linkplain ConnectionProperties connection properties} + * of the {@link #getDataSource DataSource} to be configured. */ ConnectionProperties getConnectionProperties(); /** - * Get the {@link DataSource} with the {@linkplain #getConnectionProperties - * connection properties} applied. + * Get the {@link DataSource} with the + * {@linkplain #getConnectionProperties connection properties} applied. */ DataSource getDataSource(); diff --git a/src/docs/asciidoc/data-access.adoc b/src/docs/asciidoc/data-access.adoc index 38fe149b3e40..b25cf899950a 100644 --- a/src/docs/asciidoc/data-access.adoc +++ b/src/docs/asciidoc/data-access.adoc @@ -3613,20 +3613,20 @@ part of the JDBC specification and is a generalized connection factory. It lets container or a framework hide connection pooling and transaction management issues from the application code. As a developer, you need not know details about how to connect to the database. That is the responsibility of the administrator who sets up -the datasource. You most likely fill both roles as you develop and test code, but you do -not necessarily have to know how the production data source is configured. +the datasource. You most likely fill both roles as you develop and test code, but you +do not necessarily have to know how the production data source is configured. -When you use Spring's JDBC layer, you can obtain a data source from JNDI, or you can configure your -own with a connection pool implementation provided by a third party. Popular -implementations are Apache Jakarta Commons DBCP and C3P0. Implementations in the Spring -distribution are meant only for testing purposes and do not provide pooling. +When you use Spring's JDBC layer, you can obtain a data source from JNDI, or you can +configure your own with a connection pool implementation provided by a third party. +Traditional choices are Apache Commons DBCP and C3P0 with bean-style `DataSource` classes; +for a modern JDBC connection pool, consider HikariCP with its builder-style API instead. -This section uses Spring's `DriverManagerDataSource` implementation, and several -additional implementations are covered later. +NOTE: You should use the `DriverManagerDataSource` and `SimpleDriverDataSource` classes +(as included in the Spring distribution) only for testing purposes! Those variants do not +provide pooling and perform poorly when multiple requests for a connection are made. -NOTE: You should use the `DriverManagerDataSource` class only for testing purposes, -since it does not provide pooling and performs poorly when multiple requests for a -connection are made. +The following section uses Spring's `DriverManagerDataSource` implementation. +Several other `DataSource` variants are covered later. To configure a `DriverManagerDataSource`: From 7c47e3ba2e50f563be37df7f5144288663f84bf7 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 24 Jan 2020 14:55:08 +0100 Subject: [PATCH 0352/2315] Upgrade to Netty 4.1.45, Jetty 9.4.26, Groovy 2.5.9, Woodstox 6.0.3, Caffeine 2.8.1, OpenPDF 1.3.12 --- build.gradle | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index f0296022d156..bff16637f761 100644 --- a/build.gradle +++ b/build.gradle @@ -36,10 +36,10 @@ configure(allprojects) { project -> dependencyManagement { imports { mavenBom "com.fasterxml.jackson:jackson-bom:2.10.2" - mavenBom "io.netty:netty-bom:4.1.44.Final" + mavenBom "io.netty:netty-bom:4.1.45.Final" mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR4" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" - mavenBom "org.eclipse.jetty:jetty-bom:9.4.25.v20191220" + mavenBom "org.eclipse.jetty:jetty-bom:9.4.26.v20200117" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.61" mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.2" mavenBom "org.junit:junit-bom:5.5.2" @@ -60,7 +60,7 @@ configure(allprojects) { project -> entry 'aspectjtools' entry 'aspectjweaver' } - dependencySet(group: 'org.codehaus.groovy', version: '2.5.8') { + dependencySet(group: 'org.codehaus.groovy', version: '2.5.9') { entry 'groovy' entry 'groovy-jsr223' entry 'groovy-templates' @@ -74,7 +74,7 @@ configure(allprojects) { project -> dependency "com.caucho:hessian:4.0.62" dependency "com.fasterxml:aalto-xml:1.2.2" - dependency("com.fasterxml.woodstox:woodstox-core:6.0.2") { + dependency("com.fasterxml.woodstox:woodstox-core:6.0.3") { exclude group: "stax", name: "stax-api" } dependency "com.google.code.gson:gson:2.8.6" @@ -96,8 +96,8 @@ configure(allprojects) { project -> dependency "org.yaml:snakeyaml:1.25" dependency "com.h2database:h2:1.4.200" - dependency "com.github.ben-manes.caffeine:caffeine:2.8.0" - dependency "com.github.librepdf:openpdf:1.3.11" + dependency "com.github.ben-manes.caffeine:caffeine:2.8.1" + dependency "com.github.librepdf:openpdf:1.3.12" dependency "com.rometools:rome:1.12.2" dependency "commons-io:commons-io:2.5" dependency "io.vavr:vavr:0.10.0" From 754a8ca05ad4a9693961e308c9449c3e066aa35c Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Thu, 23 Jan 2020 14:01:58 -0600 Subject: [PATCH 0353/2315] Fix Asciidoctor Warnings - Fix "possible invalid reference" errors - Add .adoc where necessary - Remove invalid link to beans-servicelocator This section no longer exists - Fix "skipping reference to missing attribute" errors - Add pass macro to escape literals interpreted as attributes - Add missing :api-spring-framework: attribute - Remove invalid {JB} attribute Closes gh-24427 --- src/docs/asciidoc/core/core-aop.adoc | 2 +- src/docs/asciidoc/core/core-appendix.adoc | 2 +- src/docs/asciidoc/core/core-beans.adoc | 6 +++--- src/docs/asciidoc/data-access.adoc | 2 +- src/docs/asciidoc/languages/dynamic-languages.adoc | 2 +- src/docs/asciidoc/languages/kotlin.adoc | 4 ++-- src/docs/asciidoc/rsocket.adoc | 2 +- src/docs/asciidoc/testing-webtestclient.adoc | 2 ++ src/docs/asciidoc/web-reactive.adoc | 2 +- src/docs/asciidoc/web/integration.adoc | 2 +- src/docs/asciidoc/web/webflux-functional.adoc | 6 +++--- src/docs/asciidoc/web/webflux.adoc | 12 ++++++------ src/docs/asciidoc/web/webmvc-cors.adoc | 2 +- src/docs/asciidoc/web/webmvc-functional.adoc | 6 +++--- src/docs/asciidoc/web/websocket.adoc | 10 +++++----- 15 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/docs/asciidoc/core/core-aop.adoc b/src/docs/asciidoc/core/core-aop.adoc index bc100f83e554..51c077850cf4 100644 --- a/src/docs/asciidoc/core/core-aop.adoc +++ b/src/docs/asciidoc/core/core-aop.adoc @@ -3956,7 +3956,7 @@ for AspectJ LTW: * `spring-aop.jar` * `aspectjweaver.jar` -If you use the <>, you also need: * `spring-instrument.jar` diff --git a/src/docs/asciidoc/core/core-appendix.adoc b/src/docs/asciidoc/core/core-appendix.adoc index e047d3d8ea9b..ee20da30b48d 100644 --- a/src/docs/asciidoc/core/core-appendix.adoc +++ b/src/docs/asciidoc/core/core-appendix.adoc @@ -666,7 +666,7 @@ integrate such parsers into the Spring IoC container. To facilitate authoring configuration files that use a schema-aware XML editor, Spring's extensible XML configuration mechanism is based on XML Schema. If you are not familiar with Spring's current XML configuration extensions that come with the standard -Spring distribution, you should first read the appendix entitled <>. +Spring distribution, you should first read the appendix entitled <>. To create new XML configuration extensions: diff --git a/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc index bbecd6c728a1..1b1af8d8104b 100644 --- a/src/docs/asciidoc/core/core-beans.adoc +++ b/src/docs/asciidoc/core/core-beans.adoc @@ -543,7 +543,7 @@ enforced by the container, though no longer by XML parsers. You are not required to supply a `name` or an `id` for a bean. If you do not supply a `name` or `id` explicitly, the container generates a unique name for that bean. However, if you want to refer to that bean by name, through the use of the `ref` element or a -<> style lookup, you must provide a name. +Service Locator style lookup, you must provide a name. Motivations for not supplying a name are related to using <> and <>. @@ -4482,7 +4482,7 @@ with placeholder values is defined: The example shows properties configured from an external `Properties` file. At runtime, a `PropertySourcesPlaceholderConfigurer` is applied to the metadata that replaces some properties of the DataSource. The values to replace are specified as placeholders of the -form `${property-name}`, which follows the Ant and log4j and JSP EL style. +form pass:q[`${property-name}`], which follows the Ant and log4j and JSP EL style. The actual values come from another file in the standard Java `Properties` format: @@ -9543,7 +9543,7 @@ now looks like the following listing: The problem is how to switch between using these two variations based on the current environment. Over time, Spring users have devised a number of ways to get this done, usually relying on a combination of system environment variables -and XML `` statements containing `${placeholder}` tokens that resolve +and XML `` statements containing pass:q[`${placeholder}`] tokens that resolve to the correct configuration file path depending on the value of an environment variable. Bean definition profiles is a core container feature that provides a solution to this problem. diff --git a/src/docs/asciidoc/data-access.adoc b/src/docs/asciidoc/data-access.adoc index b25cf899950a..7d9795db526a 100644 --- a/src/docs/asciidoc/data-access.adoc +++ b/src/docs/asciidoc/data-access.adoc @@ -1314,7 +1314,7 @@ NOTE: The `proxy-target-class` attribute controls what type of transactional pro created for classes annotated with the `@Transactional` annotation. If `proxy-target-class` is set to `true`, class-based proxies are created. If `proxy-target-class` is `false` or if the attribute is omitted, standard JDK -interface-based proxies are created. (See <> for a discussion of the +interface-based proxies are created. (See <> for a discussion of the different proxy types.) NOTE: `@EnableTransactionManagement` and `` looks for diff --git a/src/docs/asciidoc/languages/dynamic-languages.adoc b/src/docs/asciidoc/languages/dynamic-languages.adoc index eaf26b16c2f5..67a066ba2dbd 100644 --- a/src/docs/asciidoc/languages/dynamic-languages.adoc +++ b/src/docs/asciidoc/languages/dynamic-languages.adoc @@ -589,7 +589,7 @@ in the same place as Spring's `GroovyObjectCustomizer`. This section describes how to use BeanShell beans in Spring. -The BeanShell homepage includes the following description: {JB} +The BeanShell homepage includes the following description: "`BeanShell is a small, free, embeddable Java source interpreter with dynamic language features, written in Java. BeanShell dynamically executes standard Java syntax and diff --git a/src/docs/asciidoc/languages/kotlin.adoc b/src/docs/asciidoc/languages/kotlin.adoc index f449881b8507..d9702e8a1fc9 100644 --- a/src/docs/asciidoc/languages/kotlin.adoc +++ b/src/docs/asciidoc/languages/kotlin.adoc @@ -748,12 +748,12 @@ as the following example shows: === Injecting Configuration Properties -In Java, you can inject configuration properties by using annotations (such as `@Value("${property}")`). +In Java, you can inject configuration properties by using annotations (such as pass:q[`@Value("${property}")`)]. However, in Kotlin, `$` is a reserved character that is used for https://kotlinlang.org/docs/reference/idioms.html#string-interpolation[string interpolation]. Therefore, if you wish to use the `@Value` annotation in Kotlin, you need to escape the `$` -character by writing `@Value("\${property}")`. +character by writing pass:q[`@Value("\${property}")`]. NOTE: If you use Spring Boot, you should probably use https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-typesafe-configuration-properties[`@ConfigurationProperties`] diff --git a/src/docs/asciidoc/rsocket.adoc b/src/docs/asciidoc/rsocket.adoc index 27df66009706..6f00bc02e8cf 100644 --- a/src/docs/asciidoc/rsocket.adoc +++ b/src/docs/asciidoc/rsocket.adoc @@ -781,7 +781,7 @@ use the following method arguments: | `@DestinationVariable` | Value extracted from the route based on variables in the mapping pattern, e.g. - `@MessageMapping("find.radar.{id}")`. + pass:q[`@MessageMapping("find.radar.{id}")`]. | `@Header` | Metadata value registered for extraction as described in <>. diff --git a/src/docs/asciidoc/testing-webtestclient.adoc b/src/docs/asciidoc/testing-webtestclient.adoc index ef6414f06ebf..7138bd007b81 100644 --- a/src/docs/asciidoc/testing-webtestclient.adoc +++ b/src/docs/asciidoc/testing-webtestclient.adoc @@ -1,5 +1,7 @@ [[webtestclient]] = WebTestClient +:doc-root: https://docs.spring.io +:api-spring-framework: {doc-root}/spring-framework/docs/{spring-version}/javadoc-api/org/springframework `WebTestClient` is a thin shell around <>, using it to perform requests and exposing a dedicated, fluent API for verifying responses. diff --git a/src/docs/asciidoc/web-reactive.adoc b/src/docs/asciidoc/web-reactive.adoc index 3e7df852a8b1..b913630dc070 100644 --- a/src/docs/asciidoc/web-reactive.adoc +++ b/src/docs/asciidoc/web-reactive.adoc @@ -10,7 +10,7 @@ This part of the documentation covers support for reactive-stack web applications built on a https://www.reactive-streams.org/[Reactive Streams] API to run on non-blocking servers, such as Netty, Undertow, and Servlet 3.1+ containers. Individual chapters cover -the <> framework, +the <> framework, the reactive <>, support for <>, and <>. For Servlet-stack web applications, see <>. diff --git a/src/docs/asciidoc/web/integration.adoc b/src/docs/asciidoc/web/integration.adoc index ba2442b64f02..549c5f5cde12 100644 --- a/src/docs/asciidoc/web/integration.adoc +++ b/src/docs/asciidoc/web/integration.adoc @@ -9,7 +9,7 @@ particular architecture, technology, or methodology (although it certainly recom some over others). This freedom to pick and choose the architecture, technology, or methodology that is most relevant to a developer and their development team is arguably most evident in the web area, where Spring provides its own web frameworks -(<> and <>) while, at the same time, +(<> and <>) while, at the same time, supporting integration with a number of popular third-party web frameworks. diff --git a/src/docs/asciidoc/web/webflux-functional.adoc b/src/docs/asciidoc/web/webflux-functional.adoc index a69c98976c35..278ef1107911 100644 --- a/src/docs/asciidoc/web/webflux-functional.adoc +++ b/src/docs/asciidoc/web/webflux-functional.adoc @@ -538,7 +538,7 @@ RouterFunction route = route() .add(otherRoute) // <4> .build(); ---- -<1> `GET /person/{id}` with an `Accept` header that matches JSON is routed to +<1> pass:q[`GET /person/{id}`] with an `Accept` header that matches JSON is routed to `PersonHandler.getPerson` <2> `GET /person` with an `Accept` header that matches JSON is routed to `PersonHandler.listPeople` @@ -562,7 +562,7 @@ RouterFunction route = route() POST("/person", handler::createPerson) // <3> }.and(otherRoute) // <4> ---- -<1> `GET /person/{id}` with an `Accept` header that matches JSON is routed to +<1> pass:q[`GET /person/{id}`] with an `Accept` header that matches JSON is routed to `PersonHandler.getPerson` <2> `GET /person` with an `Accept` header that matches JSON is routed to `PersonHandler.listPeople` @@ -854,4 +854,4 @@ Besides using the `filter` method on the router function builder, it is possible filter to an existing router function via `RouterFunction.filter(HandlerFilterFunction)`. NOTE: CORS support for functional endpoints is provided through a dedicated -<>. +<>. diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index 704867efef20..7c279560fd41 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -674,7 +674,7 @@ Spring WebFlux provides fine-grained support for CORS configuration through anno controllers. However, when you use it with Spring Security, we advise relying on the built-in `CorsFilter`, which must be ordered ahead of Spring Security's chain of filters. -See the section on <> and the <> for more details. +See the section on <> and the <> for more details. @@ -1960,7 +1960,7 @@ can require type conversion if the argument is declared as something other than For such cases, type conversion is automatically applied based on the configured converters. By default, simple types (such as `int`, `long`, `Date`, and others) are supported. Type conversion -can be customized through a `WebDataBinder` (see <>) or by registering +can be customized through a `WebDataBinder` (see <>) or by registering `Formatters` with the `FormattingConversionService` (see <>). @@ -2162,7 +2162,7 @@ to `false` or by declaring the argument with a `java.util.Optional` wrapper. Type conversion is applied automatically if the target method parameter type is not -`String`. See <>. +`String`. See <>. When a `@RequestParam` annotation is declared on a `Map` or `MultiValueMap` argument, the map is populated with all query parameters. @@ -2223,7 +2223,7 @@ The following example gets the value of the `Accept-Encoding` and `Keep-Alive` h <2> Get the value of the `Keep-Alive` header. Type conversion is applied automatically if the target method parameter type is not -`String`. See <>. +`String`. See <>. When a `@RequestHeader` annotation is used on a `Map`, `MultiValueMap`, or `HttpHeaders` argument, the map is populated @@ -2273,7 +2273,7 @@ The following code sample demonstrates how to get the cookie value: Type conversion is applied automatically if the target method parameter type is not -`String`. See <>. +`String`. See <>. [[webflux-ann-modelattrib-method-args]] @@ -3265,7 +3265,7 @@ controller-specific `Formatter` instances, as the following example shows: === Managing Exceptions [.small]#<># -`@Controller` and <> classes can have +`@Controller` and <> classes can have `@ExceptionHandler` methods to handle exceptions from controller methods. The following example includes such a handler method: diff --git a/src/docs/asciidoc/web/webmvc-cors.adoc b/src/docs/asciidoc/web/webmvc-cors.adoc index a5c60e03dffa..aee826ced2bd 100644 --- a/src/docs/asciidoc/web/webmvc-cors.adoc +++ b/src/docs/asciidoc/web/webmvc-cors.adoc @@ -325,7 +325,7 @@ as the following example shows: [[mvc-cors-filter]] == CORS Filter -[.small]#<># +[.small]#<># You can apply CORS support through the built-in {api-spring-framework}/web/filter/CorsFilter.html[`CorsFilter`]. diff --git a/src/docs/asciidoc/web/webmvc-functional.adoc b/src/docs/asciidoc/web/webmvc-functional.adoc index 51d8b2b2b05d..7f502e569432 100644 --- a/src/docs/asciidoc/web/webmvc-functional.adoc +++ b/src/docs/asciidoc/web/webmvc-functional.adoc @@ -475,7 +475,7 @@ The following example shows the composition of four routes: .add(otherRoute) // <4> .build(); ---- -<1> `GET /person/{id}` with an `Accept` header that matches JSON is routed to +<1> pass:q[`GET /person/{id}`] with an `Accept` header that matches JSON is routed to `PersonHandler.getPerson` <2> `GET /person` with an `Accept` header that matches JSON is routed to `PersonHandler.listPeople` @@ -500,7 +500,7 @@ The following example shows the composition of four routes: POST("/person", handler::createPerson) // <3> }.and(otherRoute) // <4> ---- -<1> `GET /person/{id}` with an `Accept` header that matches JSON is routed to +<1> pass:q[`GET /person/{id}`] with an `Accept` header that matches JSON is routed to `PersonHandler.getPerson` <2> `GET /person` with an `Accept` header that matches JSON is routed to `PersonHandler.listPeople` @@ -787,4 +787,4 @@ Besides using the `filter` method on the router function builder, it is possible filter to an existing router function via `RouterFunction.filter(HandlerFilterFunction)`. NOTE: CORS support for functional endpoints is provided through a dedicated -<>. +<>. diff --git a/src/docs/asciidoc/web/websocket.adoc b/src/docs/asciidoc/web/websocket.adoc index 3cc268b01a74..9a0c5a68ba87 100644 --- a/src/docs/asciidoc/web/websocket.adoc +++ b/src/docs/asciidoc/web/websocket.adoc @@ -512,9 +512,9 @@ https://host:port/myApp/myEndpoint/{server-id}/{session-id}/{transport} where: -* `{server-id}` is useful for routing requests in a cluster but is not used otherwise. -* `{session-id}` correlates HTTP requests belonging to a SockJS session. -* `{transport}` indicates the transport type (for example, `websocket`, `xhr-streaming`, and others). +* pass:q[`{server-id}`] is useful for routing requests in a cluster but is not used otherwise. +* pass:q[`{session-id}`] correlates HTTP requests belonging to a SockJS session. +* pass:q[`{transport}`] indicates the transport type (for example, `websocket`, `xhr-streaming`, and others). The WebSocket transport needs only a single HTTP request to do the WebSocket handshake. All messages thereafter are exchanged on that socket. @@ -1254,7 +1254,7 @@ level, `@MessageMapping` is used to express shared mappings across all methods i controller. By default, the mapping values are Ant-style path patterns (for example `/thing*`, `/thing/**`), -including support for template variables (for example, `/thing/{id}`). The values can be +including support for template variables (for example, pass:q[`/thing/{id}`]). The values can be referenced through `@DestinationVariable` method arguments. Applications can also switch to a dot-separated destination convention for mappings, as explained in <>. @@ -1862,7 +1862,7 @@ with other users who subscribe to the same destination so that each user can rec unique stock position updates. On the sending side, messages can be sent to a destination such as -`/user/{username}/queue/position-updates`, which in turn is translated +pass:q[`/user/{username}/queue/position-updates`], which in turn is translated by the `UserDestinationMessageHandler` into one or more destinations, one for each session associated with the user. This lets any component within the application send messages that target a specific user without necessarily knowing anything more From 75a13952265f352fc159b5dcb5332b3a3e939058 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 24 Jan 2020 16:18:39 +0100 Subject: [PATCH 0354/2315] Link to BeanShell homepage --- src/docs/asciidoc/languages/dynamic-languages.adoc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/docs/asciidoc/languages/dynamic-languages.adoc b/src/docs/asciidoc/languages/dynamic-languages.adoc index 67a066ba2dbd..cae5239b0602 100644 --- a/src/docs/asciidoc/languages/dynamic-languages.adoc +++ b/src/docs/asciidoc/languages/dynamic-languages.adoc @@ -589,12 +589,15 @@ in the same place as Spring's `GroovyObjectCustomizer`. This section describes how to use BeanShell beans in Spring. -The BeanShell homepage includes the following description: +The https://beanshell.github.io/intro.html[BeanShell homepage] includes the following +description: -"`BeanShell is a small, free, embeddable Java source interpreter with dynamic language +---- +BeanShell is a small, free, embeddable Java source interpreter with dynamic language features, written in Java. BeanShell dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method -closures like those in Perl and JavaScript.`" +closures like those in Perl and JavaScript. +---- In contrast to Groovy, BeanShell-backed bean definitions require some (small) additional configuration. The implementation of the BeanShell dynamic language support in Spring is @@ -875,6 +878,6 @@ the correct schema so that the tags in the `lang` namespace are available to you The following links go to further resources about the various dynamic languages referenced in this chapter: -* The http://www.groovy-lang.org/[Groovy] homepage -* The http://www.beanshell.org/[BeanShell] homepage +* The https://www.groovy-lang.org/[Groovy] homepage +* The https://beanshell.github.io/intro.html[BeanShell] homepage * The https://www.jruby.org[JRuby] homepage From ab70acb3256c8913996ee394240a43c9d02fae0b Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Fri, 24 Jan 2020 09:27:52 -0600 Subject: [PATCH 0355/2315] Fix Additional Asciidoctor Warnings Fix "unknown style for example block: INFO" Issue gh-24427 --- src/docs/asciidoc/web/webmvc.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index af1a83679282..99adbce18c8d 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -1683,7 +1683,7 @@ the issues that come with file extensions. Alternatively, if you must use file e restricting them to a list of explicitly registered extensions through the `mediaTypes` property of <>. -[INFO] +[NOTE] ==== Starting in 5.2.4, path extension related options for request mapping in {api-spring-framework}/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java[RequestMappingHandlerMapping] From b142f8e66000bbf4ff86866fa47a6941bf06b453 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 24 Jan 2020 15:36:46 +0000 Subject: [PATCH 0356/2315] Remove no-op code in URI encoding Closes gh-24413 --- .../web/util/HierarchicalUriComponents.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java index 624bff55b10a..cd088e039db2 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -337,9 +337,6 @@ static String encodeUriComponent(String source, Charset charset, Type type) { byte[] bytes = source.getBytes(charset); boolean original = true; for (byte b : bytes) { - if (b < 0) { - b += 256; - } if (!type.isAllowed(b)) { original = false; break; @@ -351,9 +348,6 @@ static String encodeUriComponent(String source, Charset charset, Type type) { ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length); for (byte b : bytes) { - if (b < 0) { - b += 256; - } if (type.isAllowed(b)) { bos.write(b); } From d499e14b7829c462f4a4cd9ca0c3b45a52d06aba Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 24 Jan 2020 15:40:16 +0000 Subject: [PATCH 0357/2315] Update default value in ReactorResourceFactory We used ConnectionProvider#elastic only to customize the name. Now that Reactor Netty's TcpResources itself uses fixed 500 by default, we update to have the same value which would apply when global resources are not used. Closes gh-24424 --- .../http/client/reactive/ReactorResourceFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java index fdfd1a78d8f9..8e696504b4f0 100644 --- a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java +++ b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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,7 +46,7 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean @Nullable private Consumer globalResourcesConsumer; - private Supplier connectionProviderSupplier = () -> ConnectionProvider.elastic("webflux"); + private Supplier connectionProviderSupplier = () -> ConnectionProvider.fixed("webflux", 500); private Supplier loopResourcesSupplier = () -> LoopResources.create("webflux-http"); From 2fcee5ae58e61c9c999606c9ff6ad3424644b4b5 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 24 Jan 2020 15:57:56 +0000 Subject: [PATCH 0358/2315] Append unique number to WebFlux server log prefix Closes gh-22039 --- .../server/reactive/ReactorServerHttpRequest.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java index e05f992c97df..9cd57c08c09a 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -19,6 +19,7 @@ import java.net.InetSocketAddress; import java.net.URI; import java.net.URISyntaxException; +import java.util.concurrent.atomic.AtomicLong; import javax.net.ssl.SSLSession; @@ -47,6 +48,9 @@ */ class ReactorServerHttpRequest extends AbstractServerHttpRequest { + private static final AtomicLong logPrefixIndex = new AtomicLong(0); + + private final HttpServerRequest request; private final NettyDataBufferFactory bufferFactory; @@ -181,8 +185,11 @@ public T getNativeRequest() { @Override @Nullable protected String initId() { - return this.request instanceof Connection ? - ((Connection) this.request).channel().id().asShortText() : null; + if (this.request instanceof Connection) { + return ((Connection) this.request).channel().id().asShortText() + + "-" + logPrefixIndex.incrementAndGet(); + } + return null; } } From e66e41029ccb31df18e2cc56c9fc87119cc90bd2 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Fri, 24 Jan 2020 15:48:56 -0600 Subject: [PATCH 0359/2315] Asciidoctor Warnings Are Fatal Ensure we don't get any more warnings within Asciidoctor build Issue gh-24427 --- gradle/docs.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle/docs.gradle b/gradle/docs.gradle index 591832d681ab..1772212c507b 100644 --- a/gradle/docs.gradle +++ b/gradle/docs.gradle @@ -107,6 +107,7 @@ asciidoctorj { version '1.5.0-beta.8' } } + fatalWarnings ".*" } /** From c1218615dfe67d672de2fcb6a44ea1f1ec8ffadc Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 27 Jan 2020 16:57:12 +0200 Subject: [PATCH 0360/2315] Update integration.adoc Fix typo --- src/docs/asciidoc/integration.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/asciidoc/integration.adoc b/src/docs/asciidoc/integration.adoc index 0ca100c30de3..3d5c0534d3d0 100644 --- a/src/docs/asciidoc/integration.adoc +++ b/src/docs/asciidoc/integration.adoc @@ -6943,7 +6943,7 @@ This is the recommended approach over the quite different in signatures as the code base grows. While the default strategy might work for some methods, it rarely works for all methods. -The following examples ise various SpEL declarations (if you are not familiar with SpEL, +The following examples use various SpEL declarations (if you are not familiar with SpEL, do yourself a favor and read <>): [source,java,indent=0] From 75abd9fc7e485cbbb68e8fd4d1abe84ba454ec1b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 27 Jan 2020 18:18:16 +0100 Subject: [PATCH 0361/2315] Upgrade to ASM 7.3 Closes gh-24438 --- .../asm/AnnotationVisitor.java | 10 +- .../springframework/asm/AnnotationWriter.java | 2 +- .../org/springframework/asm/ClassReader.java | 222 +++++++++++++++- .../org/springframework/asm/ClassVisitor.java | 59 ++++- .../org/springframework/asm/ClassWriter.java | 92 ++++++- .../org/springframework/asm/Constants.java | 47 +++- .../org/springframework/asm/FieldVisitor.java | 10 +- .../org/springframework/asm/FieldWriter.java | 2 +- .../springframework/asm/MethodVisitor.java | 12 +- .../org/springframework/asm/MethodWriter.java | 2 +- .../springframework/asm/ModuleVisitor.java | 10 +- .../org/springframework/asm/ModuleWriter.java | 2 +- .../java/org/springframework/asm/Opcodes.java | 11 +- .../asm/RecordComponentVisitor.java | 169 ++++++++++++ .../asm/RecordComponentWriter.java | 242 ++++++++++++++++++ 15 files changed, 870 insertions(+), 22 deletions(-) create mode 100644 spring-core/src/main/java/org/springframework/asm/RecordComponentVisitor.java create mode 100644 spring-core/src/main/java/org/springframework/asm/RecordComponentWriter.java diff --git a/spring-core/src/main/java/org/springframework/asm/AnnotationVisitor.java b/spring-core/src/main/java/org/springframework/asm/AnnotationVisitor.java index 31fcb619139a..cb99202b72bc 100644 --- a/spring-core/src/main/java/org/springframework/asm/AnnotationVisitor.java +++ b/spring-core/src/main/java/org/springframework/asm/AnnotationVisitor.java @@ -67,10 +67,18 @@ public AnnotationVisitor(final int api) { * @param annotationVisitor the annotation visitor to which this visitor must delegate method * calls. May be {@literal null}. */ + @SuppressWarnings("deprecation") public AnnotationVisitor(final int api, final AnnotationVisitor annotationVisitor) { - if (api != Opcodes.ASM7 && api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } + if (api == Opcodes.ASM8_EXPERIMENTAL) { + Constants.checkAsm8Experimental(this); + } this.api = api; this.av = annotationVisitor; } diff --git a/spring-core/src/main/java/org/springframework/asm/AnnotationWriter.java b/spring-core/src/main/java/org/springframework/asm/AnnotationWriter.java index b81e1917a20a..0b29d380582b 100644 --- a/spring-core/src/main/java/org/springframework/asm/AnnotationWriter.java +++ b/spring-core/src/main/java/org/springframework/asm/AnnotationWriter.java @@ -112,7 +112,7 @@ final class AnnotationWriter extends AnnotationVisitor { final boolean useNamedValues, final ByteVector annotation, final AnnotationWriter previousAnnotation) { - super(Opcodes.ASM7); + super(/* latest api = */ Opcodes.ASM7); this.symbolTable = symbolTable; this.useNamedValues = useNamedValues; this.annotation = annotation; diff --git a/spring-core/src/main/java/org/springframework/asm/ClassReader.java b/spring-core/src/main/java/org/springframework/asm/ClassReader.java index f656d179a489..b2591c7fbb95 100644 --- a/spring-core/src/main/java/org/springframework/asm/ClassReader.java +++ b/spring-core/src/main/java/org/springframework/asm/ClassReader.java @@ -50,10 +50,11 @@ public class ClassReader { public static final int SKIP_CODE = 1; /** - * A flag to skip the SourceFile, SourceDebugExtension, LocalVariableTable, LocalVariableTypeTable - * and LineNumberTable attributes. If this flag is set these attributes are neither parsed nor - * visited (i.e. {@link ClassVisitor#visitSource}, {@link MethodVisitor#visitLocalVariable} and - * {@link MethodVisitor#visitLineNumber} are not called). + * A flag to skip the SourceFile, SourceDebugExtension, LocalVariableTable, + * LocalVariableTypeTable, LineNumberTable and MethodParameters attributes. If this flag is set + * these attributes are neither parsed nor visited (i.e. {@link ClassVisitor#visitSource}, {@link + * MethodVisitor#visitLocalVariable}, {@link MethodVisitor#visitLineNumber} and {@link + * MethodVisitor#visitParameter} are not called). */ public static final int SKIP_DEBUG = 2; @@ -190,7 +191,7 @@ public ClassReader( this.b = classFileBuffer; // Check the class' major_version. This field is after the magic and minor_version fields, which // use 4 and 2 bytes respectively. - if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V14) { + if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V15) { throw new IllegalArgumentException( "Unsupported class file major version " + readShort(classFileOffset + 6)); } @@ -414,6 +415,7 @@ public void accept(final ClassVisitor classVisitor, final int parsingOptions) { * @param parsingOptions the options to use to parse this class. One or more of {@link * #SKIP_CODE}, {@link #SKIP_DEBUG}, {@link #SKIP_FRAMES} or {@link #EXPAND_FRAMES}. */ + @SuppressWarnings("deprecation") public void accept( final ClassVisitor classVisitor, final Attribute[] attributePrototypes, @@ -466,6 +468,10 @@ public void accept( String nestHostClass = null; // - The offset of the NestMembers attribute, or 0. int nestMembersOffset = 0; + // - The offset of the PermittedSubtypes attribute, or 0 + int permittedSubtypesOffset = 0; + // - The offset of the Record attribute, or 0. + int recordOffset = 0; // - The non standard attributes (linked with their {@link Attribute#nextAttribute} field). // This list in the reverse order or their order in the ClassFile structure. Attribute attributes = null; @@ -488,6 +494,8 @@ public void accept( nestHostClass = readClass(currentAttributeOffset, charBuffer); } else if (Constants.NEST_MEMBERS.equals(attributeName)) { nestMembersOffset = currentAttributeOffset; + } else if (Constants.PERMITTED_SUBTYPES.equals(attributeName)) { + permittedSubtypesOffset = currentAttributeOffset; } else if (Constants.SIGNATURE.equals(attributeName)) { signature = readUTF8(currentAttributeOffset, charBuffer); } else if (Constants.RUNTIME_VISIBLE_ANNOTATIONS.equals(attributeName)) { @@ -505,6 +513,8 @@ public void accept( runtimeInvisibleAnnotationsOffset = currentAttributeOffset; } else if (Constants.RUNTIME_INVISIBLE_TYPE_ANNOTATIONS.equals(attributeName)) { runtimeInvisibleTypeAnnotationsOffset = currentAttributeOffset; + } else if (Constants.RECORD.equals(attributeName)) { + recordOffset = currentAttributeOffset; } else if (Constants.MODULE.equals(attributeName)) { moduleOffset = currentAttributeOffset; } else if (Constants.MODULE_MAIN_CLASS.equals(attributeName)) { @@ -662,6 +672,17 @@ public void accept( } } + // Visit the PermittedSubtypes attribute. + if (permittedSubtypesOffset != 0) { + int numberOfPermittedSubtypes = readUnsignedShort(permittedSubtypesOffset); + int currentPermittedSubtypeOffset = permittedSubtypesOffset + 2; + while (numberOfPermittedSubtypes-- > 0) { + classVisitor.visitPermittedSubtypeExperimental( + readClass(currentPermittedSubtypeOffset, charBuffer)); + currentPermittedSubtypeOffset += 2; + } + } + // Visit the InnerClasses attribute. if (innerClassesOffset != 0) { int numberOfClasses = readUnsignedShort(innerClassesOffset); @@ -676,6 +697,15 @@ public void accept( } } + // Visit Record components. + if (recordOffset != 0) { + int recordComponentsCount = readUnsignedShort(recordOffset); + recordOffset += 2; + while (recordComponentsCount-- > 0) { + recordOffset = readRecordComponent(classVisitor, context, recordOffset); + } + } + // Visit the fields and methods. int fieldsCount = readUnsignedShort(currentOffset); currentOffset += 2; @@ -823,6 +853,186 @@ private void readModuleAttributes( moduleVisitor.visitEnd(); } + /** + * Reads a record component and visit it. + * + * @param classVisitor the current class visitor + * @param context information about the class being parsed. + * @param recordComponentOffset the offset of the current record component. + * @return the offset of the first byte following the record component. + */ + @SuppressWarnings("deprecation") + private int readRecordComponent( + final ClassVisitor classVisitor, final Context context, final int recordComponentOffset) { + char[] charBuffer = context.charBuffer; + + int currentOffset = recordComponentOffset; + String name = readUTF8(currentOffset, charBuffer); + String descriptor = readUTF8(currentOffset + 2, charBuffer); + currentOffset += 4; + + // Read the record component attributes (the variables are ordered as in Section 4.7 of the + // JVMS). + + int accessFlags = 0; + // Attribute offsets exclude the attribute_name_index and attribute_length fields. + // - The string corresponding to the Signature attribute, or null. + String signature = null; + // - The offset of the RuntimeVisibleAnnotations attribute, or 0. + int runtimeVisibleAnnotationsOffset = 0; + // - The offset of the RuntimeInvisibleAnnotations attribute, or 0. + int runtimeInvisibleAnnotationsOffset = 0; + // - The offset of the RuntimeVisibleTypeAnnotations attribute, or 0. + int runtimeVisibleTypeAnnotationsOffset = 0; + // - The offset of the RuntimeInvisibleTypeAnnotations attribute, or 0. + int runtimeInvisibleTypeAnnotationsOffset = 0; + // - The non standard attributes (linked with their {@link Attribute#nextAttribute} field). + // This list in the reverse order or their order in the ClassFile structure. + Attribute attributes = null; + + int attributesCount = readUnsignedShort(currentOffset); + currentOffset += 2; + while (attributesCount-- > 0) { + // Read the attribute_info's attribute_name and attribute_length fields. + String attributeName = readUTF8(currentOffset, charBuffer); + int attributeLength = readInt(currentOffset + 2); + currentOffset += 6; + // The tests are sorted in decreasing frequency order (based on frequencies observed on + // typical classes). + if (Constants.SIGNATURE.equals(attributeName)) { + signature = readUTF8(currentOffset, charBuffer); + } else if (Constants.DEPRECATED.equals(attributeName)) { + accessFlags |= Opcodes.ACC_DEPRECATED; + } else if (Constants.RUNTIME_VISIBLE_ANNOTATIONS.equals(attributeName)) { + runtimeVisibleAnnotationsOffset = currentOffset; + } else if (Constants.RUNTIME_VISIBLE_TYPE_ANNOTATIONS.equals(attributeName)) { + runtimeVisibleTypeAnnotationsOffset = currentOffset; + } else if (Constants.RUNTIME_INVISIBLE_ANNOTATIONS.equals(attributeName)) { + runtimeInvisibleAnnotationsOffset = currentOffset; + } else if (Constants.RUNTIME_INVISIBLE_TYPE_ANNOTATIONS.equals(attributeName)) { + runtimeInvisibleTypeAnnotationsOffset = currentOffset; + } else { + Attribute attribute = + readAttribute( + context.attributePrototypes, + attributeName, + currentOffset, + attributeLength, + charBuffer, + -1, + null); + attribute.nextAttribute = attributes; + attributes = attribute; + } + currentOffset += attributeLength; + } + + RecordComponentVisitor recordComponentVisitor = + classVisitor.visitRecordComponentExperimental(accessFlags, name, descriptor, signature); + if (recordComponentVisitor == null) { + return currentOffset; + } + + // Visit the RuntimeVisibleAnnotations attribute. + if (runtimeVisibleAnnotationsOffset != 0) { + int numAnnotations = readUnsignedShort(runtimeVisibleAnnotationsOffset); + int currentAnnotationOffset = runtimeVisibleAnnotationsOffset + 2; + while (numAnnotations-- > 0) { + // Parse the type_index field. + String annotationDescriptor = readUTF8(currentAnnotationOffset, charBuffer); + currentAnnotationOffset += 2; + // Parse num_element_value_pairs and element_value_pairs and visit these values. + currentAnnotationOffset = + readElementValues( + recordComponentVisitor.visitAnnotationExperimental( + annotationDescriptor, /* visible = */ true), + currentAnnotationOffset, + /* named = */ true, + charBuffer); + } + } + + // Visit the RuntimeInvisibleAnnotations attribute. + if (runtimeInvisibleAnnotationsOffset != 0) { + int numAnnotations = readUnsignedShort(runtimeInvisibleAnnotationsOffset); + int currentAnnotationOffset = runtimeInvisibleAnnotationsOffset + 2; + while (numAnnotations-- > 0) { + // Parse the type_index field. + String annotationDescriptor = readUTF8(currentAnnotationOffset, charBuffer); + currentAnnotationOffset += 2; + // Parse num_element_value_pairs and element_value_pairs and visit these values. + currentAnnotationOffset = + readElementValues( + recordComponentVisitor.visitAnnotationExperimental( + annotationDescriptor, /* visible = */ false), + currentAnnotationOffset, + /* named = */ true, + charBuffer); + } + } + + // Visit the RuntimeVisibleTypeAnnotations attribute. + if (runtimeVisibleTypeAnnotationsOffset != 0) { + int numAnnotations = readUnsignedShort(runtimeVisibleTypeAnnotationsOffset); + int currentAnnotationOffset = runtimeVisibleTypeAnnotationsOffset + 2; + while (numAnnotations-- > 0) { + // Parse the target_type, target_info and target_path fields. + currentAnnotationOffset = readTypeAnnotationTarget(context, currentAnnotationOffset); + // Parse the type_index field. + String annotationDescriptor = readUTF8(currentAnnotationOffset, charBuffer); + currentAnnotationOffset += 2; + // Parse num_element_value_pairs and element_value_pairs and visit these values. + currentAnnotationOffset = + readElementValues( + recordComponentVisitor.visitTypeAnnotationExperimental( + context.currentTypeAnnotationTarget, + context.currentTypeAnnotationTargetPath, + annotationDescriptor, + /* visible = */ true), + currentAnnotationOffset, + /* named = */ true, + charBuffer); + } + } + + // Visit the RuntimeInvisibleTypeAnnotations attribute. + if (runtimeInvisibleTypeAnnotationsOffset != 0) { + int numAnnotations = readUnsignedShort(runtimeInvisibleTypeAnnotationsOffset); + int currentAnnotationOffset = runtimeInvisibleTypeAnnotationsOffset + 2; + while (numAnnotations-- > 0) { + // Parse the target_type, target_info and target_path fields. + currentAnnotationOffset = readTypeAnnotationTarget(context, currentAnnotationOffset); + // Parse the type_index field. + String annotationDescriptor = readUTF8(currentAnnotationOffset, charBuffer); + currentAnnotationOffset += 2; + // Parse num_element_value_pairs and element_value_pairs and visit these values. + currentAnnotationOffset = + readElementValues( + recordComponentVisitor.visitTypeAnnotationExperimental( + context.currentTypeAnnotationTarget, + context.currentTypeAnnotationTargetPath, + annotationDescriptor, + /* visible = */ false), + currentAnnotationOffset, + /* named = */ true, + charBuffer); + } + } + + // Visit the non standard attributes. + while (attributes != null) { + // Copy and reset the nextAttribute field so that it can also be used in FieldWriter. + Attribute nextAttribute = attributes.nextAttribute; + attributes.nextAttribute = null; + recordComponentVisitor.visitAttributeExperimental(attributes); + attributes = nextAttribute; + } + + // Visit the end of the field. + recordComponentVisitor.visitEndExperimental(); + return currentOffset; + } + /** * Reads a JVMS field_info structure and makes the given visitor visit it. * @@ -1149,7 +1359,7 @@ private int readMethod( } // Visit the MethodParameters attribute. - if (methodParametersOffset != 0) { + if (methodParametersOffset != 0 && (context.parsingOptions & SKIP_DEBUG) == 0) { int parametersCount = readByte(methodParametersOffset); int currentParameterOffset = methodParametersOffset + 1; while (parametersCount-- > 0) { diff --git a/spring-core/src/main/java/org/springframework/asm/ClassVisitor.java b/spring-core/src/main/java/org/springframework/asm/ClassVisitor.java index 463499cacce8..856b77f04953 100644 --- a/spring-core/src/main/java/org/springframework/asm/ClassVisitor.java +++ b/spring-core/src/main/java/org/springframework/asm/ClassVisitor.java @@ -30,9 +30,9 @@ /** * A visitor to visit a Java class. The methods of this class must be called in the following order: * {@code visit} [ {@code visitSource} ] [ {@code visitModule} ][ {@code visitNestHost} ][ {@code - * visitOuterClass} ] ( {@code visitAnnotation} | {@code visitTypeAnnotation} | {@code - * visitAttribute} )* ( {@code visitNestMember} | {@code visitInnerClass} | {@code visitField} | - * {@code visitMethod} )* {@code visitEnd}. + * visitPermittedSubtype} ][ {@code visitOuterClass} ] ( {@code visitAnnotation} | {@code + * visitTypeAnnotation} | {@code visitAttribute} )* ( {@code visitNestMember} | {@code + * visitInnerClass} | {@code visitField} | {@code visitMethod} )* {@code visitEnd}. * * @author Eric Bruneton */ @@ -65,10 +65,18 @@ public ClassVisitor(final int api) { * @param classVisitor the class visitor to which this visitor must delegate method calls. May be * null. */ + @SuppressWarnings("deprecation") public ClassVisitor(final int api, final ClassVisitor classVisitor) { - if (api != Opcodes.ASM7 && api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } + if (api == Opcodes.ASM8_EXPERIMENTAL) { + Constants.checkAsm8Experimental(this); + } this.api = api; this.cv = classVisitor; } @@ -240,6 +248,24 @@ public void visitNestMember(final String nestMember) { } } + /** + * Experimental, use at your own risk. This method will be renamed when it becomes stable, this + * will break existing code using it. Visits a permitted subtypes. A permitted subtypes is one + * of the allowed subtypes of the current class. + * + * @param permittedSubtype the internal name of a permitted subtype. + * @deprecated this API is experimental. + */ + @Deprecated + public void visitPermittedSubtypeExperimental(final String permittedSubtype) { + if (api != Opcodes.ASM8_EXPERIMENTAL) { + throw new UnsupportedOperationException("This feature requires ASM8_EXPERIMENTAL"); + } + if (cv != null) { + cv.visitPermittedSubtypeExperimental(permittedSubtype); + } + } + /** * Visits information about an inner class. This inner class is not necessarily a member of the * class being visited. @@ -259,6 +285,31 @@ public void visitInnerClass( } } + /** + * Visits a record component of the class. + * + * @param access the record component access flags, the only possible value is {@link + * Opcodes#ACC_DEPRECATED}. + * @param name the record component name. + * @param descriptor the record component descriptor (see {@link Type}). + * @param signature the record component signature. May be {@literal null} if the record component + * type does not use generic types. + * @return a visitor to visit this record component annotations and attributes, or {@literal null} + * if this class visitor is not interested in visiting these annotations and attributes. + * @deprecated this API is experimental. + */ + @Deprecated + public RecordComponentVisitor visitRecordComponentExperimental( + final int access, final String name, final String descriptor, final String signature) { + if (api < Opcodes.ASM8_EXPERIMENTAL) { + throw new UnsupportedOperationException("This feature requires ASM8_EXPERIMENTAL"); + } + if (cv != null) { + return cv.visitRecordComponentExperimental(access, name, descriptor, signature); + } + return null; + } + /** * Visits a field of the class. * diff --git a/spring-core/src/main/java/org/springframework/asm/ClassWriter.java b/spring-core/src/main/java/org/springframework/asm/ClassWriter.java index e3d2dfd94646..60074927a558 100644 --- a/spring-core/src/main/java/org/springframework/asm/ClassWriter.java +++ b/spring-core/src/main/java/org/springframework/asm/ClassWriter.java @@ -177,6 +177,26 @@ public class ClassWriter extends ClassVisitor { /** The 'classes' array of the NestMembers attribute, or {@literal null}. */ private ByteVector nestMemberClasses; + /** The number_of_classes field of the PermittedSubtypes attribute, or 0. */ + private int numberOfPermittedSubtypeClasses; + + /** The 'classes' array of the PermittedSubtypes attribute, or {@literal null}. */ + private ByteVector permittedSubtypeClasses; + + /** + * The record components of this class, stored in a linked list of {@link RecordComponentWriter} + * linked via their {@link RecordComponentWriter#delegate} field. This field stores the first + * element of this list. + */ + private RecordComponentWriter firstRecordComponent; + + /** + * The record components of this class, stored in a linked list of {@link RecordComponentWriter} + * linked via their {@link RecordComponentWriter#delegate} field. This field stores the last + * element of this list. + */ + private RecordComponentWriter lastRecordComponent; + /** * The first non standard attribute of this class. The next ones can be accessed with the {@link * Attribute#nextAttribute} field. May be {@literal null}. @@ -234,7 +254,7 @@ public ClassWriter(final int flags) { * maximum stack size nor the stack frames will be computed for these methods. */ public ClassWriter(final ClassReader classReader, final int flags) { - super(Opcodes.ASM7); + super(/* latest api = */ Opcodes.ASM7); symbolTable = classReader == null ? new SymbolTable(this) : new SymbolTable(this, classReader); if ((flags & COMPUTE_FRAMES) != 0) { this.compute = MethodWriter.COMPUTE_ALL_FRAMES; @@ -352,6 +372,16 @@ public final void visitNestMember(final String nestMember) { nestMemberClasses.putShort(symbolTable.addConstantClass(nestMember).index); } + @Override + @SuppressWarnings("deprecation") + public final void visitPermittedSubtypeExperimental(final String permittedSubtype) { + if (permittedSubtypeClasses == null) { + permittedSubtypeClasses = new ByteVector(); + } + ++numberOfPermittedSubtypeClasses; + permittedSubtypeClasses.putShort(symbolTable.addConstantClass(permittedSubtype).index); + } + @Override public final void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { @@ -377,6 +407,20 @@ public final void visitInnerClass( // and throw an exception if there is a difference? } + @Override + @SuppressWarnings("deprecation") + public final RecordComponentVisitor visitRecordComponentExperimental( + final int access, final String name, final String descriptor, final String signature) { + RecordComponentWriter recordComponentWriter = + new RecordComponentWriter(symbolTable, access, name, descriptor, signature); + if (firstRecordComponent == null) { + firstRecordComponent = recordComponentWriter; + } else { + lastRecordComponent.delegate = recordComponentWriter; + } + return lastRecordComponent = recordComponentWriter; + } + @Override public final FieldVisitor visitField( final int access, @@ -447,6 +491,7 @@ public byte[] toByteArray() { size += methodWriter.computeMethodInfoSize(); methodWriter = (MethodWriter) methodWriter.mv; } + // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS. int attributesCount = 0; if (innerClasses != null) { @@ -526,6 +571,24 @@ public byte[] toByteArray() { size += 8 + nestMemberClasses.length; symbolTable.addConstantUtf8(Constants.NEST_MEMBERS); } + if (permittedSubtypeClasses != null) { + ++attributesCount; + size += 8 + permittedSubtypeClasses.length; + symbolTable.addConstantUtf8(Constants.PERMITTED_SUBTYPES); + } + int recordComponentCount = 0; + int recordSize = 0; + if (firstRecordComponent != null) { + RecordComponentWriter recordComponentWriter = firstRecordComponent; + while (recordComponentWriter != null) { + ++recordComponentCount; + recordSize += recordComponentWriter.computeRecordComponentInfoSize(); + recordComponentWriter = (RecordComponentWriter) recordComponentWriter.delegate; + } + ++attributesCount; + size += 8 + recordSize; + symbolTable.addConstantUtf8(Constants.RECORD); + } if (firstAttribute != null) { attributesCount += firstAttribute.getAttributeCount(); size += firstAttribute.computeAttributesSize(symbolTable); @@ -630,6 +693,24 @@ public byte[] toByteArray() { .putShort(numberOfNestMemberClasses) .putByteArray(nestMemberClasses.data, 0, nestMemberClasses.length); } + if (permittedSubtypeClasses != null) { + result + .putShort(symbolTable.addConstantUtf8(Constants.PERMITTED_SUBTYPES)) + .putInt(permittedSubtypeClasses.length + 2) + .putShort(numberOfPermittedSubtypeClasses) + .putByteArray(permittedSubtypeClasses.data, 0, permittedSubtypeClasses.length); + } + if (firstRecordComponent != null) { + result + .putShort(symbolTable.addConstantUtf8(Constants.RECORD)) + .putInt(recordSize + 2) + .putShort(recordComponentCount); + RecordComponentWriter recordComponentWriter = firstRecordComponent; + while (recordComponentWriter != null) { + recordComponentWriter.putRecordComponentInfo(result); + recordComponentWriter = (RecordComponentWriter) recordComponentWriter.delegate; + } + } if (firstAttribute != null) { firstAttribute.putAttributes(symbolTable, result); } @@ -666,6 +747,10 @@ private byte[] replaceAsmInstructions(final byte[] classFile, final boolean hasF nestHostClassIndex = 0; numberOfNestMemberClasses = 0; nestMemberClasses = null; + numberOfPermittedSubtypeClasses = 0; + permittedSubtypeClasses = null; + firstRecordComponent = null; + lastRecordComponent = null; firstAttribute = null; compute = hasFrames ? MethodWriter.COMPUTE_INSERTED_FRAMES : MethodWriter.COMPUTE_NOTHING; new ClassReader(classFile, 0, /* checkClassVersion = */ false) @@ -694,6 +779,11 @@ private Attribute[] getAttributePrototypes() { methodWriter.collectAttributePrototypes(attributePrototypes); methodWriter = (MethodWriter) methodWriter.mv; } + RecordComponentWriter recordComponentWriter = firstRecordComponent; + while (recordComponentWriter != null) { + recordComponentWriter.collectAttributePrototypes(attributePrototypes); + recordComponentWriter = (RecordComponentWriter) recordComponentWriter.delegate; + } return attributePrototypes.toArray(); } diff --git a/spring-core/src/main/java/org/springframework/asm/Constants.java b/spring-core/src/main/java/org/springframework/asm/Constants.java index 4713f09e5fe2..f94f1197575a 100644 --- a/spring-core/src/main/java/org/springframework/asm/Constants.java +++ b/spring-core/src/main/java/org/springframework/asm/Constants.java @@ -27,6 +27,11 @@ // THE POSSIBILITY OF SUCH DAMAGE. package org.springframework.asm; +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.regex.Pattern; + /** * Defines additional JVM opcodes, access flags and constants which are not part of the ASM public * API. @@ -56,7 +61,8 @@ final class Constants implements Opcodes { static final String RUNTIME_VISIBLE_ANNOTATIONS = "RuntimeVisibleAnnotations"; static final String RUNTIME_INVISIBLE_ANNOTATIONS = "RuntimeInvisibleAnnotations"; static final String RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = "RuntimeVisibleParameterAnnotations"; - static final String RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = "RuntimeInvisibleParameterAnnotations"; + static final String RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = + "RuntimeInvisibleParameterAnnotations"; static final String RUNTIME_VISIBLE_TYPE_ANNOTATIONS = "RuntimeVisibleTypeAnnotations"; static final String RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = "RuntimeInvisibleTypeAnnotations"; static final String ANNOTATION_DEFAULT = "AnnotationDefault"; @@ -67,6 +73,8 @@ final class Constants implements Opcodes { static final String MODULE_MAIN_CLASS = "ModuleMainClass"; static final String NEST_HOST = "NestHost"; static final String NEST_MEMBERS = "NestMembers"; + static final String PERMITTED_SUBTYPES = "PermittedSubtypes"; + static final String RECORD = "Record"; // ASM specific access flags. // WARNING: the 16 least significant bits must NOT be used, to avoid conflicts with standard @@ -173,4 +181,41 @@ final class Constants implements Opcodes { static final int ASM_GOTO_W = 220; private Constants() {} + + static void checkAsm8Experimental(final Object caller) { + Class callerClass = caller.getClass(); + String internalName = callerClass.getName().replace('.', '/'); + if (!isWhitelisted(internalName)) { + checkIsPreview(callerClass.getClassLoader().getResourceAsStream(internalName + ".class")); + } + } + + static boolean isWhitelisted(final String internalName) { + if (!internalName.startsWith("org/objectweb/asm/")) { + return false; + } + String member = "(Annotation|Class|Field|Method|Module|RecordComponent|Signature)"; + return internalName.contains("Test$") + || Pattern.matches( + "org/objectweb/asm/util/Trace" + member + "Visitor(\\$.*)?", internalName) + || Pattern.matches( + "org/objectweb/asm/util/Check" + member + "Adapter(\\$.*)?", internalName); + } + + static void checkIsPreview(final InputStream classInputStream) { + if (classInputStream == null) { + throw new IllegalStateException("Bytecode not available, can't check class version"); + } + int minorVersion; + try (DataInputStream callerClassStream = new DataInputStream(classInputStream); ) { + callerClassStream.readInt(); + minorVersion = callerClassStream.readUnsignedShort(); + } catch (IOException ioe) { + throw new IllegalStateException("I/O error, can't check class version", ioe); + } + if (minorVersion != 0xFFFF) { + throw new IllegalStateException( + "ASM8_EXPERIMENTAL can only be used by classes compiled with --enable-preview"); + } + } } diff --git a/spring-core/src/main/java/org/springframework/asm/FieldVisitor.java b/spring-core/src/main/java/org/springframework/asm/FieldVisitor.java index 04d3d2e92221..bd17f86796d4 100644 --- a/spring-core/src/main/java/org/springframework/asm/FieldVisitor.java +++ b/spring-core/src/main/java/org/springframework/asm/FieldVisitor.java @@ -63,10 +63,18 @@ public FieldVisitor(final int api) { * @param fieldVisitor the field visitor to which this visitor must delegate method calls. May be * null. */ + @SuppressWarnings("deprecation") public FieldVisitor(final int api, final FieldVisitor fieldVisitor) { - if (api != Opcodes.ASM7 && api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } + if (api == Opcodes.ASM8_EXPERIMENTAL) { + Constants.checkAsm8Experimental(this); + } this.api = api; this.fv = fieldVisitor; } diff --git a/spring-core/src/main/java/org/springframework/asm/FieldWriter.java b/spring-core/src/main/java/org/springframework/asm/FieldWriter.java index 0b4ca89d7e3d..ab8ad32ee590 100644 --- a/spring-core/src/main/java/org/springframework/asm/FieldWriter.java +++ b/spring-core/src/main/java/org/springframework/asm/FieldWriter.java @@ -124,7 +124,7 @@ final class FieldWriter extends FieldVisitor { final String descriptor, final String signature, final Object constantValue) { - super(Opcodes.ASM7); + super(/* latest api = */ Opcodes.ASM7); this.symbolTable = symbolTable; this.accessFlags = access; this.nameIndex = symbolTable.addConstantUtf8(name); diff --git a/spring-core/src/main/java/org/springframework/asm/MethodVisitor.java b/spring-core/src/main/java/org/springframework/asm/MethodVisitor.java index 0f987f072919..ab905e8084cb 100644 --- a/spring-core/src/main/java/org/springframework/asm/MethodVisitor.java +++ b/spring-core/src/main/java/org/springframework/asm/MethodVisitor.java @@ -79,10 +79,18 @@ public MethodVisitor(final int api) { * @param methodVisitor the method visitor to which this visitor must delegate method calls. May * be null. */ + @SuppressWarnings("deprecation") public MethodVisitor(final int api, final MethodVisitor methodVisitor) { - if (api != Opcodes.ASM7 && api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } + if (api == Opcodes.ASM8_EXPERIMENTAL) { + Constants.checkAsm8Experimental(this); + } this.api = api; this.mv = methodVisitor; } @@ -534,7 +542,7 @@ public void visitLdcInsn(final Object value) { || (value instanceof Type && ((Type) value).getSort() == Type.METHOD))) { throw new UnsupportedOperationException(REQUIRES_ASM5); } - if (api != Opcodes.ASM7 && value instanceof ConstantDynamic) { + if (api < Opcodes.ASM7 && value instanceof ConstantDynamic) { throw new UnsupportedOperationException("This feature requires ASM7"); } if (mv != null) { diff --git a/spring-core/src/main/java/org/springframework/asm/MethodWriter.java b/spring-core/src/main/java/org/springframework/asm/MethodWriter.java index 39ab255be60f..4cc0552dc85a 100644 --- a/spring-core/src/main/java/org/springframework/asm/MethodWriter.java +++ b/spring-core/src/main/java/org/springframework/asm/MethodWriter.java @@ -592,7 +592,7 @@ final class MethodWriter extends MethodVisitor { final String signature, final String[] exceptions, final int compute) { - super(Opcodes.ASM7); + super(/* latest api = */ Opcodes.ASM7); this.symbolTable = symbolTable; this.accessFlags = "".equals(name) ? access | Constants.ACC_CONSTRUCTOR : access; this.nameIndex = symbolTable.addConstantUtf8(name); diff --git a/spring-core/src/main/java/org/springframework/asm/ModuleVisitor.java b/spring-core/src/main/java/org/springframework/asm/ModuleVisitor.java index e8c2b0628659..afdb37279f22 100644 --- a/spring-core/src/main/java/org/springframework/asm/ModuleVisitor.java +++ b/spring-core/src/main/java/org/springframework/asm/ModuleVisitor.java @@ -65,10 +65,18 @@ public ModuleVisitor(final int api) { * @param moduleVisitor the module visitor to which this visitor must delegate method calls. May * be null. */ + @SuppressWarnings("deprecation") public ModuleVisitor(final int api, final ModuleVisitor moduleVisitor) { - if (api != Opcodes.ASM7 && api != Opcodes.ASM6) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } + if (api == Opcodes.ASM8_EXPERIMENTAL) { + Constants.checkAsm8Experimental(this); + } this.api = api; this.mv = moduleVisitor; } diff --git a/spring-core/src/main/java/org/springframework/asm/ModuleWriter.java b/spring-core/src/main/java/org/springframework/asm/ModuleWriter.java index 8a54e652df78..e23e28cac474 100644 --- a/spring-core/src/main/java/org/springframework/asm/ModuleWriter.java +++ b/spring-core/src/main/java/org/springframework/asm/ModuleWriter.java @@ -94,7 +94,7 @@ final class ModuleWriter extends ModuleVisitor { private int mainClassIndex; ModuleWriter(final SymbolTable symbolTable, final int name, final int access, final int version) { - super(Opcodes.ASM7); + super(/* latest api = */ Opcodes.ASM7); this.symbolTable = symbolTable; this.moduleNameIndex = name; this.moduleFlags = access; diff --git a/spring-core/src/main/java/org/springframework/asm/Opcodes.java b/spring-core/src/main/java/org/springframework/asm/Opcodes.java index 90bd930fcc34..21fa7287b216 100644 --- a/spring-core/src/main/java/org/springframework/asm/Opcodes.java +++ b/spring-core/src/main/java/org/springframework/asm/Opcodes.java @@ -48,6 +48,14 @@ public interface Opcodes { int ASM6 = 6 << 16 | 0 << 8; int ASM7 = 7 << 16 | 0 << 8; + /** + * Experimental, use at your own risk. This field will be renamed when it becomes stable, this + * will break existing code using it. Only code compiled with --enable-preview can use this. + * + * @deprecated This API is experimental. + */ + @Deprecated int ASM8_EXPERIMENTAL = 1 << 24 | 8 << 16 | 0 << 8; + /* * Internal flags used to redirect calls to deprecated methods. For instance, if a visitOldStuff * method in API_OLD is deprecated and replaced with visitNewStuff in API_NEW, then the @@ -270,6 +278,7 @@ public interface Opcodes { int V12 = 0 << 16 | 56; int V13 = 0 << 16 | 57; int V14 = 0 << 16 | 58; + int V15 = 0 << 16 | 59; /** * Version flag indicating that the class is using 'preview' features. @@ -306,7 +315,7 @@ public interface Opcodes { int ACC_SYNTHETIC = 0x1000; // class, field, method, parameter, module * int ACC_ANNOTATION = 0x2000; // class int ACC_ENUM = 0x4000; // class(?) field inner - int ACC_MANDATED = 0x8000; // parameter, module, module * + int ACC_MANDATED = 0x8000; // field, method, parameter, module, module * int ACC_MODULE = 0x8000; // class // ASM specific access flags. diff --git a/spring-core/src/main/java/org/springframework/asm/RecordComponentVisitor.java b/spring-core/src/main/java/org/springframework/asm/RecordComponentVisitor.java new file mode 100644 index 000000000000..4dfab5d1264f --- /dev/null +++ b/spring-core/src/main/java/org/springframework/asm/RecordComponentVisitor.java @@ -0,0 +1,169 @@ +// ASM: a very small and fast Java bytecode manipulation framework +// Copyright (c) 2000-2011 INRIA, France Telecom +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// 3. Neither the name of the copyright holders nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +// THE POSSIBILITY OF SUCH DAMAGE. +package org.springframework.asm; + +/** + * A visitor to visit a record component. The methods of this class must be called in the following + * order: ( {@code visitAnnotation} | {@code visitTypeAnnotation} | {@code visitAttribute} )* {@code + * visitEnd}. + * + * @author Remi Forax + * @author Eric Bruneton + * @deprecated this API is experimental. + */ +@Deprecated +public abstract class RecordComponentVisitor { + /** + * The ASM API version implemented by this visitor. The value of this field must be {@link + * Opcodes#ASM8_EXPERIMENTAL}. + */ + protected final int api; + + /** + * The record visitor to which this visitor must delegate method calls. May be {@literal null}. + */ + /*package-private*/ RecordComponentVisitor delegate; + + /** + * Constructs a new {@link RecordComponentVisitor}. + * + * @param api the ASM API version implemented by this visitor. Must be {@link + * Opcodes#ASM8_EXPERIMENTAL}. + * @deprecated this API is experimental. + */ + @Deprecated + public RecordComponentVisitor(final int api) { + this(api, null); + } + + /** + * Constructs a new {@link RecordComponentVisitor}. + * + * @param api the ASM API version implemented by this visitor. Must be {@link + * Opcodes#ASM8_EXPERIMENTAL}. + * @param recordComponentVisitor the record component visitor to which this visitor must delegate + * method calls. May be null. + * @deprecated this API is experimental. + */ + @Deprecated + public RecordComponentVisitor( + final int api, final RecordComponentVisitor recordComponentVisitor) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { + throw new IllegalArgumentException("Unsupported api " + api); + } + if (api == Opcodes.ASM8_EXPERIMENTAL) { + Constants.checkAsm8Experimental(this); + } + this.api = api; + this.delegate = recordComponentVisitor; + } + + /** + * The record visitor to which this visitor must delegate method calls. May be {@literal null}. + * + * @return the record visitor to which this visitor must delegate method calls or {@literal null}. + * @deprecated this API is experimental. + */ + @Deprecated + public RecordComponentVisitor getDelegateExperimental() { + return delegate; + } + + /** + * Visits an annotation of the record component. + * + * @param descriptor the class descriptor of the annotation class. + * @param visible {@literal true} if the annotation is visible at runtime. + * @return a visitor to visit the annotation values, or {@literal null} if this visitor is not + * interested in visiting this annotation. + * @deprecated this API is experimental. + */ + @Deprecated + public AnnotationVisitor visitAnnotationExperimental( + final String descriptor, final boolean visible) { + if (delegate != null) { + return delegate.visitAnnotationExperimental(descriptor, visible); + } + return null; + } + + /** + * Visits an annotation on a type in the record component signature. + * + * @param typeRef a reference to the annotated type. The sort of this type reference must be + * {@link TypeReference#CLASS_TYPE_PARAMETER}, {@link + * TypeReference#CLASS_TYPE_PARAMETER_BOUND} or {@link TypeReference#CLASS_EXTENDS}. See + * {@link TypeReference}. + * @param typePath the path to the annotated type argument, wildcard bound, array element type, or + * static inner type within 'typeRef'. May be {@literal null} if the annotation targets + * 'typeRef' as a whole. + * @param descriptor the class descriptor of the annotation class. + * @param visible {@literal true} if the annotation is visible at runtime. + * @return a visitor to visit the annotation values, or {@literal null} if this visitor is not + * interested in visiting this annotation. + * @deprecated this API is experimental. + */ + @Deprecated + public AnnotationVisitor visitTypeAnnotationExperimental( + final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { + if (delegate != null) { + return delegate.visitTypeAnnotationExperimental(typeRef, typePath, descriptor, visible); + } + return null; + } + + /** + * Visits a non standard attribute of the record component. + * + * @param attribute an attribute. + * @deprecated this API is experimental. + */ + @Deprecated + public void visitAttributeExperimental(final Attribute attribute) { + if (delegate != null) { + delegate.visitAttributeExperimental(attribute); + } + } + + /** + * Visits the end of the record component. This method, which is the last one to be called, is + * used to inform the visitor that everything have been visited. + * + * @deprecated this API is experimental. + */ + @Deprecated + public void visitEndExperimental() { + if (delegate != null) { + delegate.visitEndExperimental(); + } + } +} diff --git a/spring-core/src/main/java/org/springframework/asm/RecordComponentWriter.java b/spring-core/src/main/java/org/springframework/asm/RecordComponentWriter.java new file mode 100644 index 000000000000..c775fc4bd8f4 --- /dev/null +++ b/spring-core/src/main/java/org/springframework/asm/RecordComponentWriter.java @@ -0,0 +1,242 @@ +// ASM: a very small and fast Java bytecode manipulation framework +// Copyright (c) 2000-2011 INRIA, France Telecom +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// 3. Neither the name of the copyright holders nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +// THE POSSIBILITY OF SUCH DAMAGE. +package org.springframework.asm; + +@SuppressWarnings("deprecation") +final class RecordComponentWriter extends RecordComponentVisitor { + /** Where the constants used in this RecordComponentWriter must be stored. */ + private final SymbolTable symbolTable; + + // Note: fields are ordered as in the component_info structure, and those related to attributes + // are ordered as in Section TODO of the JVMS. + // The field accessFlag doesn't exist in the component_info structure but is used to carry + // ACC_DEPRECATED which is represented by an attribute in the structure and as an access flag by + // ASM. + + /** The access_flags field can only be {@link Opcodes#ACC_DEPRECATED}. */ + private final int accessFlags; + + /** The name_index field of the Record attribute. */ + private final int nameIndex; + + /** The descriptor_index field of the the Record attribute. */ + private final int descriptorIndex; + + /** + * The signature_index field of the Signature attribute of this record component, or 0 if there is + * no Signature attribute. + */ + private int signatureIndex; + + /** + * The last runtime visible annotation of this record component. The previous ones can be accessed + * with the {@link AnnotationWriter#previousAnnotation} field. May be {@literal null}. + */ + private AnnotationWriter lastRuntimeVisibleAnnotation; + + /** + * The last runtime invisible annotation of this record component. The previous ones can be + * accessed with the {@link AnnotationWriter#previousAnnotation} field. May be {@literal null}. + */ + private AnnotationWriter lastRuntimeInvisibleAnnotation; + + /** + * The last runtime visible type annotation of this record component. The previous ones can be + * accessed with the {@link AnnotationWriter#previousAnnotation} field. May be {@literal null}. + */ + private AnnotationWriter lastRuntimeVisibleTypeAnnotation; + + /** + * The last runtime invisible type annotation of this record component. The previous ones can be + * accessed with the {@link AnnotationWriter#previousAnnotation} field. May be {@literal null}. + */ + private AnnotationWriter lastRuntimeInvisibleTypeAnnotation; + + /** + * The first non standard attribute of this record component. The next ones can be accessed with + * the {@link Attribute#nextAttribute} field. May be {@literal null}. + * + *

    WARNING: this list stores the attributes in the reverse order of their visit. + * firstAttribute is actually the last attribute visited in {@link + * #visitAttributeExperimental(Attribute)}. The {@link #putRecordComponentInfo(ByteVector)} method + * writes the attributes in the order defined by this list, i.e. in the reverse order specified by + * the user. + */ + private Attribute firstAttribute; + + /** + * Constructs a new {@link RecordComponentWriter}. + * + * @param symbolTable where the constants used in this RecordComponentWriter must be stored. + * @param accessFlags the record component access flags, only synthetic and/or deprecated. + * @param name the record component name. + * @param descriptor the record component descriptor (see {@link Type}). + * @param signature the record component signature. May be {@literal null}. + */ + RecordComponentWriter( + final SymbolTable symbolTable, + final int accessFlags, + final String name, + final String descriptor, + final String signature) { + super(/* latest api = */ Opcodes.ASM7); + this.symbolTable = symbolTable; + this.accessFlags = accessFlags; + this.nameIndex = symbolTable.addConstantUtf8(name); + this.descriptorIndex = symbolTable.addConstantUtf8(descriptor); + if (signature != null) { + this.signatureIndex = symbolTable.addConstantUtf8(signature); + } + } + + // ----------------------------------------------------------------------------------------------- + // Implementation of the FieldVisitor abstract class + // ----------------------------------------------------------------------------------------------- + + @Override + public AnnotationVisitor visitAnnotationExperimental( + final String descriptor, final boolean visible) { + if (visible) { + return lastRuntimeVisibleAnnotation = + AnnotationWriter.create(symbolTable, descriptor, lastRuntimeVisibleAnnotation); + } else { + return lastRuntimeInvisibleAnnotation = + AnnotationWriter.create(symbolTable, descriptor, lastRuntimeInvisibleAnnotation); + } + } + + @Override + public AnnotationVisitor visitTypeAnnotationExperimental( + final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { + if (visible) { + return lastRuntimeVisibleTypeAnnotation = + AnnotationWriter.create( + symbolTable, typeRef, typePath, descriptor, lastRuntimeVisibleTypeAnnotation); + } else { + return lastRuntimeInvisibleTypeAnnotation = + AnnotationWriter.create( + symbolTable, typeRef, typePath, descriptor, lastRuntimeInvisibleTypeAnnotation); + } + } + + @Override + public void visitAttributeExperimental(final Attribute attribute) { + // Store the attributes in the reverse order of their visit by this method. + attribute.nextAttribute = firstAttribute; + firstAttribute = attribute; + } + + @Override + public void visitEndExperimental() { + // Nothing to do. + } + + // ----------------------------------------------------------------------------------------------- + // Utility methods + // ----------------------------------------------------------------------------------------------- + + /** + * Returns the size of the record component JVMS structure generated by this + * RecordComponentWriter. Also adds the names of the attributes of this record component in the + * constant pool. + * + * @return the size in bytes of the record_component_info of the Record attribute. + */ + int computeRecordComponentInfoSize() { + // name_index, descriptor_index and attributes_count fields use 6 bytes. + int size = 6; + size += + Attribute.computeAttributesSize( + symbolTable, accessFlags & Opcodes.ACC_DEPRECATED, signatureIndex); + size += + AnnotationWriter.computeAnnotationsSize( + lastRuntimeVisibleAnnotation, + lastRuntimeInvisibleAnnotation, + lastRuntimeVisibleTypeAnnotation, + lastRuntimeInvisibleTypeAnnotation); + if (firstAttribute != null) { + size += firstAttribute.computeAttributesSize(symbolTable); + } + return size; + } + + /** + * Puts the content of the record component generated by this RecordComponentWriter into the given + * ByteVector. + * + * @param output where the record_component_info structure must be put. + */ + void putRecordComponentInfo(final ByteVector output) { + output.putShort(nameIndex).putShort(descriptorIndex); + // Compute and put the attributes_count field. + // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS. + int attributesCount = 0; + if (signatureIndex != 0) { + ++attributesCount; + } + if ((accessFlags & Opcodes.ACC_DEPRECATED) != 0) { + ++attributesCount; + } + if (lastRuntimeVisibleAnnotation != null) { + ++attributesCount; + } + if (lastRuntimeInvisibleAnnotation != null) { + ++attributesCount; + } + if (lastRuntimeVisibleTypeAnnotation != null) { + ++attributesCount; + } + if (lastRuntimeInvisibleTypeAnnotation != null) { + ++attributesCount; + } + if (firstAttribute != null) { + attributesCount += firstAttribute.getAttributeCount(); + } + output.putShort(attributesCount); + Attribute.putAttributes(symbolTable, accessFlags, signatureIndex, output); + AnnotationWriter.putAnnotations( + symbolTable, + lastRuntimeVisibleAnnotation, + lastRuntimeInvisibleAnnotation, + lastRuntimeVisibleTypeAnnotation, + lastRuntimeInvisibleTypeAnnotation, + output); + if (firstAttribute != null) { + firstAttribute.putAttributes(symbolTable, output); + } + } + + /** + * Collects the attributes of this record component into the given set of attribute prototypes. + * + * @param attributePrototypes a set of attribute prototypes. + */ + final void collectAttributePrototypes(final Attribute.Set attributePrototypes) { + attributePrototypes.addAttributes(firstAttribute); + } +} From f9a73503f4976b3c91732c353515cb91e3829344 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 27 Jan 2020 18:19:23 +0100 Subject: [PATCH 0362/2315] Upgrade to Hibernate Validator 6.1.1 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bff16637f761..3233d8493450 100644 --- a/build.gradle +++ b/build.gradle @@ -125,7 +125,7 @@ configure(allprojects) { project -> dependency "org.ehcache:jcache:1.0.1" dependency "org.ehcache:ehcache:3.4.0" dependency "org.hibernate:hibernate-core:5.4.10.Final" - dependency "org.hibernate:hibernate-validator:6.1.0.Final" + dependency "org.hibernate:hibernate-validator:6.1.1.Final" dependency "org.webjars:webjars-locator-core:0.43" dependency "org.webjars:underscorejs:1.8.3" From eeaae16b1792debe9aa942b16c8fec0acd543162 Mon Sep 17 00:00:00 2001 From: Sviatoslav Date: Sun, 26 Jan 2020 14:23:22 +0000 Subject: [PATCH 0363/2315] Remove dated mention of "local" bean attribute Closes gh-24430 --- src/docs/asciidoc/core/core-beans.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc index 1b1af8d8104b..073a3051acac 100644 --- a/src/docs/asciidoc/core/core-beans.adoc +++ b/src/docs/asciidoc/core/core-beans.adoc @@ -1565,7 +1565,7 @@ is a dependency of the bean whose property is to be set, and it is initialized o as needed before the property is set. (If the collaborator is a singleton bean, it may already be initialized by the container.) All references are ultimately a reference to another object. Scoping and validation depend on whether you specify the ID or name of the -other object through the `bean`, `local,` or `parent` attributes. +other object through the `bean`, or `parent` attributes. Specifying the target bean through the `bean` attribute of the `` tag is the most general form and allows creation of a reference to any bean in the same container or From 2c86d6ded2b3009b4e4d7e855e47cb6cfa7439db Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 28 Jan 2020 10:48:59 +0100 Subject: [PATCH 0364/2315] Polishing --- src/docs/asciidoc/core/core-beans.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc index 073a3051acac..667a6f94dcfd 100644 --- a/src/docs/asciidoc/core/core-beans.adoc +++ b/src/docs/asciidoc/core/core-beans.adoc @@ -1565,7 +1565,7 @@ is a dependency of the bean whose property is to be set, and it is initialized o as needed before the property is set. (If the collaborator is a singleton bean, it may already be initialized by the container.) All references are ultimately a reference to another object. Scoping and validation depend on whether you specify the ID or name of the -other object through the `bean`, or `parent` attributes. +other object through the `bean` or `parent` attribute. Specifying the target bean through the `bean` attribute of the `` tag is the most general form and allows creation of a reference to any bean in the same container or From 64440a5f04a17b3728234afaa89f57766768decb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A6=D1=8B=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 28 Jan 2020 12:07:40 +0200 Subject: [PATCH 0365/2315] Some trivial improvements to reduce allocation pressure Closes gh-24447 --- .../beans/support/ArgumentConvertingMethodInvoker.java | 7 ++++--- .../java/org/springframework/core/GenericTypeResolver.java | 5 +++-- .../type/classreading/MethodMetadataReadingVisitor.java | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/support/ArgumentConvertingMethodInvoker.java b/spring-beans/src/main/java/org/springframework/beans/support/ArgumentConvertingMethodInvoker.java index 006da60e4d03..bdd72f24d380 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/ArgumentConvertingMethodInvoker.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/ArgumentConvertingMethodInvoker.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -146,8 +146,9 @@ protected Method doFindMatchingMethod(Object[] arguments) { for (Method candidate : candidates) { if (candidate.getName().equals(targetMethod)) { // Check if the inspected method has the correct number of parameters. - Class[] paramTypes = candidate.getParameterTypes(); - if (paramTypes.length == argCount) { + int parameterCount = candidate.getParameterCount(); + if (parameterCount == argCount) { + Class[] paramTypes = candidate.getParameterTypes(); Object[] convertedArguments = new Object[argCount]; boolean match = true; for (int j = 0; j < argCount && match; j++) { diff --git a/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java b/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java index 55a0f60b317a..353b88fd3626 100644 --- a/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java +++ b/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -170,11 +170,12 @@ else if (genericType instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) genericType; Class[] generics = new Class[parameterizedType.getActualTypeArguments().length]; Type[] typeArguments = parameterizedType.getActualTypeArguments(); + ResolvableType contextType = ResolvableType.forClass(contextClass); for (int i = 0; i < typeArguments.length; i++) { Type typeArgument = typeArguments[i]; if (typeArgument instanceof TypeVariable) { ResolvableType resolvedTypeArgument = resolveVariable( - (TypeVariable) typeArgument, ResolvableType.forClass(contextClass)); + (TypeVariable) typeArgument, contextType); if (resolvedTypeArgument != ResolvableType.NONE) { generics[i] = resolvedTypeArgument.resolve(); } diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java index a4223601f686..034e571814fc 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -151,9 +151,10 @@ public MultiValueMap getAllAnnotationAttributes(String annotatio MultiValueMap allAttributes = new LinkedMultiValueMap<>(); List attributesList = this.attributesMap.get(annotationName); if (attributesList != null) { + String annotatedElement = "method '" + getMethodName() + '\''; for (AnnotationAttributes annotationAttributes : attributesList) { AnnotationAttributes convertedAttributes = AnnotationReadingVisitorUtils.convertClassValues( - "method '" + getMethodName() + "'", this.classLoader, annotationAttributes, classValuesAsString); + annotatedElement, this.classLoader, annotationAttributes, classValuesAsString); convertedAttributes.forEach(allAttributes::add); } } From c86e164b033d7a862539e05b33a510aec3ecc363 Mon Sep 17 00:00:00 2001 From: wilrosco Date: Mon, 27 Jan 2020 18:10:51 -0600 Subject: [PATCH 0366/2315] Add Informix to the list of supported database products for procedure calls Hi guys, We're facing an issue in our application when we try to call a procedure in Informix database, our app uses standard JDBC (spring-jdbc and com.ibm.informix.jdbc.4.50.3) without Hibernate to connect to the database Issue: When we trying to execute any procedure call in our Informix database there is no data returned. Diagnostic: It points to the Java class called CallMetaDataProviderFactory in spring-jdbc project. Taking a look of this class there is no explicit support for Informix procedure calls, so I added "Informix Dynamic Server" to the list of supported databases and now I can execute procedures call without issues. Basically I added the line "Informix Dynamic Server" to the list called "supportedDatabaseProductsForProcedures" of CallMetaDataProviderFactory class in my local environment and it worked as expected. I really appreciate any feedback/suggestion for this approach due we would like to continue using the framework normally in our development without losing updates using a workaround in our end. Many thanks in advance. --- .../jdbc/core/metadata/CallMetaDataProviderFactory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java index 5030fe33e4c6..e7eb23c10484 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java @@ -46,7 +46,8 @@ public final class CallMetaDataProviderFactory { "Microsoft SQL Server", "Oracle", "PostgreSQL", - "Sybase" + "Sybase", + "Informix Dynamic Server" ); /** List of supported database products for function calls. */ From d93403a257a56417f94c7693cb0888eecd7c493c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 28 Jan 2020 21:06:04 +0100 Subject: [PATCH 0367/2315] Alphabetical order for database names See gh-24443 --- .../core/metadata/CallMetaDataProviderFactory.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java index e7eb23c10484..ff93bfc9a859 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -42,18 +42,18 @@ public final class CallMetaDataProviderFactory { public static final List supportedDatabaseProductsForProcedures = Arrays.asList( "Apache Derby", "DB2", - "MySQL", + "Informix Dynamic Server", "Microsoft SQL Server", + "MySQL", "Oracle", "PostgreSQL", - "Sybase", - "Informix Dynamic Server" + "Sybase" ); /** List of supported database products for function calls. */ public static final List supportedDatabaseProductsForFunctions = Arrays.asList( - "MySQL", "Microsoft SQL Server", + "MySQL", "Oracle", "PostgreSQL" ); From 8cced42fb2cdbe1d0864ca6c576d81d4cb8dcb49 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 28 Jan 2020 21:06:48 +0100 Subject: [PATCH 0368/2315] Use local LoggerContext in Log4jLog when static field not initialized yet Closes gh-24440 --- .../main/java/org/apache/commons/logging/LogAdapter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java b/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java index d84b54e874e3..e6d6f42f0f36 100644 --- a/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java +++ b/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -157,7 +157,12 @@ private static class Log4jLog implements Log, Serializable { private final ExtendedLogger logger; public Log4jLog(String name) { - this.logger = loggerContext.getLogger(name); + LoggerContext context = loggerContext; + if (context == null) { + // Circular call in early-init scenario -> static field not initialized yet + context = LogManager.getContext(Log4jLog.class.getClassLoader(), false); + } + this.logger = context.getLogger(name); } @Override From b4a9758d9bb8b958efd12acb8cb89d78ce90684a Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 28 Jan 2020 21:56:35 +0100 Subject: [PATCH 0369/2315] Polishing --- .../src/main/java/org/apache/commons/logging/LogAdapter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java b/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java index e6d6f42f0f36..c918ee7c2df0 100644 --- a/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java +++ b/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java @@ -608,8 +608,8 @@ private void log(java.util.logging.Level level, Object message, Throwable except else { rec = new LocationResolvingLogRecord(level, String.valueOf(message)); rec.setLoggerName(this.name); - rec.setResourceBundleName(logger.getResourceBundleName()); - rec.setResourceBundle(logger.getResourceBundle()); + rec.setResourceBundleName(this.logger.getResourceBundleName()); + rec.setResourceBundle(this.logger.getResourceBundle()); rec.setThrown(exception); } logger.log(rec); From 688167a7df052b6e1b822b36a1e81e4cd440e24a Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 28 Jan 2020 22:06:06 +0100 Subject: [PATCH 0370/2315] Upgrade to Checkstyle 8.29 and Apache Johnzon 1.2.3 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 3233d8493450..498a71b996e2 100644 --- a/build.gradle +++ b/build.gradle @@ -84,7 +84,7 @@ configure(allprojects) { project -> exclude group: "xpp3", name: "xpp3_min" exclude group: "xmlpull", name: "xmlpull" } - dependency "org.apache.johnzon:johnzon-jsonb:1.2.2" + dependency "org.apache.johnzon:johnzon-jsonb:1.2.3" dependency("org.codehaus.jettison:jettison:1.3.8") { exclude group: "stax", name: "stax-api" } @@ -333,7 +333,7 @@ configure([rootProject] + javaProjects) { project -> } checkstyle { - toolVersion = "8.28" + toolVersion = "8.29" configDir = rootProject.file("src/checkstyle") } From cc4261c30b988f4c3ea51d86e51a0474b924afcd Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 30 Jan 2020 06:16:43 +0000 Subject: [PATCH 0371/2315] Only non-null input resets scheme specific part Closes gh-24444 --- .../web/util/UriComponentsBuilder.java | 19 +++++++++++++------ .../web/util/UriComponentsBuilderTests.java | 17 ++++++++++++++++- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java index 506f92b1a9a0..5403bdcbac31 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -551,7 +551,9 @@ public UriComponentsBuilder userInfo(@Nullable String userInfo) { @Override public UriComponentsBuilder host(@Nullable String host) { this.host = host; - resetSchemeSpecificPart(); + if (host != null) { + resetSchemeSpecificPart(); + } return this; } @@ -559,14 +561,18 @@ public UriComponentsBuilder host(@Nullable String host) { public UriComponentsBuilder port(int port) { Assert.isTrue(port >= -1, "Port must be >= -1"); this.port = String.valueOf(port); - resetSchemeSpecificPart(); + if (port > -1) { + resetSchemeSpecificPart(); + } return this; } @Override public UriComponentsBuilder port(@Nullable String port) { this.port = port; - resetSchemeSpecificPart(); + if (port != null) { + resetSchemeSpecificPart(); + } return this; } @@ -604,11 +610,11 @@ public UriComponentsBuilder query(@Nullable String query) { String value = matcher.group(3); queryParam(name, (value != null ? value : (StringUtils.hasLength(eq) ? "" : null))); } + resetSchemeSpecificPart(); } else { this.queryParams.clear(); } - resetSchemeSpecificPart(); return this; } @@ -617,8 +623,8 @@ public UriComponentsBuilder replaceQuery(@Nullable String query) { this.queryParams.clear(); if (query != null) { query(query); + resetSchemeSpecificPart(); } - resetSchemeSpecificPart(); return this; } @@ -651,6 +657,7 @@ public UriComponentsBuilder queryParam(String name, @Nullable Collection valu public UriComponentsBuilder queryParams(@Nullable MultiValueMap params) { if (params != null) { this.queryParams.addAll(params); + resetSchemeSpecificPart(); } return this; } diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java index 011a3d77a718..4d6166ebba2d 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -769,6 +769,21 @@ public void queryParamWithoutValueWithoutEquals() { assertThat(uriComponents.getQueryParams().get("bar").get(0)).isNull(); } + @Test // gh-24444 + public void opaqueUriDoesNotResetOnNullInput() throws URISyntaxException { + URI uri = new URI("urn:ietf:wg:oauth:2.0:oob"); + UriComponents result = UriComponentsBuilder.fromUri(uri) + .host(null) + .port(-1) + .port(null) + .queryParams(null) + .replaceQuery(null) + .query(null) + .build(); + + assertThat(result.toUri()).isEqualTo(uri); + } + @Test public void relativeUrls() { String baseUrl = "https://example.com"; From 547342b27d39efdb7ef6de068897b972e85c7b23 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 30 Jan 2020 10:06:58 +0000 Subject: [PATCH 0372/2315] Status code as Integer methods in ServerHttpResponse Closes gh-24400 --- .../reactive/server/HttpHandlerConnector.java | 4 +- .../reactive/AbstractServerHttpResponse.java | 25 ++++++++- .../reactive/ReactorServerHttpResponse.java | 17 ++++--- .../server/reactive/ServerHttpResponse.java | 51 ++++++++++++++++--- .../reactive/ServletServerHttpResponse.java | 18 ++++--- .../reactive/UndertowServerHttpResponse.java | 17 ++++--- .../server/DefaultServerResponseBuilder.java | 15 +----- .../ResponseEntityResultHandler.java | 14 ++--- 8 files changed, 108 insertions(+), 53 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/HttpHandlerConnector.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/HttpHandlerConnector.java index c5841c41ec2b..ee23babdc4f2 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/HttpHandlerConnector.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/HttpHandlerConnector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -135,7 +135,7 @@ private ServerHttpResponse prepareResponse(ServerHttpResponse response, ServerHt } private ClientHttpResponse adaptResponse(MockServerHttpResponse response, Flux body) { - Integer status = response.getStatusCodeValue(); + Integer status = response.getRawStatusCode(); MockClientHttpResponse clientResponse = new MockClientHttpResponse((status != null) ? status : 200); clientResponse.getHeaders().putAll(response.getHeaders()); clientResponse.getCookies().putAll(response.getCookies()); diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java index f4841a705250..b6c7f98037df 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java @@ -111,21 +111,44 @@ public HttpStatus getStatusCode() { return (this.statusCode != null ? HttpStatus.resolve(this.statusCode) : null); } + @Override + public boolean setRawStatusCode(@Nullable Integer statusCode) { + if (this.state.get() == State.COMMITTED) { + return false; + } + else { + this.statusCode = statusCode; + return true; + } + } + + @Override + @Nullable + public Integer getRawStatusCode() { + return this.statusCode; + } + /** * Set the HTTP status code of the response. * @param statusCode the HTTP status as an integer value * @since 5.0.1 + * @deprecated as of 5.2.4 in favor of {@link ServerHttpResponse#setRawStatusCode(Integer)}. */ + @Deprecated public void setStatusCodeValue(@Nullable Integer statusCode) { - this.statusCode = statusCode; + if (this.state.get() != State.COMMITTED) { + this.statusCode = statusCode; + } } /** * Return the HTTP status code of the response. * @return the HTTP status as an integer value * @since 5.0.1 + * @deprecated as of 5.2.4 in favor of {@link ServerHttpResponse#getRawStatusCode()}. */ @Nullable + @Deprecated public Integer getStatusCodeValue() { return this.statusCode; } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpResponse.java index 43842bdb28e0..64b0a1c3f1d7 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -61,16 +61,21 @@ public T getNativeResponse() { @Override public HttpStatus getStatusCode() { - HttpStatus httpStatus = super.getStatusCode(); - return (httpStatus != null ? httpStatus : HttpStatus.resolve(this.response.status().code())); + HttpStatus status = super.getStatusCode(); + return (status != null ? status : HttpStatus.resolve(this.response.status().code())); } + @Override + public Integer getRawStatusCode() { + Integer status = super.getRawStatusCode(); + return (status != null ? status : this.response.status().code()); + } @Override protected void applyStatusCode() { - Integer statusCode = getStatusCodeValue(); - if (statusCode != null) { - this.response.status(statusCode); + Integer status = super.getRawStatusCode(); + if (status != null) { + this.response.status(status); } } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponse.java index 2bbfba900f4e..eb665e362ed8 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -27,6 +27,7 @@ * * @author Arjen Poutsma * @author Sebastien Deleuze + * @author Rossen Stoyanchev * @since 5.0 */ public interface ServerHttpResponse extends ReactiveHttpOutputMessage { @@ -34,21 +35,55 @@ public interface ServerHttpResponse extends ReactiveHttpOutputMessage { /** * Set the HTTP status code of the response. * @param status the HTTP status as an {@link HttpStatus} enum value - * @return {@code false} if the status code has not been set because the - * HTTP response is already committed, {@code true} if successfully set. + * @return {@code false} if the status code change wasn't processed because + * the HTTP response is committed, {@code true} if successfully set. */ boolean setStatusCode(@Nullable HttpStatus status); /** - * Return the status code set via {@link #setStatusCode}, or if the status - * has not been set, return the default status code from the underlying - * server response. The return value may be {@code null} if the status code - * value is outside the {@link HttpStatus} enum range, or if the underlying - * server response does not have a default value. + * Return the status code that has been set, or otherwise fall back on the + * status of the response from the underlying server. The return value may + * be {@code null} if the status code value is outside the + * {@link HttpStatus} enum range, or if there is no default value from the + * underlying server. */ @Nullable HttpStatus getStatusCode(); + /** + * Set the HTTP status code to the given value (potentially non-standard and + * not resolvable through the {@link HttpStatus} enum) as an integer. + * @param value the status code value + * @return {@code false} if the status code change wasn't processed because + * the HTTP response is committed, {@code true} if successfully set. + * @since 5.2.4 + */ + default boolean setRawStatusCode(@Nullable Integer value) { + if (value == null) { + return setStatusCode(null); + } + else { + HttpStatus httpStatus = HttpStatus.resolve(value); + if (httpStatus == null) { + throw new IllegalStateException( + "Unresolvable HttpStatus for general ServerHttpResponse: " + value); + } + return setStatusCode(httpStatus); + } + } + + /** + * Return the status code that has been set, or otherwise fall back on the + * status of the response from the underlying server. The return value may + * be {@code null} if there is no default value from the underlying server. + * @since 5.2.4 + */ + @Nullable + default Integer getRawStatusCode() { + HttpStatus httpStatus = getStatusCode(); + return (httpStatus != null ? httpStatus.value() : null); + } + /** * Return a mutable map with the cookies to send to the server. */ diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpResponse.java index b82233977e2a..ee52193b8da4 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -100,15 +100,21 @@ public T getNativeResponse() { @Override public HttpStatus getStatusCode() { - HttpStatus httpStatus = super.getStatusCode(); - return (httpStatus != null ? httpStatus : HttpStatus.resolve(this.response.getStatus())); + HttpStatus status = super.getStatusCode(); + return (status != null ? status : HttpStatus.resolve(this.response.getStatus())); + } + + @Override + public Integer getRawStatusCode() { + Integer status = super.getRawStatusCode(); + return (status != null ? status : this.response.getStatus()); } @Override protected void applyStatusCode() { - Integer statusCode = getStatusCodeValue(); - if (statusCode != null) { - this.response.setStatus(statusCode); + Integer status = super.getRawStatusCode(); + if (status != null) { + this.response.setStatus(status); } } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java index d19f839cb2b8..f20b4e6167d0 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -82,16 +82,21 @@ public T getNativeResponse() { @Override public HttpStatus getStatusCode() { - HttpStatus httpStatus = super.getStatusCode(); - return (httpStatus != null ? httpStatus : HttpStatus.resolve(this.exchange.getStatusCode())); + HttpStatus status = super.getStatusCode(); + return (status != null ? status : HttpStatus.resolve(this.exchange.getStatusCode())); } + @Override + public Integer getRawStatusCode() { + Integer status = super.getRawStatusCode(); + return (status != null ? status : this.exchange.getStatusCode()); + } @Override protected void applyStatusCode() { - Integer statusCode = getStatusCodeValue(); - if (statusCode != null) { - this.exchange.setStatusCode(statusCode); + Integer status = super.getRawStatusCode(); + if (status != null) { + this.exchange.setStatusCode(status); } } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java index a87b37a5c97f..da71fbe565a1 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -45,7 +45,6 @@ import org.springframework.http.ReactiveHttpOutputMessage; import org.springframework.http.ResponseCookie; import org.springframework.http.codec.HttpMessageWriter; -import org.springframework.http.server.reactive.AbstractServerHttpResponse; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.util.Assert; @@ -354,17 +353,7 @@ public final Mono writeTo(ServerWebExchange exchange, Context context) { } private void writeStatusAndHeaders(ServerHttpResponse response) { - if (response instanceof AbstractServerHttpResponse) { - ((AbstractServerHttpResponse) response).setStatusCodeValue(this.statusCode); - } - else { - HttpStatus status = HttpStatus.resolve(this.statusCode); - if (status == null) { - throw new IllegalStateException( - "Unresolvable HttpStatus for general ServerHttpResponse: " + this.statusCode); - } - response.setStatusCode(status); - } + response.setRawStatusCode(this.statusCode); copy(this.headers, response.getHeaders()); copy(this.cookies, response.getCookies()); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandler.java index 2e642d706fe2..6c57bd125126 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -33,8 +33,6 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.http.codec.HttpMessageWriter; -import org.springframework.http.server.reactive.AbstractServerHttpResponse; -import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.web.reactive.HandlerResult; @@ -141,14 +139,8 @@ else if (returnValue instanceof HttpHeaders) { } if (httpEntity instanceof ResponseEntity) { - ResponseEntity responseEntity = (ResponseEntity) httpEntity; - ServerHttpResponse response = exchange.getResponse(); - if (response instanceof AbstractServerHttpResponse) { - ((AbstractServerHttpResponse) response).setStatusCodeValue(responseEntity.getStatusCodeValue()); - } - else { - response.setStatusCode(responseEntity.getStatusCode()); - } + exchange.getResponse().setRawStatusCode( + ((ResponseEntity) httpEntity).getStatusCodeValue()); } HttpHeaders entityHeaders = httpEntity.getHeaders(); From 15b651cdfe2a3090d7c2d99ea08d5409ea853d08 Mon Sep 17 00:00:00 2001 From: Christoph Dreis Date: Thu, 30 Jan 2020 14:17:22 +0100 Subject: [PATCH 0373/2315] Polish documentation format See gh-24460 --- src/docs/asciidoc/core/core-validation.adoc | 1 + src/docs/asciidoc/web/webflux.adoc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/docs/asciidoc/core/core-validation.adoc b/src/docs/asciidoc/core/core-validation.adoc index ee2c5245c620..ca2783632979 100644 --- a/src/docs/asciidoc/core/core-validation.adoc +++ b/src/docs/asciidoc/core/core-validation.adoc @@ -1971,6 +1971,7 @@ requires the Spring Validation API, as the following example shows: ==== Configuring Custom Constraints Each bean validation constraint consists of two parts: + * A `@Constraint` annotation that declares the constraint and its configurable properties. * An implementation of the `javax.validation.ConstraintValidator` interface that implements the constraint's behavior. diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index 7c279560fd41..2a001476bc08 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -3737,7 +3737,7 @@ use `FormatterRegistrar` implementations. By default, if <> is present on the classpath (for example, the Hibernate Validator), the `LocalValidatorFactoryBean` is registered as a global <> for use with `@Valid` and -`Validated` on `@Controller` method arguments. +`@Validated` on `@Controller` method arguments. In your Java configuration, you can customize the global `Validator` instance, as the following example shows: From f01de79fe20db0c73f1c48a280f7d4c83ebb427c Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Fri, 31 Jan 2020 17:40:29 +0900 Subject: [PATCH 0374/2315] Polish --- .../beans/factory/support/PropertiesBeanDefinitionReader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java index 02807b031157..0e7876f1ce97 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java @@ -423,7 +423,7 @@ protected void registerBeanDefinition(String beanName, Map map, String pre MutablePropertyValues pvs = new MutablePropertyValues(); String prefixWithSep = prefix + SEPARATOR; - int beginIndex = prefix.length() + SEPARATOR.length(); + int beginIndex = prefixWithSep.length(); for (Map.Entry entry : map.entrySet()) { String key = StringUtils.trimWhitespace((String) entry.getKey()); From daebbf1960c9a5ef4dfdb9565ca7d29c19a1c6d1 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 31 Jan 2020 14:34:50 +0100 Subject: [PATCH 0375/2315] Polishing --- .../core/env/SimpleCommandLineArgsParser.java | 4 ++-- .../env/JOptCommandLinePropertySourceTests.java | 14 +++++++------- .../SimpleCommandLinePropertySourceTests.java | 17 ++++++----------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java index e03f3cc79742..e2c57def9191 100644 --- a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java +++ b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2020 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. @@ -66,7 +66,7 @@ public CommandLineArgs parse(String... args) { String optionValue = null; if (optionText.contains("=")) { optionName = optionText.substring(0, optionText.indexOf('=')); - optionValue = optionText.substring(optionText.indexOf('=')+1, optionText.length()); + optionValue = optionText.substring(optionText.indexOf('=') + 1, optionText.length()); } else { optionName = optionText; diff --git a/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java index 252f11157e25..b2b4063557a8 100644 --- a/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -39,7 +39,7 @@ void withRequiredArg_andArgIsPresent() { OptionSet options = parser.parse("--foo=bar"); PropertySource ps = new JOptCommandLinePropertySource(options); - assertThat((String)ps.getProperty("foo")).isEqualTo("bar"); + assertThat(ps.getProperty("foo")).isEqualTo("bar"); } @Test @@ -50,7 +50,7 @@ void withOptionalArg_andArgIsMissing() { PropertySource ps = new JOptCommandLinePropertySource(options); assertThat(ps.containsProperty("foo")).isTrue(); - assertThat((String)ps.getProperty("foo")).isEqualTo(""); + assertThat(ps.getProperty("foo")).isEqualTo(""); } @Test @@ -63,7 +63,7 @@ void withNoArg() { PropertySource ps = new JOptCommandLinePropertySource(options); assertThat(ps.containsProperty("o1")).isTrue(); assertThat(ps.containsProperty("o2")).isFalse(); - assertThat((String)ps.getProperty("o1")).isEqualTo(""); + assertThat(ps.getProperty("o1")).isEqualTo(""); assertThat(ps.getProperty("o2")).isNull(); } @@ -138,8 +138,7 @@ void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() { assertThat(ps.containsProperty("o1")).isTrue(); assertThat(ps.containsProperty("o2")).isTrue(); - String nonOptionArgs = (String)ps.getProperty("nonOptionArgs"); - assertThat(nonOptionArgs).isEqualTo("noa1,noa2"); + assertThat(ps.getProperty("nonOptionArgs")).isEqualTo("noa1,noa2"); } @Test @@ -169,7 +168,8 @@ void withRequiredArg_ofTypeEnum() { assertThat(ps.getProperty("o1")).isEqualTo("VAL_1"); } - public static enum OptionEnum { + public enum OptionEnum { VAL_1; } + } diff --git a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java index 8d18f609a565..4d4ac70d157e 100644 --- a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -33,8 +33,7 @@ class SimpleCommandLinePropertySourceTests { @Test void withDefaultName() { PropertySource ps = new SimpleCommandLinePropertySource(); - assertThat(ps.getName()) - .isEqualTo(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME); + assertThat(ps.getName()).isEqualTo(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME); } @Test @@ -52,8 +51,7 @@ void withNoArgs() { @Test void withOptionArgsOnly() { - CommandLinePropertySource ps = - new SimpleCommandLinePropertySource("--o1=v1", "--o2"); + CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "--o2"); assertThat(ps.containsProperty("o1")).isTrue(); assertThat(ps.containsProperty("o2")).isTrue(); assertThat(ps.containsProperty("o3")).isFalse(); @@ -77,8 +75,7 @@ void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() { @Test void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() { - CommandLinePropertySource ps = - new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); + CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); assertThat(ps.containsProperty("nonOptionArgs")).isTrue(); assertThat(ps.containsProperty("o1")).isTrue(); @@ -90,8 +87,7 @@ void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() { @Test void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() { - CommandLinePropertySource ps = - new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); + CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); ps.setNonOptionArgsPropertyName("NOA"); assertThat(ps.containsProperty("nonOptionArgs")).isFalse(); @@ -104,8 +100,7 @@ void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() { @Test void covertNonOptionArgsToStringArrayAndList() { - CommandLinePropertySource ps = - new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); + CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); StandardEnvironment env = new StandardEnvironment(); env.getPropertySources().addFirst(ps); From cbb037bc681e85517aee31ce623478ce0a9b3189 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 31 Jan 2020 14:37:40 +0100 Subject: [PATCH 0376/2315] Suppress deprecation warning in spring-test --- .../test/web/servlet/setup/StandaloneMockMvcBuilderTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilderTests.java index 078504557481..7c31562e7c5e 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilderTests.java @@ -67,6 +67,7 @@ public void placeHoldersInRequestMapping() throws Exception { } @Test // SPR-13637 + @SuppressWarnings("deprecation") public void suffixPatternMatch() throws Exception { TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PersonController()); builder.setUseSuffixPatternMatch(false); From 8dfacbc210c4162b124a4f4a6d749df653c945ea Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 3 Feb 2020 12:01:40 +0100 Subject: [PATCH 0377/2315] Upgrade to Hibernate Validator 6.1.2 and OpenPDF 1.3.13 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 498a71b996e2..18a39f76fb9c 100644 --- a/build.gradle +++ b/build.gradle @@ -97,7 +97,7 @@ configure(allprojects) { project -> dependency "com.h2database:h2:1.4.200" dependency "com.github.ben-manes.caffeine:caffeine:2.8.1" - dependency "com.github.librepdf:openpdf:1.3.12" + dependency "com.github.librepdf:openpdf:1.3.13" dependency "com.rometools:rome:1.12.2" dependency "commons-io:commons-io:2.5" dependency "io.vavr:vavr:0.10.0" @@ -125,7 +125,7 @@ configure(allprojects) { project -> dependency "org.ehcache:jcache:1.0.1" dependency "org.ehcache:ehcache:3.4.0" dependency "org.hibernate:hibernate-core:5.4.10.Final" - dependency "org.hibernate:hibernate-validator:6.1.1.Final" + dependency "org.hibernate:hibernate-validator:6.1.2.Final" dependency "org.webjars:webjars-locator-core:0.43" dependency "org.webjars:underscorejs:1.8.3" From d77a28aac3c185f1fa8436f26576febc69d98ae9 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 3 Feb 2020 15:03:43 +0100 Subject: [PATCH 0378/2315] Support optional command line arguments with empty values Spring Framework provides two implementations of the CommandLinePropertySource API: SimpleCommandLinePropertySource and JOptCommandLinePropertySource. Prior to this commit, JOptCommandLinePropertySource supported empty values for optional arguments; whereas, SimpleCommandLinePropertySource did not. This commit modifies the implementation of SimpleCommandLinePropertySource to allow empty values for optional arguments. Closes gh-24464 --- .../core/env/SimpleCommandLineArgsParser.java | 31 +++++++----- .../env/SimpleCommandLinePropertySource.java | 32 ++++++++----- .../JOptCommandLinePropertySourceTests.java | 18 +++++-- ... => SimpleCommandLineArgsParserTests.java} | 48 +++++++++---------- .../SimpleCommandLinePropertySourceTests.java | 11 ++++- 5 files changed, 85 insertions(+), 55 deletions(-) rename spring-core/src/test/java/org/springframework/core/env/{SimpleCommandLineParserTests.java => SimpleCommandLineArgsParserTests.java} (63%) diff --git a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java index e2c57def9191..bcf8d071604c 100644 --- a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java +++ b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java @@ -21,15 +21,20 @@ * {@link CommandLineArgs} object. * *

    Working with option arguments

    - * Option arguments must adhere to the exact syntax: + *

    Option arguments must adhere to the exact syntax: + * *

    --optName[=optValue]
    - * That is, options must be prefixed with "{@code --}", and may or may not specify a value. - * If a value is specified, the name and value must be separated without spaces - * by an equals sign ("="). + * + *

    That is, options must be prefixed with "{@code --}" and may or may not + * specify a value. If a value is specified, the name and value must be separated + * without spaces by an equals sign ("="). The value may optionally be + * an empty string. * *

    Valid examples of option arguments

    *
      * --foo
    + * --foo=
    + * --foo=""
      * --foo=bar
      * --foo="bar then baz"
      * --foo=bar,baz,biz
    @@ -42,11 +47,12 @@ * --foo=bar --foo=baz --foo=biz * *

    Working with non-option arguments

    - * Any and all arguments specified at the command line without the "{@code --}" option - * prefix will be considered as "non-option arguments" and made available through the - * {@link CommandLineArgs#getNonOptionArgs()} method. + *

    Any and all arguments specified at the command line without the "{@code --}" + * option prefix will be considered as "non-option arguments" and made available + * through the {@link CommandLineArgs#getNonOptionArgs()} method. * * @author Chris Beams + * @author Sam Brannen * @since 3.1 */ class SimpleCommandLineArgsParser { @@ -61,17 +67,18 @@ public CommandLineArgs parse(String... args) { CommandLineArgs commandLineArgs = new CommandLineArgs(); for (String arg : args) { if (arg.startsWith("--")) { - String optionText = arg.substring(2, arg.length()); + String optionText = arg.substring(2); String optionName; String optionValue = null; - if (optionText.contains("=")) { - optionName = optionText.substring(0, optionText.indexOf('=')); - optionValue = optionText.substring(optionText.indexOf('=') + 1, optionText.length()); + int indexOfEqualsSign = optionText.indexOf('='); + if (indexOfEqualsSign > -1) { + optionName = optionText.substring(0, indexOfEqualsSign); + optionValue = optionText.substring(indexOfEqualsSign + 1); } else { optionName = optionText; } - if (optionName.isEmpty() || (optionValue != null && optionValue.isEmpty())) { + if (optionName.isEmpty()) { throw new IllegalArgumentException("Invalid argument syntax: " + arg); } commandLineArgs.addOptionArg(optionName, optionValue); diff --git a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java index 8bbc88b7ee5e..a4a25397ac9f 100644 --- a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -25,22 +25,28 @@ * {@link CommandLinePropertySource} implementation backed by a simple String array. * *

    Purpose

    - * This {@code CommandLinePropertySource} implementation aims to provide the simplest - * possible approach to parsing command line arguments. As with all {@code + *

    This {@code CommandLinePropertySource} implementation aims to provide the simplest + * possible approach to parsing command line arguments. As with all {@code * CommandLinePropertySource} implementations, command line arguments are broken into two * distinct groups: option arguments and non-option arguments, as - * described below (some sections copied from Javadoc for {@link SimpleCommandLineArgsParser}): + * described below (some sections copied from Javadoc for + * {@link SimpleCommandLineArgsParser}): * *

    Working with option arguments

    - * Option arguments must adhere to the exact syntax: + *

    Option arguments must adhere to the exact syntax: + * *

    --optName[=optValue]
    - * That is, options must be prefixed with "{@code --}", and may or may not specify a value. - * If a value is specified, the name and value must be separated without spaces - * by an equals sign ("="). + * + *

    That is, options must be prefixed with "{@code --}" and may or may not + * specify a value. If a value is specified, the name and value must be separated + * without spaces by an equals sign ("="). The value may optionally be + * an empty string. * *

    Valid examples of option arguments

    *
      * --foo
    + * --foo=
    + * --foo=""
      * --foo=bar
      * --foo="bar then baz"
      * --foo=bar,baz,biz
    @@ -53,11 +59,11 @@ * --foo=bar --foo=baz --foo=biz * *

    Working with non-option arguments

    - * Any and all arguments specified at the command line without the "{@code --}" option - * prefix will be considered as "non-option arguments" and made available through the - * {@link #getNonOptionArgs()} method. + *

    Any and all arguments specified at the command line without the "{@code --}" + * option prefix will be considered as "non-option arguments" and made available + * through the {@link CommandLineArgs#getNonOptionArgs()} method. * - *

    Typical usage

    + *

    Typical usage

    *
      * public static void main(String[] args) {
      *     PropertySource ps = new SimpleCommandLinePropertySource(args);
    @@ -71,7 +77,7 @@
      * 

    When more fully-featured command line parsing is necessary, consider using * the provided {@link JOptCommandLinePropertySource}, or implement your own * {@code CommandLinePropertySource} against the command line parsing library of your - * choice! + * choice. * * @author Chris Beams * @since 3.1 diff --git a/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java index b2b4063557a8..0ebb4e99e8ba 100644 --- a/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java @@ -28,6 +28,7 @@ * Unit tests for {@link JOptCommandLinePropertySource}. * * @author Chris Beams + * @author Sam Brannen * @since 3.1 */ class JOptCommandLinePropertySourceTests { @@ -53,6 +54,17 @@ void withOptionalArg_andArgIsMissing() { assertThat(ps.getProperty("foo")).isEqualTo(""); } + @Test // gh-24464 + void withOptionalArg_andArgIsEmpty() { + OptionParser parser = new OptionParser(); + parser.accepts("foo").withOptionalArg(); + OptionSet options = parser.parse("--foo="); + + PropertySource ps = new JOptCommandLinePropertySource(options); + assertThat(ps.containsProperty("foo")).isTrue(); + assertThat(ps.getProperty("foo")).isEqualTo(""); + } + @Test void withNoArg() { OptionParser parser = new OptionParser(); @@ -74,7 +86,7 @@ void withRequiredArg_andMultipleArgsPresent_usingDelimiter() { OptionSet options = parser.parse("--foo=bar,baz,biz"); CommandLinePropertySource ps = new JOptCommandLinePropertySource(options); - assertThat(ps.getOptionValues("foo")).isEqualTo(Arrays.asList("bar","baz","biz")); + assertThat(ps.getOptionValues("foo")).containsExactly("bar", "baz", "biz"); assertThat(ps.getProperty("foo")).isEqualTo("bar,baz,biz"); } @@ -85,7 +97,7 @@ void withRequiredArg_andMultipleArgsPresent_usingRepeatedOption() { OptionSet options = parser.parse("--foo=bar", "--foo=baz", "--foo=biz"); CommandLinePropertySource ps = new JOptCommandLinePropertySource(options); - assertThat(ps.getOptionValues("foo")).isEqualTo(Arrays.asList("bar","baz","biz")); + assertThat(ps.getOptionValues("foo")).containsExactly("bar", "baz", "biz"); assertThat(ps.getProperty("foo")).isEqualTo("bar,baz,biz"); } @@ -123,7 +135,7 @@ void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() { assertThat(ps.containsProperty("nonOptionArgs")).isFalse(); assertThat(ps.getProperty("nonOptionArgs")).isNull(); - assertThat(ps.getPropertyNames().length).isEqualTo(2); + assertThat(ps.getPropertyNames()).hasSize(2); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineArgsParserTests.java similarity index 63% rename from spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java rename to spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineArgsParserTests.java index 471af3e7598f..4e3f186f87b0 100644 --- a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineArgsParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -25,17 +25,24 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -class SimpleCommandLineParserTests { +/** + * Unit tests for {@link SimpleCommandLineArgsParser}. + * + * @author Chris Beams + * @author Sam Brannen + */ +class SimpleCommandLineArgsParserTests { + + private final SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); + @Test void withNoOptions() { - SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); assertThat(parser.parse().getOptionValues("foo")).isNull(); } @Test void withSingleOptionAndNoValue() { - SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); CommandLineArgs args = parser.parse("--o1"); assertThat(args.containsOption("o1")).isTrue(); assertThat(args.getOptionValues("o1")).isEqualTo(Collections.EMPTY_LIST); @@ -43,63 +50,52 @@ void withSingleOptionAndNoValue() { @Test void withSingleOptionAndValue() { - SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); CommandLineArgs args = parser.parse("--o1=v1"); assertThat(args.containsOption("o1")).isTrue(); - assertThat(args.getOptionValues("o1").get(0)).isEqualTo("v1"); + assertThat(args.getOptionValues("o1")).containsExactly("v1"); } @Test void withMixOfOptionsHavingValueAndOptionsHavingNoValue() { - SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); CommandLineArgs args = parser.parse("--o1=v1", "--o2"); assertThat(args.containsOption("o1")).isTrue(); assertThat(args.containsOption("o2")).isTrue(); assertThat(args.containsOption("o3")).isFalse(); - assertThat(args.getOptionValues("o1").get(0)).isEqualTo("v1"); + assertThat(args.getOptionValues("o1")).containsExactly("v1"); assertThat(args.getOptionValues("o2")).isEqualTo(Collections.EMPTY_LIST); assertThat(args.getOptionValues("o3")).isNull(); } @Test void withEmptyOptionText() { - SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); - assertThatIllegalArgumentException().isThrownBy(() -> - parser.parse("--")); + assertThatIllegalArgumentException().isThrownBy(() -> parser.parse("--")); } @Test void withEmptyOptionName() { - SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); - assertThatIllegalArgumentException().isThrownBy(() -> - parser.parse("--=v1")); + assertThatIllegalArgumentException().isThrownBy(() -> parser.parse("--=v1")); } @Test void withEmptyOptionValue() { - SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); - assertThatIllegalArgumentException().isThrownBy(() -> - parser.parse("--o1=")); + CommandLineArgs args = parser.parse("--o1="); + assertThat(args.containsOption("o1")).isTrue(); + assertThat(args.getOptionValues("o1")).containsExactly(""); } @Test void withEmptyOptionNameAndEmptyOptionValue() { - SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); - assertThatIllegalArgumentException().isThrownBy(() -> - parser.parse("--=")); + assertThatIllegalArgumentException().isThrownBy(() -> parser.parse("--=")); } @Test void withNonOptionArguments() { - SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); CommandLineArgs args = parser.parse("--o1=v1", "noa1", "--o2=v2", "noa2"); - assertThat(args.getOptionValues("o1").get(0)).isEqualTo("v1"); - assertThat(args.getOptionValues("o2").get(0)).isEqualTo("v2"); + assertThat(args.getOptionValues("o1")).containsExactly("v1"); + assertThat(args.getOptionValues("o2")).containsExactly("v2"); List nonOptions = args.getNonOptionArgs(); - assertThat(nonOptions.get(0)).isEqualTo("noa1"); - assertThat(nonOptions.get(1)).isEqualTo("noa2"); - assertThat(nonOptions.size()).isEqualTo(2); + assertThat(nonOptions).containsExactly("noa1", "noa2"); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java index 4d4ac70d157e..9b67142de752 100644 --- a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java @@ -26,6 +26,7 @@ * Unit tests for {@link SimpleCommandLinePropertySource}. * * @author Chris Beams + * @author Sam Brannen * @since 3.1 */ class SimpleCommandLinePropertySourceTests { @@ -60,6 +61,14 @@ void withOptionArgsOnly() { assertThat(ps.getProperty("o3")).isNull(); } + @Test // gh-24464 + void withOptionalArg_andArgIsEmpty() { + EnumerablePropertySource ps = new SimpleCommandLinePropertySource("--foo="); + + assertThat(ps.containsProperty("foo")).isTrue(); + assertThat(ps.getProperty("foo")).isEqualTo(""); + } + @Test void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() { EnumerablePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "--o2"); @@ -70,7 +79,7 @@ void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() { assertThat(ps.containsProperty("nonOptionArgs")).isFalse(); assertThat(ps.getProperty("nonOptionArgs")).isNull(); - assertThat(ps.getPropertyNames().length).isEqualTo(2); + assertThat(ps.getPropertyNames()).hasSize(2); } @Test From 14a32d13d0e4cc58c0a2446236fa343ce9f0a130 Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Mon, 3 Feb 2020 23:23:32 +0900 Subject: [PATCH 0379/2315] Fix typo in StringUtils class Closes gh-24471 --- .../src/main/java/org/springframework/util/StringUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/util/StringUtils.java b/spring-core/src/main/java/org/springframework/util/StringUtils.java index 24af9f14d571..70cbf256a1d2 100644 --- a/spring-core/src/main/java/org/springframework/util/StringUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StringUtils.java @@ -79,7 +79,7 @@ public abstract class StringUtils { /** * Check whether the given object (possibly a {@code String}) is empty. - * This is effectly a shortcut for {@code !hasLength(String)}. + * This is effectively a shortcut for {@code !hasLength(String)}. *

    This method accepts any Object as an argument, comparing it to * {@code null} and the empty String. As a consequence, this method * will never return {@code true} for a non-null non-String object. From 1b39f138ebd580e16c58298104bd3bac7030918a Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Mon, 3 Feb 2020 23:34:47 +0900 Subject: [PATCH 0380/2315] Test ObjectUtils.containsElement() This commit introduces a unit test for the containsElement() method in ObjectUtils. Closes gh-24428 --- .../springframework/util/ObjectUtilsTests.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java index b07a5558c222..7e239d1cc9d3 100644 --- a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -37,6 +37,7 @@ * @author Juergen Hoeller * @author Rick Evans * @author Sam Brannen + * @author Hyunjin Choi */ class ObjectUtilsTests { @@ -806,6 +807,20 @@ void caseInsensitiveValueOf() { .withMessage("Constant [bogus] does not exist in enum type org.springframework.util.ObjectUtilsTests$Tropes"); } + @Test + void containsElement() { + String keyObject = "key"; + String[] array = {"foo", "bar", "Bar", keyObject}; + + String fakeObject = "fake"; + + assertThat(ObjectUtils.containsElement(null, keyObject)).isFalse(); + + assertThat(ObjectUtils.containsElement(array, keyObject)).isTrue(); + + assertThat(ObjectUtils.containsElement(array, fakeObject)).isFalse(); + } + private void assertEqualHashCodes(int expected, Object array) { int actual = ObjectUtils.nullSafeHashCode(array); assertThat(actual).isEqualTo(expected); From cf9a052e3a8637d72f281ac0242d34faaae0bd1c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 3 Feb 2020 15:39:00 +0100 Subject: [PATCH 0381/2315] Polish contribution See gh-24428 --- .../util/ObjectUtilsTests.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java index 7e239d1cc9d3..aa6cf358117f 100644 --- a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java @@ -797,6 +797,20 @@ void containsConstant() { assertThat(ObjectUtils.containsConstant(Tropes.values(), "foo", true)).isFalse(); } + @Test + void containsElement() { + Object[] array = {"foo", "bar", 42, new String[] {"baz", "quux"}}; + + assertThat(ObjectUtils.containsElement(null, "foo")).isFalse(); + assertThat(ObjectUtils.containsElement(array, null)).isFalse(); + assertThat(ObjectUtils.containsElement(array, "bogus")).isFalse(); + + assertThat(ObjectUtils.containsElement(array, "foo")).isTrue(); + assertThat(ObjectUtils.containsElement(array, "bar")).isTrue(); + assertThat(ObjectUtils.containsElement(array, 42)).isTrue(); + assertThat(ObjectUtils.containsElement(array, new String[] {"baz", "quux"})).isTrue(); + } + @Test void caseInsensitiveValueOf() { assertThat(ObjectUtils.caseInsensitiveValueOf(Tropes.values(), "foo")).isEqualTo(Tropes.FOO); @@ -807,20 +821,6 @@ void caseInsensitiveValueOf() { .withMessage("Constant [bogus] does not exist in enum type org.springframework.util.ObjectUtilsTests$Tropes"); } - @Test - void containsElement() { - String keyObject = "key"; - String[] array = {"foo", "bar", "Bar", keyObject}; - - String fakeObject = "fake"; - - assertThat(ObjectUtils.containsElement(null, keyObject)).isFalse(); - - assertThat(ObjectUtils.containsElement(array, keyObject)).isTrue(); - - assertThat(ObjectUtils.containsElement(array, fakeObject)).isFalse(); - } - private void assertEqualHashCodes(int expected, Object array) { int actual = ObjectUtils.nullSafeHashCode(array); assertThat(actual).isEqualTo(expected); From 273812f9c5122014260a854d81c27fb2e0a017ac Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Mon, 3 Feb 2020 21:30:25 +0900 Subject: [PATCH 0382/2315] Remove unnecessary escapes in regular expressions See gh-24470 --- .../interceptor/CustomizableTraceInterceptor.java | 2 +- .../org/springframework/util/AntPathMatcher.java | 6 +++--- .../core/io/ClassPathResourceTests.java | 2 +- .../test/context/util/TestContextResourceUtils.java | 2 +- .../org/springframework/web/util/UriComponents.java | 2 +- .../web/util/UriComponentsBuilder.java | 4 ++-- .../web/util/pattern/RegexPathElement.java | 2 +- .../web/reactive/result/view/RedirectView.java | 2 +- .../handler/AbstractHttpSendingTransportHandler.java | 2 +- .../MessageBrokerBeanDefinitionParserTests.java | 12 ++++++------ ...SocketMessageBrokerConfigurationSupportTests.java | 12 ++++++------ 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java index 48fc03aee10b..df06c3a77f0a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java @@ -147,7 +147,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { /** * The {@code Pattern} used to match placeholders. */ - private static final Pattern PATTERN = Pattern.compile("\\$\\[\\p{Alpha}+\\]"); + private static final Pattern PATTERN = Pattern.compile("\\$\\[\\p{Alpha}+]"); /** * The {@code Set} of allowed placeholders. diff --git a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java index e8f8372e0306..f2ebf871cf70 100644 --- a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java +++ b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -77,7 +77,7 @@ public class AntPathMatcher implements PathMatcher { private static final int CACHE_TURNOFF_THRESHOLD = 65536; - private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{[^/]+?\\}"); + private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{[^/]+?}"); private static final char[] WILDCARD_CHARS = { '*', '?', '{' }; @@ -641,7 +641,7 @@ public Comparator getPatternComparator(String path) { */ protected static class AntPathStringMatcher { - private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{((?:\\{[^/]+?\\}|[^/{}]|\\\\[{}])+?)\\}"); + private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{((?:\\{[^/]+?}|[^/{}]|\\\\[{}])+?)}"); private static final String DEFAULT_VARIABLE_PATTERN = "(.*)"; diff --git a/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java index 630a551e6c91..126c56b535e9 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java @@ -43,7 +43,7 @@ class ClassPathResourceTests { */ private static final String FQ_RESOURCE_PATH_WITH_LEADING_SLASH = '/' + FQ_RESOURCE_PATH; - private static final Pattern DESCRIPTION_PATTERN = Pattern.compile("^class path resource \\[(.+?)\\]$"); + private static final Pattern DESCRIPTION_PATTERN = Pattern.compile("^class path resource \\[(.+?)]$"); @Test diff --git a/spring-test/src/main/java/org/springframework/test/context/util/TestContextResourceUtils.java b/spring-test/src/main/java/org/springframework/test/context/util/TestContextResourceUtils.java index 645594d2b731..aeda69be0207 100644 --- a/spring-test/src/main/java/org/springframework/test/context/util/TestContextResourceUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/util/TestContextResourceUtils.java @@ -47,7 +47,7 @@ public abstract class TestContextResourceUtils { private static final String SLASH = "/"; - private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile(".*\\$\\{[^\\}]+\\}.*"); + private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile(".*\\$\\{[^}]+}.*"); /** diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponents.java b/spring-web/src/main/java/org/springframework/web/util/UriComponents.java index c29b09f584ea..e8506e319f1c 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponents.java @@ -48,7 +48,7 @@ public abstract class UriComponents implements Serializable { /** Captures URI template variable names. */ - private static final Pattern NAMES_PATTERN = Pattern.compile("\\{([^/]+?)\\}"); + private static final Pattern NAMES_PATTERN = Pattern.compile("\\{([^/]+?)}"); @Nullable diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java index 5403bdcbac31..0a862167d919 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java @@ -76,11 +76,11 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable { private static final String HOST_IPV4_PATTERN = "[^\\[/?#:]*"; - private static final String HOST_IPV6_PATTERN = "\\[[\\p{XDigit}\\:\\.]*[%\\p{Alnum}]*\\]"; + private static final String HOST_IPV6_PATTERN = "\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]"; private static final String HOST_PATTERN = "(" + HOST_IPV6_PATTERN + "|" + HOST_IPV4_PATTERN + ")"; - private static final String PORT_PATTERN = "(\\d*(?:\\{[^/]+?\\})?)"; + private static final String PORT_PATTERN = "(\\d*(?:\\{[^/]+?})?)"; private static final String PATH_PATTERN = "([^?#]*)"; diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/RegexPathElement.java b/spring-web/src/main/java/org/springframework/web/util/pattern/RegexPathElement.java index fbd6b7f4df58..496989d2992c 100644 --- a/spring-web/src/main/java/org/springframework/web/util/pattern/RegexPathElement.java +++ b/spring-web/src/main/java/org/springframework/web/util/pattern/RegexPathElement.java @@ -35,7 +35,7 @@ */ class RegexPathElement extends PathElement { - private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{((?:\\{[^/]+?\\}|[^/{}]|\\\\[{}])+?)\\}"); + private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{((?:\\{[^/]+?}|[^/{}]|\\\\[{}])+?)}"); private static final String DEFAULT_VARIABLE_PATTERN = "(.*)"; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java index 4b3ae4f0b5dc..f16994f9660c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java @@ -53,7 +53,7 @@ */ public class RedirectView extends AbstractUrlBasedView { - private static final Pattern URI_TEMPLATE_VARIABLE_PATTERN = Pattern.compile("\\{([^/]+?)\\}"); + private static final Pattern URI_TEMPLATE_VARIABLE_PATTERN = Pattern.compile("\\{([^/]+?)}"); private HttpStatus statusCode = HttpStatus.SEE_OTHER; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpSendingTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpSendingTransportHandler.java index 0aa17c5552a7..2960f20dc4bd 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpSendingTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpSendingTransportHandler.java @@ -48,7 +48,7 @@ public abstract class AbstractHttpSendingTransportHandler extends AbstractTransp /** * Pattern for validating callback parameter values. */ - private static final Pattern CALLBACK_PARAM_PATTERN = Pattern.compile("[0-9A-Za-z_\\.]*"); + private static final Pattern CALLBACK_PARAM_PATTERN = Pattern.compile("[0-9A-Za-z_.]*"); @Override diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java index 5cab43c1f5b0..9e6fa7bf4ef7 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java @@ -303,16 +303,16 @@ public void stompBrokerRelay() { WebSocketMessageBrokerStats stats = this.appContext.getBean(name, WebSocketMessageBrokerStats.class); String actual = stats.toString(); String expected = "WebSocketSession\\[0 current WS\\(0\\)-HttpStream\\(0\\)-HttpPoll\\(0\\), " + - "0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)\\], " + - "stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " + + "0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)], " + + "stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)], " + "stompBrokerRelay\\[0 sessions, relayhost:1234 \\(not available\\), " + - "processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " + + "processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)], " + "inboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " + - "completed tasks = \\d\\], " + + "completed tasks = \\d], " + "outboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " + - "completed tasks = \\d\\], " + + "completed tasks = \\d], " + "sockJsScheduler\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " + - "completed tasks = \\d\\]"; + "completed tasks = \\d]"; assertThat(actual.matches(expected)).as("\nExpected: " + expected.replace("\\", "") + "\n Actual: " + actual).isTrue(); } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java index 19e81bc360e5..fb791b670825 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java @@ -168,12 +168,12 @@ public void webSocketMessageBrokerStats() { WebSocketMessageBrokerStats stats = config.getBean(name, WebSocketMessageBrokerStats.class); String actual = stats.toString(); String expected = "WebSocketSession\\[0 current WS\\(0\\)-HttpStream\\(0\\)-HttpPoll\\(0\\), " + - "0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)\\], " + - "stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " + - "stompBrokerRelay\\[null\\], " + - "inboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\], " + - "outboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\], " + - "sockJsScheduler\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\]"; + "0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)], " + + "stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)], " + + "stompBrokerRelay\\[null], " + + "inboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d], " + + "outboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d], " + + "sockJsScheduler\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d]"; assertThat(actual.matches(expected)).as("\nExpected: " + expected.replace("\\", "") + "\n Actual: " + actual).isTrue(); } From f5df422de925d7a96feafe2675ecfbdef2d5d856 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 3 Feb 2020 20:32:36 +0000 Subject: [PATCH 0383/2315] Polishing contribution See gh-24470 --- .../aop/interceptor/CustomizableTraceInterceptor.java | 2 +- .../org/springframework/core/io/ClassPathResourceTests.java | 2 +- .../main/java/org/springframework/web/util/UriComponents.java | 2 +- .../org/springframework/web/util/pattern/RegexPathElement.java | 2 +- .../springframework/web/reactive/result/view/RedirectView.java | 2 +- .../transport/handler/AbstractHttpSendingTransportHandler.java | 2 +- .../socket/config/MessageBrokerBeanDefinitionParserTests.java | 2 +- .../WebSocketMessageBrokerConfigurationSupportTests.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java index df06c3a77f0a..e6008ee001ea 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. diff --git a/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java index 126c56b535e9..9720f081d8d0 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponents.java b/spring-web/src/main/java/org/springframework/web/util/UriComponents.java index e8506e319f1c..4b1e7686013c 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponents.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/RegexPathElement.java b/spring-web/src/main/java/org/springframework/web/util/pattern/RegexPathElement.java index 496989d2992c..ae222c0b43b1 100644 --- a/spring-web/src/main/java/org/springframework/web/util/pattern/RegexPathElement.java +++ b/spring-web/src/main/java/org/springframework/web/util/pattern/RegexPathElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java index f16994f9660c..9c614638983c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpSendingTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpSendingTransportHandler.java index 2960f20dc4bd..ef566c7f8db1 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpSendingTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpSendingTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java index 9e6fa7bf4ef7..af5df574ae30 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java index fb791b670825..63fed01115b5 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. From bac5cd866e3ad685b84be0bcce2bdef573077242 Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Fri, 17 Jan 2020 21:23:45 +0900 Subject: [PATCH 0384/2315] Simplify getSessionAttributesHandler() method --- .../method/annotation/RequestMappingHandlerAdapter.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java index 7b0f5038ee02..ead2f88c8a2d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -825,11 +825,7 @@ private SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handl SessionAttributesHandler sessionAttrHandler = this.sessionAttributesHandlerCache.get(handlerType); if (sessionAttrHandler == null) { synchronized (this.sessionAttributesHandlerCache) { - sessionAttrHandler = this.sessionAttributesHandlerCache.get(handlerType); - if (sessionAttrHandler == null) { - sessionAttrHandler = new SessionAttributesHandler(handlerType, this.sessionAttributeStore); - this.sessionAttributesHandlerCache.put(handlerType, sessionAttrHandler); - } + sessionAttrHandler = this.sessionAttributesHandlerCache.computeIfAbsent(handlerType, type -> new SessionAttributesHandler(type, this.sessionAttributeStore)); } } return sessionAttrHandler; From e7d40f930f8e85d67b3d235ca26c7f2f076d6a58 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 3 Feb 2020 20:59:30 +0000 Subject: [PATCH 0385/2315] Remove synchronized block As per the Javadoc of ConcurrentHashMap its computeIfAbsent implementation is atomic and hence already synchronized internally, so we can remove the surrounding synchronization block. See gh-24470 --- .../annotation/RequestMappingHandlerAdapter.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java index ead2f88c8a2d..66049d310e0d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java @@ -821,14 +821,9 @@ protected long getLastModifiedInternal(HttpServletRequest request, HandlerMethod * (never {@code null}). */ private SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handlerMethod) { - Class handlerType = handlerMethod.getBeanType(); - SessionAttributesHandler sessionAttrHandler = this.sessionAttributesHandlerCache.get(handlerType); - if (sessionAttrHandler == null) { - synchronized (this.sessionAttributesHandlerCache) { - sessionAttrHandler = this.sessionAttributesHandlerCache.computeIfAbsent(handlerType, type -> new SessionAttributesHandler(type, this.sessionAttributeStore)); - } - } - return sessionAttrHandler; + return this.sessionAttributesHandlerCache.computeIfAbsent( + handlerMethod.getBeanType(), + type -> new SessionAttributesHandler(type, this.sessionAttributeStore)); } /** From a36168c972c889cce5ee6df32343f6622a400cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A6=D1=8B=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 4 Feb 2020 12:18:48 +0200 Subject: [PATCH 0386/2315] Produce less String-related garbage when generating bean names Closes gh-24476 --- .../beans/factory/support/AbstractBeanFactory.java | 5 +++-- .../beans/factory/support/BeanDefinitionReaderUtils.java | 5 +++-- .../beans/factory/support/BeanDefinitionValueResolver.java | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index d5e0f96096f6..3457d2bfe25b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -725,8 +725,9 @@ public String[] getAliases(String name) { aliases.add(fullBeanName); } String[] retrievedAliases = super.getAliases(beanName); + String prefix = factoryPrefix ? FACTORY_BEAN_PREFIX : ""; for (String retrievedAlias : retrievedAliases) { - String alias = (factoryPrefix ? FACTORY_BEAN_PREFIX : "") + retrievedAlias; + String alias = prefix + retrievedAlias; if (!alias.equals(name)) { aliases.add(alias); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java index f96c96fbdc3b..62c422c1a6b1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -144,9 +144,10 @@ public static String uniqueBeanName(String beanName, BeanDefinitionRegistry regi int counter = -1; // Increase counter until the id is unique. + String prefix = beanName + GENERATED_BEAN_NAME_SEPARATOR; while (counter == -1 || registry.containsBeanDefinition(id)) { counter++; - id = beanName + GENERATED_BEAN_NAME_SEPARATOR + counter; + id = prefix + counter; } return id; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java index abb5040f8992..124f1fa84f8c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -400,9 +400,10 @@ private Object resolveInnerBean(Object argName, String innerBeanName, BeanDefini private String adaptInnerBeanName(String innerBeanName) { String actualInnerBeanName = innerBeanName; int counter = 0; + String prefix = innerBeanName + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR; while (this.beanFactory.isBeanNameInUse(actualInnerBeanName)) { counter++; - actualInnerBeanName = innerBeanName + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + counter; + actualInnerBeanName = prefix + counter; } return actualInnerBeanName; } From 550f13e8ed678447a61872b4f9ff96d918003102 Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Tue, 4 Feb 2020 20:59:57 +0900 Subject: [PATCH 0387/2315] Simplify GenericConversionService.getMatchableConverters() Closes gh-24403 --- .../core/convert/support/GenericConversionService.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java index 2816117144dd..e8263d9526c2 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -519,12 +519,7 @@ public void add(GenericConverter converter) { } private ConvertersForPair getMatchableConverters(ConvertiblePair convertiblePair) { - ConvertersForPair convertersForPair = this.converters.get(convertiblePair); - if (convertersForPair == null) { - convertersForPair = new ConvertersForPair(); - this.converters.put(convertiblePair, convertersForPair); - } - return convertersForPair; + return this.converters.computeIfAbsent(convertiblePair, k -> new ConvertersForPair()); } public void remove(Class sourceType, Class targetType) { From d624dc084fb14e48102d8a3ca1f44ce9e7718287 Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Tue, 4 Feb 2020 21:36:24 +0900 Subject: [PATCH 0388/2315] Add close() method in FileCopyUtils to reduce duplication Closes gh-24393 --- .../springframework/util/FileCopyUtils.java | 54 ++++++++----------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java b/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java index d36e698d44c2..981243b5de0b 100644 --- a/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java +++ b/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -18,6 +18,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.Closeable; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -37,6 +38,7 @@ *

    Mainly for use within the framework, but also useful for application code. * * @author Juergen Hoeller + * @author Hyunjin Choi * @since 06.10.2003 * @see StreamUtils * @see FileSystemUtils @@ -110,16 +112,8 @@ public static int copy(InputStream in, OutputStream out) throws IOException { return StreamUtils.copy(in, out); } finally { - try { - in.close(); - } - catch (IOException ex) { - } - try { - out.close(); - } - catch (IOException ex) { - } + close(in); + close(out); } } @@ -138,11 +132,7 @@ public static void copy(byte[] in, OutputStream out) throws IOException { out.write(in); } finally { - try { - out.close(); - } - catch (IOException ex) { - } + close(out); } } @@ -192,16 +182,8 @@ public static int copy(Reader in, Writer out) throws IOException { return byteCount; } finally { - try { - in.close(); - } - catch (IOException ex) { - } - try { - out.close(); - } - catch (IOException ex) { - } + close(in); + close(out); } } @@ -220,11 +202,7 @@ public static void copy(String in, Writer out) throws IOException { out.write(in); } finally { - try { - out.close(); - } - catch (IOException ex) { - } + close(out); } } @@ -245,4 +223,18 @@ public static String copyToString(@Nullable Reader in) throws IOException { return out.toString(); } + /** + * Close the {@link Closeable} as a null-safety. + * + * @param closeable to close, may be null. + */ + private static void close(@Nullable Closeable closeable) { + if (closeable == null) return; + try { + closeable.close(); + } catch (IOException e) { + // do nothing + } + } + } From 72685b1d819d0fda74ebf17a489080059051baed Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 4 Feb 2020 13:41:31 +0100 Subject: [PATCH 0389/2315] Polish contribution See gh-24393 --- .../org/springframework/util/FileCopyUtils.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java b/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java index 981243b5de0b..3e78995a58e3 100644 --- a/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java +++ b/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java @@ -224,16 +224,15 @@ public static String copyToString(@Nullable Reader in) throws IOException { } /** - * Close the {@link Closeable} as a null-safety. - * - * @param closeable to close, may be null. + * Attempt to close the supplied {@link Closeable}, silently swallowing any + * exceptions. + * @param closeable the {@code Closeable} to close */ - private static void close(@Nullable Closeable closeable) { - if (closeable == null) return; + private static void close(Closeable closeable) { try { closeable.close(); - } catch (IOException e) { - // do nothing + } catch (IOException ex) { + // ignore } } From 2b6117c0c2e6ec841116b5a21f4b98bc8a08ad47 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 4 Feb 2020 13:45:02 +0100 Subject: [PATCH 0390/2315] Fix Checkstyle violation See gh-24393 --- .../src/main/java/org/springframework/util/FileCopyUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java b/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java index 3e78995a58e3..620d27daa757 100644 --- a/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java +++ b/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java @@ -231,7 +231,8 @@ public static String copyToString(@Nullable Reader in) throws IOException { private static void close(Closeable closeable) { try { closeable.close(); - } catch (IOException ex) { + } + catch (IOException ex) { // ignore } } From 5aa37ea07b31a6408e244f99d9440fba202f76ff Mon Sep 17 00:00:00 2001 From: Qimiao Chen Date: Tue, 4 Feb 2020 21:10:59 +0800 Subject: [PATCH 0391/2315] Let BFAwareGeneratorStrategy extend ClassLoaderAwareGeneratorStrategy This commit updates BeanFactoryAwareGeneratorStrategy to extend ClassLoaderAwareGeneratorStrategy in order to avoid duplication of the common generate() implementation. Closes gh-24396 --- .../ConfigurationClassEnhancer.java | 40 ++----------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java index a27f1d436ced..17079522c7f6 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java @@ -35,8 +35,8 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.support.SimpleInstantiationStrategy; import org.springframework.cglib.core.ClassGenerator; +import org.springframework.cglib.core.ClassLoaderAwareGeneratorStrategy; import org.springframework.cglib.core.Constants; -import org.springframework.cglib.core.DefaultGeneratorStrategy; import org.springframework.cglib.core.SpringNamingPolicy; import org.springframework.cglib.proxy.Callback; import org.springframework.cglib.proxy.CallbackFilter; @@ -207,13 +207,11 @@ public Class[] getCallbackTypes() { * Also exposes the application ClassLoader as thread context ClassLoader for the time of * class generation (in order for ASM to pick it up when doing common superclass resolution). */ - private static class BeanFactoryAwareGeneratorStrategy extends DefaultGeneratorStrategy { - - @Nullable - private final ClassLoader classLoader; + private static class BeanFactoryAwareGeneratorStrategy extends + ClassLoaderAwareGeneratorStrategy { public BeanFactoryAwareGeneratorStrategy(@Nullable ClassLoader classLoader) { - this.classLoader = classLoader; + super(classLoader); } @Override @@ -228,36 +226,6 @@ public void end_class() { return new TransformingClassGenerator(cg, transformer); } - @Override - public byte[] generate(ClassGenerator cg) throws Exception { - if (this.classLoader == null) { - return super.generate(cg); - } - - Thread currentThread = Thread.currentThread(); - ClassLoader threadContextClassLoader; - try { - threadContextClassLoader = currentThread.getContextClassLoader(); - } - catch (Throwable ex) { - // Cannot access thread context ClassLoader - falling back... - return super.generate(cg); - } - - boolean overrideClassLoader = !this.classLoader.equals(threadContextClassLoader); - if (overrideClassLoader) { - currentThread.setContextClassLoader(this.classLoader); - } - try { - return super.generate(cg); - } - finally { - if (overrideClassLoader) { - // Reset original thread context ClassLoader. - currentThread.setContextClassLoader(threadContextClassLoader); - } - } - } } From b4cf88499c36c5120da9596e2785895a3d2a512d Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Tue, 4 Feb 2020 22:21:59 +0900 Subject: [PATCH 0392/2315] Use try-with-resource in ScriptUtils Closes gh-24385 --- .../springframework/jdbc/datasource/init/ScriptUtils.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java index 6ee6be6e1bbf..2b2f66b57f64 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java @@ -325,13 +325,9 @@ static String readScript(EncodedResource resource) throws IOException { private static String readScript(EncodedResource resource, @Nullable String[] commentPrefixes, @Nullable String separator, @Nullable String blockCommentEndDelimiter) throws IOException { - LineNumberReader lnr = new LineNumberReader(resource.getReader()); - try { + try (LineNumberReader lnr = new LineNumberReader(resource.getReader())) { return readScript(lnr, commentPrefixes, separator, blockCommentEndDelimiter); } - finally { - lnr.close(); - } } /** From 7575616d268997b40758ccb57815d57afceb9ab5 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 4 Feb 2020 14:23:18 +0100 Subject: [PATCH 0393/2315] Update copyright date See gh-24385 --- .../org/springframework/jdbc/datasource/init/ScriptUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java index 2b2f66b57f64..fa87e08f9d5d 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. From 1acf5a742436d2e8460a880c11dd4946d2ca3555 Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Tue, 4 Feb 2020 22:45:52 +0900 Subject: [PATCH 0394/2315] Use dedicated catch block for ScriptException Closes gh-24383 --- .../jdbc/datasource/init/DatabasePopulatorUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java index 534df4a08210..b8de5191ae83 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -52,10 +52,10 @@ public static void execute(DatabasePopulator populator, DataSource dataSource) t DataSourceUtils.releaseConnection(connection, dataSource); } } + catch (ScriptException ex){ + throw ex; + } catch (Throwable ex) { - if (ex instanceof ScriptException) { - throw (ScriptException) ex; - } throw new UncategorizedScriptException("Failed to execute database script", ex); } } From c2367b3ad23a5c90920ca0d8f18bda6bbedbf855 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 4 Feb 2020 14:48:13 +0100 Subject: [PATCH 0395/2315] Polish contribution See gh-24383 --- .../jdbc/datasource/init/DatabasePopulatorUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java index b8de5191ae83..3861cb5e54b2 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java @@ -52,7 +52,7 @@ public static void execute(DatabasePopulator populator, DataSource dataSource) t DataSourceUtils.releaseConnection(connection, dataSource); } } - catch (ScriptException ex){ + catch (ScriptException ex) { throw ex; } catch (Throwable ex) { From d93303c0089d311f2b014f45f1b345ca7ab9cb1f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 5 Feb 2020 12:35:16 +0100 Subject: [PATCH 0396/2315] ImportSelector.getCandidateFilter() for transitive filtering of classes Closes gh-24175 --- .../annotation/ConfigurationClassParser.java | 130 ++++++++++-------- .../annotation/DeferredImportSelector.java | 3 +- .../context/annotation/ImportSelector.java | 21 ++- .../annotation/ImportSelectorTests.java | 17 ++- 4 files changed, 111 insertions(+), 60 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java index 5be7fe892ba5..7b406d6c9115 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -34,6 +34,7 @@ import java.util.Map; import java.util.Set; import java.util.StringJoiner; +import java.util.function.Predicate; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -110,6 +111,9 @@ class ConfigurationClassParser { private static final PropertySourceFactory DEFAULT_PROPERTY_SOURCE_FACTORY = new DefaultPropertySourceFactory(); + private static final Predicate DEFAULT_CANDIDATE_FILTER = className -> + (className.startsWith("java.lang.annotation.") || className.startsWith("org.springframework.stereotype.")); + private static final Comparator DEFERRED_IMPORT_COMPARATOR = (o1, o2) -> AnnotationAwareOrderComparator.INSTANCE.compare(o1.getImportSelector(), o2.getImportSelector()); @@ -191,15 +195,15 @@ else if (bd instanceof AbstractBeanDefinition && ((AbstractBeanDefinition) bd).h protected final void parse(@Nullable String className, String beanName) throws IOException { Assert.notNull(className, "No bean class name for configuration class bean definition"); MetadataReader reader = this.metadataReaderFactory.getMetadataReader(className); - processConfigurationClass(new ConfigurationClass(reader, beanName)); + processConfigurationClass(new ConfigurationClass(reader, beanName), DEFAULT_CANDIDATE_FILTER); } protected final void parse(Class clazz, String beanName) throws IOException { - processConfigurationClass(new ConfigurationClass(clazz, beanName)); + processConfigurationClass(new ConfigurationClass(clazz, beanName), DEFAULT_CANDIDATE_FILTER); } protected final void parse(AnnotationMetadata metadata, String beanName) throws IOException { - processConfigurationClass(new ConfigurationClass(metadata, beanName)); + processConfigurationClass(new ConfigurationClass(metadata, beanName), DEFAULT_CANDIDATE_FILTER); } /** @@ -217,7 +221,7 @@ public Set getConfigurationClasses() { } - protected void processConfigurationClass(ConfigurationClass configClass) throws IOException { + protected void processConfigurationClass(ConfigurationClass configClass, Predicate filter) throws IOException { if (this.conditionEvaluator.shouldSkip(configClass.getMetadata(), ConfigurationPhase.PARSE_CONFIGURATION)) { return; } @@ -240,9 +244,9 @@ protected void processConfigurationClass(ConfigurationClass configClass) throws } // Recursively process the configuration class and its superclass hierarchy. - SourceClass sourceClass = asSourceClass(configClass); + SourceClass sourceClass = asSourceClass(configClass, filter); do { - sourceClass = doProcessConfigurationClass(configClass, sourceClass); + sourceClass = doProcessConfigurationClass(configClass, sourceClass, filter); } while (sourceClass != null); @@ -258,12 +262,13 @@ protected void processConfigurationClass(ConfigurationClass configClass) throws * @return the superclass, or {@code null} if none found or previously processed */ @Nullable - protected final SourceClass doProcessConfigurationClass(ConfigurationClass configClass, SourceClass sourceClass) + protected final SourceClass doProcessConfigurationClass( + ConfigurationClass configClass, SourceClass sourceClass, Predicate filter) throws IOException { if (configClass.getMetadata().isAnnotated(Component.class.getName())) { // Recursively process any member (nested) classes first - processMemberClasses(configClass, sourceClass); + processMemberClasses(configClass, sourceClass, filter); } // Process any @PropertySource annotations @@ -302,7 +307,7 @@ protected final SourceClass doProcessConfigurationClass(ConfigurationClass confi } // Process any @Import annotations - processImports(configClass, sourceClass, getImports(sourceClass), true); + processImports(configClass, sourceClass, getImports(sourceClass), filter, true); // Process any @ImportResource annotations AnnotationAttributes importResource = @@ -343,7 +348,9 @@ protected final SourceClass doProcessConfigurationClass(ConfigurationClass confi /** * Register member (nested) classes that happen to be configuration classes themselves. */ - private void processMemberClasses(ConfigurationClass configClass, SourceClass sourceClass) throws IOException { + private void processMemberClasses(ConfigurationClass configClass, SourceClass sourceClass, + Predicate filter) throws IOException { + Collection memberClasses = sourceClass.getMemberClasses(); if (!memberClasses.isEmpty()) { List candidates = new ArrayList<>(memberClasses.size()); @@ -361,7 +368,7 @@ private void processMemberClasses(ConfigurationClass configClass, SourceClass so else { this.importStack.push(configClass); try { - processConfigurationClass(candidate.asConfigClass(configClass)); + processConfigurationClass(candidate.asConfigClass(configClass), filter); } finally { this.importStack.pop(); @@ -543,7 +550,8 @@ private void collectImports(SourceClass sourceClass, Set imports, S } private void processImports(ConfigurationClass configClass, SourceClass currentSourceClass, - Collection importCandidates, boolean checkForCircularImports) { + Collection importCandidates, Predicate candidateFilter, + boolean checkForCircularImports) { if (importCandidates.isEmpty()) { return; @@ -561,13 +569,17 @@ private void processImports(ConfigurationClass configClass, SourceClass currentS Class candidateClass = candidate.loadClass(); ImportSelector selector = ParserStrategyUtils.instantiateClass(candidateClass, ImportSelector.class, this.environment, this.resourceLoader, this.registry); + Predicate selectorFilter = selector.getCandidateFilter(); + if (selectorFilter != null) { + candidateFilter = candidateFilter.or(selectorFilter); + } if (selector instanceof DeferredImportSelector) { this.deferredImportSelectorHandler.handle(configClass, (DeferredImportSelector) selector); } else { String[] importClassNames = selector.selectImports(currentSourceClass.getMetadata()); - Collection importSourceClasses = asSourceClasses(importClassNames); - processImports(configClass, currentSourceClass, importSourceClasses, false); + Collection importSourceClasses = asSourceClasses(importClassNames, candidateFilter); + processImports(configClass, currentSourceClass, importSourceClasses, candidateFilter, false); } } else if (candidate.isAssignable(ImportBeanDefinitionRegistrar.class)) { @@ -584,7 +596,7 @@ else if (candidate.isAssignable(ImportBeanDefinitionRegistrar.class)) { // process it as an @Configuration class this.importStack.registerImport( currentSourceClass.getMetadata(), candidate.getMetadata().getClassName()); - processConfigurationClass(candidate.asConfigClass(configClass)); + processConfigurationClass(candidate.asConfigClass(configClass), candidateFilter); } } } @@ -624,19 +636,19 @@ ImportRegistry getImportRegistry() { /** * Factory method to obtain a {@link SourceClass} from a {@link ConfigurationClass}. */ - private SourceClass asSourceClass(ConfigurationClass configurationClass) throws IOException { + private SourceClass asSourceClass(ConfigurationClass configurationClass, Predicate filter) throws IOException { AnnotationMetadata metadata = configurationClass.getMetadata(); if (metadata instanceof StandardAnnotationMetadata) { - return asSourceClass(((StandardAnnotationMetadata) metadata).getIntrospectedClass()); + return asSourceClass(((StandardAnnotationMetadata) metadata).getIntrospectedClass(), filter); } - return asSourceClass(metadata.getClassName()); + return asSourceClass(metadata.getClassName(), filter); } /** * Factory method to obtain a {@link SourceClass} from a {@link Class}. */ - SourceClass asSourceClass(@Nullable Class classType) throws IOException { - if (classType == null || classType.getName().startsWith("java.lang.annotation.")) { + SourceClass asSourceClass(@Nullable Class classType, Predicate filter) throws IOException { + if (classType == null || filter.test(classType.getName())) { return this.objectSourceClass; } try { @@ -649,17 +661,17 @@ SourceClass asSourceClass(@Nullable Class classType) throws IOException { } catch (Throwable ex) { // Enforce ASM via class name resolution - return asSourceClass(classType.getName()); + return asSourceClass(classType.getName(), filter); } } /** * Factory method to obtain {@link SourceClass SourceClasss} from class names. */ - private Collection asSourceClasses(String... classNames) throws IOException { + private Collection asSourceClasses(String[] classNames, Predicate filter) throws IOException { List annotatedClasses = new ArrayList<>(classNames.length); for (String className : classNames) { - annotatedClasses.add(asSourceClass(className)); + annotatedClasses.add(asSourceClass(className, filter)); } return annotatedClasses; } @@ -667,23 +679,20 @@ private Collection asSourceClasses(String... classNames) throws IOE /** * Factory method to obtain a {@link SourceClass} from a class name. */ - SourceClass asSourceClass(@Nullable String className) throws IOException { - if (className == null || className.startsWith("java.lang.annotation.")) { + SourceClass asSourceClass(@Nullable String className, Predicate filter) throws IOException { + if (className == null || filter.test(className)) { return this.objectSourceClass; } if (className.startsWith("java")) { // Never use ASM for core java types try { - return new SourceClass(ClassUtils.forName(className, - this.resourceLoader.getClassLoader())); + return new SourceClass(ClassUtils.forName(className, this.resourceLoader.getClassLoader())); } catch (ClassNotFoundException ex) { - throw new NestedIOException( - "Failed to load class [" + className + "]", ex); + throw new NestedIOException("Failed to load class [" + className + "]", ex); } } - return new SourceClass( - this.metadataReaderFactory.getMetadataReader(className)); + return new SourceClass(this.metadataReaderFactory.getMetadataReader(className)); } @@ -748,8 +757,7 @@ private class DeferredImportSelectorHandler { * @param importSelector the selector to handle */ public void handle(ConfigurationClass configClass, DeferredImportSelector importSelector) { - DeferredImportSelectorHolder holder = new DeferredImportSelectorHolder( - configClass, importSelector); + DeferredImportSelectorHolder holder = new DeferredImportSelectorHolder(configClass, importSelector); if (this.deferredImportSelectors == null) { DeferredImportSelectorGroupingHandler handler = new DeferredImportSelectorGroupingHandler(); handler.register(holder); @@ -775,7 +783,6 @@ public void process() { this.deferredImportSelectors = new ArrayList<>(); } } - } @@ -786,8 +793,7 @@ private class DeferredImportSelectorGroupingHandler { private final Map configurationClasses = new HashMap<>(); public void register(DeferredImportSelectorHolder deferredImport) { - Class group = deferredImport.getImportSelector() - .getImportGroup(); + Class group = deferredImport.getImportSelector().getImportGroup(); DeferredImportSelectorGrouping grouping = this.groupings.computeIfAbsent( (group != null ? group : deferredImport), key -> new DeferredImportSelectorGrouping(createGroup(group))); @@ -798,12 +804,13 @@ public void register(DeferredImportSelectorHolder deferredImport) { public void processGroupImports() { for (DeferredImportSelectorGrouping grouping : this.groupings.values()) { + Predicate candidateFilter = grouping.getCandidateFilter(); grouping.getImports().forEach(entry -> { - ConfigurationClass configurationClass = this.configurationClasses.get( - entry.getMetadata()); + ConfigurationClass configurationClass = this.configurationClasses.get(entry.getMetadata()); try { - processImports(configurationClass, asSourceClass(configurationClass), - asSourceClasses(entry.getImportClassName()), false); + processImports(configurationClass, asSourceClass(configurationClass, candidateFilter), + Collections.singleton(asSourceClass(entry.getImportClassName(), candidateFilter)), + candidateFilter, false); } catch (BeanDefinitionStoreException ex) { throw ex; @@ -818,15 +825,12 @@ public void processGroupImports() { } private Group createGroup(@Nullable Class type) { - Class effectiveType = (type != null ? type - : DefaultDeferredImportSelectorGroup.class); - Group group = ParserStrategyUtils.instantiateClass(effectiveType, Group.class, + Class effectiveType = (type != null ? type : DefaultDeferredImportSelectorGroup.class); + return ParserStrategyUtils.instantiateClass(effectiveType, Group.class, ConfigurationClassParser.this.environment, ConfigurationClassParser.this.resourceLoader, ConfigurationClassParser.this.registry); - return group; } - } @@ -861,6 +865,10 @@ private static class DeferredImportSelectorGrouping { this.group = group; } + public Group getGroup() { + return this.group; + } + public void add(DeferredImportSelectorHolder deferredImport) { this.deferredImports.add(deferredImport); } @@ -876,6 +884,17 @@ public Iterable getImports() { } return this.group.selectImports(); } + + public Predicate getCandidateFilter() { + Predicate mergedFilter = DEFAULT_CANDIDATE_FILTER; + for (DeferredImportSelectorHolder deferredImport : this.deferredImports) { + Predicate selectorFilter = deferredImport.getImportSelector().getCandidateFilter(); + if (selectorFilter != null) { + mergedFilter = mergedFilter.or(selectorFilter); + } + } + return mergedFilter; + } } @@ -957,7 +976,7 @@ public Collection getMemberClasses() throws IOException { Class[] declaredClasses = sourceClass.getDeclaredClasses(); List members = new ArrayList<>(declaredClasses.length); for (Class declaredClass : declaredClasses) { - members.add(asSourceClass(declaredClass)); + members.add(asSourceClass(declaredClass, DEFAULT_CANDIDATE_FILTER)); } return members; } @@ -974,7 +993,7 @@ public Collection getMemberClasses() throws IOException { List members = new ArrayList<>(memberClassNames.length); for (String memberClassName : memberClassNames) { try { - members.add(asSourceClass(memberClassName)); + members.add(asSourceClass(memberClassName, DEFAULT_CANDIDATE_FILTER)); } catch (IOException ex) { // Let's skip it if it's not resolvable - we're just looking for candidates @@ -989,9 +1008,10 @@ public Collection getMemberClasses() throws IOException { public SourceClass getSuperClass() throws IOException { if (this.source instanceof Class) { - return asSourceClass(((Class) this.source).getSuperclass()); + return asSourceClass(((Class) this.source).getSuperclass(), DEFAULT_CANDIDATE_FILTER); } - return asSourceClass(((MetadataReader) this.source).getClassMetadata().getSuperClassName()); + return asSourceClass( + ((MetadataReader) this.source).getClassMetadata().getSuperClassName(), DEFAULT_CANDIDATE_FILTER); } public Set getInterfaces() throws IOException { @@ -999,12 +1019,12 @@ public Set getInterfaces() throws IOException { if (this.source instanceof Class) { Class sourceClass = (Class) this.source; for (Class ifcClass : sourceClass.getInterfaces()) { - result.add(asSourceClass(ifcClass)); + result.add(asSourceClass(ifcClass, DEFAULT_CANDIDATE_FILTER)); } } else { for (String className : this.metadata.getInterfaceNames()) { - result.add(asSourceClass(className)); + result.add(asSourceClass(className, DEFAULT_CANDIDATE_FILTER)); } } return result; @@ -1018,7 +1038,7 @@ public Set getAnnotations() { Class annType = ann.annotationType(); if (!annType.getName().startsWith("java")) { try { - result.add(asSourceClass(annType)); + result.add(asSourceClass(annType, DEFAULT_CANDIDATE_FILTER)); } catch (Throwable ex) { // An annotation not present on the classpath is being ignored @@ -1060,7 +1080,7 @@ private SourceClass getRelated(String className) throws IOException { if (this.source instanceof Class) { try { Class clazz = ClassUtils.forName(className, ((Class) this.source).getClassLoader()); - return asSourceClass(clazz); + return asSourceClass(clazz, DEFAULT_CANDIDATE_FILTER); } catch (ClassNotFoundException ex) { // Ignore -> fall back to ASM next, except for core java types. @@ -1070,7 +1090,7 @@ private SourceClass getRelated(String className) throws IOException { return new SourceClass(metadataReaderFactory.getMetadataReader(className)); } } - return asSourceClass(className); + return asSourceClass(className, DEFAULT_CANDIDATE_FILTER); } @Override diff --git a/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java b/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java index 6bca9156781c..dedb068b6497 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -51,6 +51,7 @@ default Class getImportGroup() { /** * Interface used to group results from different import selectors. + * @since 5.0 */ interface Group { diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java b/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java index 94edc6374e48..df4fd0436ae4 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2020 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. @@ -16,7 +16,10 @@ package org.springframework.context.annotation; +import java.util.function.Predicate; + import org.springframework.core.type.AnnotationMetadata; +import org.springframework.lang.Nullable; /** * Interface to be implemented by types that determine which @{@link Configuration} @@ -48,6 +51,7 @@ * (see {@link DeferredImportSelector} for details). * * @author Chris Beams + * @author Juergen Hoeller * @since 3.1 * @see DeferredImportSelector * @see Import @@ -59,7 +63,22 @@ public interface ImportSelector { /** * Select and return the names of which class(es) should be imported based on * the {@link AnnotationMetadata} of the importing @{@link Configuration} class. + * @return the class names, or an empty array if none */ String[] selectImports(AnnotationMetadata importingClassMetadata); + /** + * Return a predicate for filtering candidate classes, to be transitively + * applied to all candidate classes found through this selector's imports. + *

    If this predicate returns {@code true} for a given class name, + * said class will not be considered as a configuration class, + * bypassing class loading as well as metadata introspection. + * @return the filter predicate, or {@code null} if none + * @since 5.2.4 + */ + @Nullable + default Predicate getCandidateFilter() { + return null; + } + } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java index 08af14feedbd..b13682f786fa 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -29,6 +29,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Predicate; import java.util.stream.Collectors; import org.junit.jupiter.api.BeforeEach; @@ -101,13 +102,17 @@ public void invokeAwareMethodsInImportSelector() { } @Test - public void correctMetaDataOnIndirectImports() { - new AnnotationConfigApplicationContext(IndirectConfig.class); + public void correctMetadataOnIndirectImports() { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(IndirectConfig.class); String indirectImport = IndirectImport.class.getName(); assertThat(importFrom.get(ImportSelector1.class)).isEqualTo(indirectImport); assertThat(importFrom.get(ImportSelector2.class)).isEqualTo(indirectImport); assertThat(importFrom.get(DeferredImportSelector1.class)).isEqualTo(indirectImport); assertThat(importFrom.get(DeferredImportSelector2.class)).isEqualTo(indirectImport); + assertThat(context.containsBean("a")).isFalse(); // since ImportedSelector1 got filtered + assertThat(context.containsBean("b")).isTrue(); + assertThat(context.containsBean("c")).isTrue(); + assertThat(context.containsBean("d")).isTrue(); } @Test @@ -361,6 +366,12 @@ public static class IndirectImportSelector implements ImportSelector { public String[] selectImports(AnnotationMetadata importingClassMetadata) { return new String[] {IndirectImport.class.getName()}; } + + @Override + @Nullable + public Predicate getCandidateFilter() { + return className -> className.endsWith("ImportedSelector1"); + } } From 82adb094907c07a4a456908dc00f36ea9d2ab1b7 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 5 Feb 2020 18:20:27 +0100 Subject: [PATCH 0397/2315] ImportSelector.getExclusionFilter() naming and javadoc clarification See gh-24175 --- .../annotation/ConfigurationClassParser.java | 50 +++++++++---------- .../context/annotation/ImportSelector.java | 15 +++--- .../annotation/ImportSelectorTests.java | 2 +- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java index 7b406d6c9115..f9c204d4225f 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java @@ -111,7 +111,7 @@ class ConfigurationClassParser { private static final PropertySourceFactory DEFAULT_PROPERTY_SOURCE_FACTORY = new DefaultPropertySourceFactory(); - private static final Predicate DEFAULT_CANDIDATE_FILTER = className -> + private static final Predicate DEFAULT_EXCLUSION_FILTER = className -> (className.startsWith("java.lang.annotation.") || className.startsWith("org.springframework.stereotype.")); private static final Comparator DEFERRED_IMPORT_COMPARATOR = @@ -195,15 +195,15 @@ else if (bd instanceof AbstractBeanDefinition && ((AbstractBeanDefinition) bd).h protected final void parse(@Nullable String className, String beanName) throws IOException { Assert.notNull(className, "No bean class name for configuration class bean definition"); MetadataReader reader = this.metadataReaderFactory.getMetadataReader(className); - processConfigurationClass(new ConfigurationClass(reader, beanName), DEFAULT_CANDIDATE_FILTER); + processConfigurationClass(new ConfigurationClass(reader, beanName), DEFAULT_EXCLUSION_FILTER); } protected final void parse(Class clazz, String beanName) throws IOException { - processConfigurationClass(new ConfigurationClass(clazz, beanName), DEFAULT_CANDIDATE_FILTER); + processConfigurationClass(new ConfigurationClass(clazz, beanName), DEFAULT_EXCLUSION_FILTER); } protected final void parse(AnnotationMetadata metadata, String beanName) throws IOException { - processConfigurationClass(new ConfigurationClass(metadata, beanName), DEFAULT_CANDIDATE_FILTER); + processConfigurationClass(new ConfigurationClass(metadata, beanName), DEFAULT_EXCLUSION_FILTER); } /** @@ -550,7 +550,7 @@ private void collectImports(SourceClass sourceClass, Set imports, S } private void processImports(ConfigurationClass configClass, SourceClass currentSourceClass, - Collection importCandidates, Predicate candidateFilter, + Collection importCandidates, Predicate exclusionFilter, boolean checkForCircularImports) { if (importCandidates.isEmpty()) { @@ -569,17 +569,17 @@ private void processImports(ConfigurationClass configClass, SourceClass currentS Class candidateClass = candidate.loadClass(); ImportSelector selector = ParserStrategyUtils.instantiateClass(candidateClass, ImportSelector.class, this.environment, this.resourceLoader, this.registry); - Predicate selectorFilter = selector.getCandidateFilter(); + Predicate selectorFilter = selector.getExclusionFilter(); if (selectorFilter != null) { - candidateFilter = candidateFilter.or(selectorFilter); + exclusionFilter = exclusionFilter.or(selectorFilter); } if (selector instanceof DeferredImportSelector) { this.deferredImportSelectorHandler.handle(configClass, (DeferredImportSelector) selector); } else { String[] importClassNames = selector.selectImports(currentSourceClass.getMetadata()); - Collection importSourceClasses = asSourceClasses(importClassNames, candidateFilter); - processImports(configClass, currentSourceClass, importSourceClasses, candidateFilter, false); + Collection importSourceClasses = asSourceClasses(importClassNames, exclusionFilter); + processImports(configClass, currentSourceClass, importSourceClasses, exclusionFilter, false); } } else if (candidate.isAssignable(ImportBeanDefinitionRegistrar.class)) { @@ -596,7 +596,7 @@ else if (candidate.isAssignable(ImportBeanDefinitionRegistrar.class)) { // process it as an @Configuration class this.importStack.registerImport( currentSourceClass.getMetadata(), candidate.getMetadata().getClassName()); - processConfigurationClass(candidate.asConfigClass(configClass), candidateFilter); + processConfigurationClass(candidate.asConfigClass(configClass), exclusionFilter); } } } @@ -804,13 +804,13 @@ public void register(DeferredImportSelectorHolder deferredImport) { public void processGroupImports() { for (DeferredImportSelectorGrouping grouping : this.groupings.values()) { - Predicate candidateFilter = grouping.getCandidateFilter(); + Predicate exclusionFilter = grouping.getCandidateFilter(); grouping.getImports().forEach(entry -> { ConfigurationClass configurationClass = this.configurationClasses.get(entry.getMetadata()); try { - processImports(configurationClass, asSourceClass(configurationClass, candidateFilter), - Collections.singleton(asSourceClass(entry.getImportClassName(), candidateFilter)), - candidateFilter, false); + processImports(configurationClass, asSourceClass(configurationClass, exclusionFilter), + Collections.singleton(asSourceClass(entry.getImportClassName(), exclusionFilter)), + exclusionFilter, false); } catch (BeanDefinitionStoreException ex) { throw ex; @@ -886,9 +886,9 @@ public Iterable getImports() { } public Predicate getCandidateFilter() { - Predicate mergedFilter = DEFAULT_CANDIDATE_FILTER; + Predicate mergedFilter = DEFAULT_EXCLUSION_FILTER; for (DeferredImportSelectorHolder deferredImport : this.deferredImports) { - Predicate selectorFilter = deferredImport.getImportSelector().getCandidateFilter(); + Predicate selectorFilter = deferredImport.getImportSelector().getExclusionFilter(); if (selectorFilter != null) { mergedFilter = mergedFilter.or(selectorFilter); } @@ -976,7 +976,7 @@ public Collection getMemberClasses() throws IOException { Class[] declaredClasses = sourceClass.getDeclaredClasses(); List members = new ArrayList<>(declaredClasses.length); for (Class declaredClass : declaredClasses) { - members.add(asSourceClass(declaredClass, DEFAULT_CANDIDATE_FILTER)); + members.add(asSourceClass(declaredClass, DEFAULT_EXCLUSION_FILTER)); } return members; } @@ -993,7 +993,7 @@ public Collection getMemberClasses() throws IOException { List members = new ArrayList<>(memberClassNames.length); for (String memberClassName : memberClassNames) { try { - members.add(asSourceClass(memberClassName, DEFAULT_CANDIDATE_FILTER)); + members.add(asSourceClass(memberClassName, DEFAULT_EXCLUSION_FILTER)); } catch (IOException ex) { // Let's skip it if it's not resolvable - we're just looking for candidates @@ -1008,10 +1008,10 @@ public Collection getMemberClasses() throws IOException { public SourceClass getSuperClass() throws IOException { if (this.source instanceof Class) { - return asSourceClass(((Class) this.source).getSuperclass(), DEFAULT_CANDIDATE_FILTER); + return asSourceClass(((Class) this.source).getSuperclass(), DEFAULT_EXCLUSION_FILTER); } return asSourceClass( - ((MetadataReader) this.source).getClassMetadata().getSuperClassName(), DEFAULT_CANDIDATE_FILTER); + ((MetadataReader) this.source).getClassMetadata().getSuperClassName(), DEFAULT_EXCLUSION_FILTER); } public Set getInterfaces() throws IOException { @@ -1019,12 +1019,12 @@ public Set getInterfaces() throws IOException { if (this.source instanceof Class) { Class sourceClass = (Class) this.source; for (Class ifcClass : sourceClass.getInterfaces()) { - result.add(asSourceClass(ifcClass, DEFAULT_CANDIDATE_FILTER)); + result.add(asSourceClass(ifcClass, DEFAULT_EXCLUSION_FILTER)); } } else { for (String className : this.metadata.getInterfaceNames()) { - result.add(asSourceClass(className, DEFAULT_CANDIDATE_FILTER)); + result.add(asSourceClass(className, DEFAULT_EXCLUSION_FILTER)); } } return result; @@ -1038,7 +1038,7 @@ public Set getAnnotations() { Class annType = ann.annotationType(); if (!annType.getName().startsWith("java")) { try { - result.add(asSourceClass(annType, DEFAULT_CANDIDATE_FILTER)); + result.add(asSourceClass(annType, DEFAULT_EXCLUSION_FILTER)); } catch (Throwable ex) { // An annotation not present on the classpath is being ignored @@ -1080,7 +1080,7 @@ private SourceClass getRelated(String className) throws IOException { if (this.source instanceof Class) { try { Class clazz = ClassUtils.forName(className, ((Class) this.source).getClassLoader()); - return asSourceClass(clazz, DEFAULT_CANDIDATE_FILTER); + return asSourceClass(clazz, DEFAULT_EXCLUSION_FILTER); } catch (ClassNotFoundException ex) { // Ignore -> fall back to ASM next, except for core java types. @@ -1090,7 +1090,7 @@ private SourceClass getRelated(String className) throws IOException { return new SourceClass(metadataReaderFactory.getMetadataReader(className)); } } - return asSourceClass(className, DEFAULT_CANDIDATE_FILTER); + return asSourceClass(className, DEFAULT_EXCLUSION_FILTER); } @Override diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java b/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java index df4fd0436ae4..7ae3423ec596 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ImportSelector.java @@ -68,16 +68,17 @@ public interface ImportSelector { String[] selectImports(AnnotationMetadata importingClassMetadata); /** - * Return a predicate for filtering candidate classes, to be transitively - * applied to all candidate classes found through this selector's imports. - *

    If this predicate returns {@code true} for a given class name, - * said class will not be considered as a configuration class, - * bypassing class loading as well as metadata introspection. - * @return the filter predicate, or {@code null} if none + * Return a predicate for excluding classes from the import candidates, to be + * transitively applied to all classes found through this selector's imports. + *

    If this predicate returns {@code true} for a given fully-qualified + * class name, said class will not be considered as an imported configuration + * class, bypassing class file loading as well as metadata introspection. + * @return the filter predicate for fully-qualified candidate class names + * of transitively imported configuration classes, or {@code null} if none * @since 5.2.4 */ @Nullable - default Predicate getCandidateFilter() { + default Predicate getExclusionFilter() { return null; } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java index b13682f786fa..f310720b6522 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java @@ -369,7 +369,7 @@ public String[] selectImports(AnnotationMetadata importingClassMetadata) { @Override @Nullable - public Predicate getCandidateFilter() { + public Predicate getExclusionFilter() { return className -> className.endsWith("ImportedSelector1"); } } From 65c8a10fb0651279a2cd08c14069a4183c92a8ba Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 5 Feb 2020 18:21:03 +0100 Subject: [PATCH 0398/2315] Upgrade to EclipseLink 2.7.6 and JiBX 1.3.3 --- build.gradle | 4 ++-- spring-oxm/spring-oxm.gradle | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 18a39f76fb9c..58ac081f0986 100644 --- a/build.gradle +++ b/build.gradle @@ -88,7 +88,7 @@ configure(allprojects) { project -> dependency("org.codehaus.jettison:jettison:1.3.8") { exclude group: "stax", name: "stax-api" } - dependencySet(group: 'org.jibx', version: '1.3.1') { + dependencySet(group: 'org.jibx', version: '1.3.3') { entry 'jibx-bind' entry 'jibx-run' } @@ -234,7 +234,7 @@ configure(allprojects) { project -> dependency "com.ibm.websphere:uow:6.0.2.17" dependency "com.jamonapi:jamon:2.81" dependency "joda-time:joda-time:2.10.5" - dependency "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.5" + dependency "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.6" dependency "org.javamoney:moneta:1.3" dependency "com.sun.activation:javax.activation:1.2.0" diff --git a/spring-oxm/spring-oxm.gradle b/spring-oxm/spring-oxm.gradle index 0c8a0af2442d..530245c12625 100644 --- a/spring-oxm/spring-oxm.gradle +++ b/spring-oxm/spring-oxm.gradle @@ -6,7 +6,7 @@ configurations { } dependencies { - jibx "org.jibx:jibx-bind:1.3.1" + jibx "org.jibx:jibx-bind:1.3.3" jibx "org.apache.bcel:bcel:6.0" xjc "javax.xml.bind:jaxb-api:2.3.1" xjc "com.sun.xml.bind:jaxb-core:2.3.0.1" @@ -74,7 +74,7 @@ dependencies { testRuntime("com.sun.xml.bind:jaxb-impl") } -// JiBX compiler is currently not compatible with JDK 9 +// JiBX compiler is currently not compatible with JDK 9+ if (JavaVersion.current() == JavaVersion.VERSION_1_8) { compileTestJava { def bindingXml = "${projectDir}/src/test/resources/org/springframework/oxm/jibx/binding.xml" From 9aea10179b4901d49daf2023c29e49e9762819b7 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 5 Feb 2020 18:13:27 +0000 Subject: [PATCH 0399/2315] Insert StringMessageConverter for SSE Closes gh-24465 --- ...ResponseBodyEmitterReturnValueHandler.java | 23 +++++++++++++++++-- ...nseBodyEmitterReturnValueHandlerTests.java | 8 +++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java index c0c797fff91a..ee02ad1700af 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -18,6 +18,8 @@ import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; @@ -33,6 +35,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.server.ServerHttpResponse; import org.springframework.http.server.ServletServerHttpResponse; import org.springframework.lang.Nullable; @@ -60,6 +63,8 @@ public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodRetur private final List> messageConverters; + private final List> sseMessageConverters; + private final ReactiveTypeHandler reactiveHandler; @@ -72,6 +77,7 @@ public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodRetur public ResponseBodyEmitterReturnValueHandler(List> messageConverters) { Assert.notEmpty(messageConverters, "HttpMessageConverter List must not be empty"); this.messageConverters = messageConverters; + this.sseMessageConverters = initSseConverters(messageConverters); this.reactiveHandler = new ReactiveTypeHandler(); } @@ -88,9 +94,22 @@ public ResponseBodyEmitterReturnValueHandler(List> messa Assert.notEmpty(messageConverters, "HttpMessageConverter List must not be empty"); this.messageConverters = messageConverters; + this.sseMessageConverters = initSseConverters(messageConverters); this.reactiveHandler = new ReactiveTypeHandler(registry, executor, manager); } + private static List> initSseConverters(List> converters) { + for (HttpMessageConverter converter : converters) { + if (converter.canWrite(String.class, MediaType.TEXT_PLAIN)) { + return converters; + } + } + List> result = new ArrayList<>(converters.size() + 1); + result.add(new StringHttpMessageConverter(StandardCharsets.UTF_8)); + result.addAll(converters); + return result; + } + @Override public boolean supportsReturnType(MethodParameter returnType) { @@ -186,7 +205,7 @@ public void send(Object data, @Nullable MediaType mediaType) throws IOException @SuppressWarnings("unchecked") private void sendInternal(T data, @Nullable MediaType mediaType) throws IOException { - for (HttpMessageConverter converter : ResponseBodyEmitterReturnValueHandler.this.messageConverters) { + for (HttpMessageConverter converter : ResponseBodyEmitterReturnValueHandler.this.sseMessageConverters) { if (converter.canWrite(data.getClass(), mediaType)) { ((HttpMessageConverter) converter).write(data, mediaType, this.outputMessage); this.outputMessage.flush(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java index d71cd60378a0..36bb1cada870 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -16,7 +16,6 @@ package org.springframework.web.servlet.mvc.method.annotation; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicReference; @@ -31,7 +30,6 @@ import org.springframework.core.ResolvableType; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; @@ -72,8 +70,8 @@ public class ResponseBodyEmitterReturnValueHandlerTests { @BeforeEach public void setup() throws Exception { - List> converters = Arrays.asList( - new StringHttpMessageConverter(), new MappingJackson2HttpMessageConverter()); + List> converters = + Collections.singletonList(new MappingJackson2HttpMessageConverter()); this.handler = new ResponseBodyEmitterReturnValueHandler(converters); this.request = new MockHttpServletRequest(); From ba5fc21ab40a842f637e83e33fcbf97a3985d0b9 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 5 Feb 2020 18:35:46 +0000 Subject: [PATCH 0400/2315] Option to pair AnnotationIntrospector instances Closes gh-22830 --- .../json/Jackson2ObjectMapperBuilder.java | 21 ++++++++++++++++++- .../Jackson2ObjectMapperBuilderTests.java | 18 +++++++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java index 4709aef1dbe5..e0862b3342f1 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -26,6 +26,7 @@ import java.util.Locale; import java.util.Map; import java.util.TimeZone; +import java.util.function.Function; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonFilter; @@ -45,6 +46,7 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; +import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.FilterProvider; @@ -260,6 +262,23 @@ public Jackson2ObjectMapperBuilder annotationIntrospector(AnnotationIntrospector return this; } + /** + * Alternative to {@link #annotationIntrospector(AnnotationIntrospector)} + * that allows combining with rather than replacing the currently set + * introspector, e.g. via + * {@link AnnotationIntrospectorPair#pair(AnnotationIntrospector, AnnotationIntrospector)}. + * @param pairingFunction a function to apply to the currently set + * introspector (possibly {@code null}); the result of the function becomes + * the new introspector. + * @since 5.2.4 + */ + public Jackson2ObjectMapperBuilder annotationIntrospector( + Function pairingFunction) { + + this.annotationIntrospector = pairingFunction.apply(this.annotationIntrospector); + return this; + } + /** * Specify a {@link com.fasterxml.jackson.databind.PropertyNamingStrategy} to * configure the {@link ObjectMapper} with. diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java index 6abfffe527bc..46e6a75c02ac 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -43,6 +43,7 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.Version; +import com.fasterxml.jackson.databind.AnnotationIntrospector; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonDeserializer; @@ -60,6 +61,7 @@ import com.fasterxml.jackson.databind.deser.BasicDeserializerFactory; import com.fasterxml.jackson.databind.deser.Deserializers; import com.fasterxml.jackson.databind.deser.std.DateDeserializers; +import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.module.SimpleSerializers; @@ -431,7 +433,7 @@ public void filters() throws JsonProcessingException { @Test public void completeSetup() throws JsonMappingException { - NopAnnotationIntrospector annotationIntrospector = NopAnnotationIntrospector.instance; + NopAnnotationIntrospector introspector = NopAnnotationIntrospector.instance; Map, JsonDeserializer> deserializerMap = new HashMap<>(); JsonDeserializer deserializer = new DateDeserializers.DateDeserializer(); @@ -445,7 +447,8 @@ public void completeSetup() throws JsonMappingException { .serializers(serializer1) .serializersByType(Collections.singletonMap(Boolean.class, serializer2)) .deserializersByType(deserializerMap) - .annotationIntrospector(annotationIntrospector) + .annotationIntrospector(introspector) + .annotationIntrospector(current -> AnnotationIntrospector.pair(current, introspector)) .featuresToEnable(SerializationFeature.FAIL_ON_EMPTY_BEANS, DeserializationFeature.UNWRAP_ROOT_VALUE, JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, @@ -470,8 +473,13 @@ public void completeSetup() throws JsonMappingException { Deserializers deserializers = getDeserializerFactoryConfig(mapper).deserializers().iterator().next(); assertThat(deserializers.findBeanDeserializer(SimpleType.construct(Date.class), null, null)).isSameAs(deserializer); - assertThat(mapper.getSerializationConfig().getAnnotationIntrospector()).isSameAs(annotationIntrospector); - assertThat(mapper.getDeserializationConfig().getAnnotationIntrospector()).isSameAs(annotationIntrospector); + AnnotationIntrospectorPair pair1 = + (AnnotationIntrospectorPair) mapper.getSerializationConfig().getAnnotationIntrospector(); + AnnotationIntrospectorPair pair2 = + (AnnotationIntrospectorPair) mapper.getDeserializationConfig().getAnnotationIntrospector(); + + assertThat(pair1.allIntrospectors()).containsExactly(introspector, introspector); + assertThat(pair2.allIntrospectors()).containsExactly(introspector, introspector); assertThat(mapper.getSerializationConfig().isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)).isTrue(); assertThat(mapper.getDeserializationConfig().isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE)).isTrue(); From 10d008e3dbd696f868fcaf23faccd2e0ff6be2ee Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 6 Feb 2020 08:56:18 +0100 Subject: [PATCH 0401/2315] Upgrade to RSocket 1.0.0-RC6 Closes gh-24482 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 58ac081f0986..24be2186d012 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,7 @@ configure(allprojects) { project -> mavenBom "com.fasterxml.jackson:jackson-bom:2.10.2" mavenBom "io.netty:netty-bom:4.1.45.Final" mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR4" - mavenBom "io.rsocket:rsocket-bom:1.0.0-RC5" + mavenBom "io.rsocket:rsocket-bom:1.0.0-RC6" mavenBom "org.eclipse.jetty:jetty-bom:9.4.26.v20200117" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.61" mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.2" From 669a689a50a1afd8f3cd97639753933822c8c79e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 6 Feb 2020 12:44:05 +0100 Subject: [PATCH 0402/2315] Prevent unnecessary refresh for InjectionMetadata.EMPTY Closes gh-24485 --- .../factory/annotation/InjectionMetadata.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java index 1d1fbd77cb72..107aa580b587 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. +4 * Copyright 2002-2020 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. @@ -53,6 +53,10 @@ public class InjectionMetadata { * @since 5.2 */ public static final InjectionMetadata EMPTY = new InjectionMetadata(Object.class, Collections.emptyList()) { + @Override + protected boolean needsRefresh(Class clazz) { + return false; + } @Override public void checkConfigMembers(RootBeanDefinition beanDefinition) { } @@ -89,6 +93,16 @@ public InjectionMetadata(Class targetClass, Collection eleme } + /** + * Determine whether this metadata instance needs to be refreshed. + * @param clazz the current target class + * @return {@code true} indicating a refresh, {@code false} otherwise + * @since 5.2.4 + */ + protected boolean needsRefresh(Class clazz) { + return this.targetClass != clazz; + } + public void checkConfigMembers(RootBeanDefinition beanDefinition) { Set checkedElements = new LinkedHashSet<>(this.injectedElements.size()); for (InjectedElement element : this.injectedElements) { @@ -153,7 +167,7 @@ public static InjectionMetadata forElements(Collection elements * @return {@code true} indicating a refresh, {@code false} otherwise */ public static boolean needsRefresh(@Nullable InjectionMetadata metadata, Class clazz) { - return (metadata == null || metadata.targetClass != clazz); + return (metadata == null || metadata.needsRefresh(clazz)); } From b23049bd27cc9d8c015b2b4a984c4ea5411f556f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 6 Feb 2020 12:59:55 +0100 Subject: [PATCH 0403/2315] Polishing --- .../beans/factory/annotation/InjectionMetadata.java | 5 +++-- spring-context/spring-context.gradle | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java index 107aa580b587..3af5c1369396 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java @@ -1,5 +1,5 @@ /* -4 * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2020 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. @@ -152,7 +152,7 @@ public void clear(@Nullable PropertyValues pvs) { * Return an {@code InjectionMetadata} instance, possibly for empty elements. * @param elements the elements to inject (possibly empty) * @param clazz the target class - * @return a new {@code InjectionMetadata} instance, + * @return a new {@link #InjectionMetadata(Class, Collection)} instance, * or {@link #EMPTY} in case of no elements * @since 5.2 */ @@ -165,6 +165,7 @@ public static InjectionMetadata forElements(Collection elements * @param metadata the existing metadata instance * @param clazz the current target class * @return {@code true} indicating a refresh, {@code false} otherwise + * @see #needsRefresh(Class) */ public static boolean needsRefresh(@Nullable InjectionMetadata metadata, Class clazz) { return (metadata == null || metadata.needsRefresh(clazz)); diff --git a/spring-context/spring-context.gradle b/spring-context/spring-context.gradle index 4d37abe0786c..99e550fa328b 100644 --- a/spring-context/spring-context.gradle +++ b/spring-context/spring-context.gradle @@ -15,7 +15,7 @@ dependencies { optional("javax.inject:javax.inject") optional("javax.interceptor:javax.interceptor-api") optional("javax.money:money-api") - // TODO: overriding 2.0.1.Final, because of LocalValidatorFactoryBean + // Overriding 2.0.1.Final due to Bean Validation 1.1 compatibility in LocalValidatorFactoryBean optional("javax.validation:validation-api:1.1.0.Final") optional("javax.xml.ws:jaxws-api") optional("org.aspectj:aspectjweaver") @@ -35,12 +35,11 @@ dependencies { testCompile("org.codehaus.groovy:groovy-xml") testCompile("org.apache.commons:commons-pool2") testCompile("javax.inject:javax.inject-tck") - // Substitute for "javax.management:jmxremote_optional:1.0.1_04" which - // is not available on Maven Central - testRuntime("org.glassfish.external:opendmk_jmxremote_optional_jar") testCompile("org.awaitility:awaitility") testRuntime("javax.xml.bind:jaxb-api") testRuntime("org.glassfish:javax.el") + // Substitute for javax.management:jmxremote_optional:1.0.1_04 (not available on Maven Central) + testRuntime("org.glassfish.external:opendmk_jmxremote_optional_jar") testRuntime("org.javamoney:moneta") testRuntime("org.junit.vintage:junit-vintage-engine") // for @Inject TCK testFixturesApi("org.junit.jupiter:junit-jupiter-api") From 8f02e1088d7d12918f9fa594837aa32252e6c55c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 5 Feb 2020 15:11:59 +0100 Subject: [PATCH 0404/2315] Support alternate JDK versions in Gradle build This commit adds support for the following two JVM system properties that control the Gradle build for alternative JDKs (i.e., a JDK other than the one used to launch the Gradle process). - customJavaHome: absolute path to the alternate JDK installation to use to compile Java code and execute tests. Setting this system property causes Groovy 3.0 RC3 to be used instead of 2.5.x. This system property is also used in spring-oxm.gradle to determine whether JiBX is supported. - customJavaSourceVersion: Java version supplied to the `--release` command line flag to control the Java source and target compatibility version. Supported versions include 9 or higher. Do not set this system property if Java 8 should be used. Examples: ./gradlew -DcustomJavaHome=/opt/java/jdk-14 test ./gradlew --no-build-cache -DcustomJavaHome=/opt/java/jdk-14 test ./gradlew -DcustomJavaHome=/opt/java/jdk-14 -DcustomJavaSourceVersion=14 test See gh-24474 --- build.gradle | 4 +- gradle/build-scan-user-data.gradle | 16 ++++++ gradle/custom-java-home.gradle | 87 ++++++++++++++++++++++++++++++ spring-oxm/spring-oxm.gradle | 5 +- 4 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 gradle/custom-java-home.gradle diff --git a/build.gradle b/build.gradle index 24be2186d012..e597ed582e03 100644 --- a/build.gradle +++ b/build.gradle @@ -60,7 +60,8 @@ configure(allprojects) { project -> entry 'aspectjtools' entry 'aspectjweaver' } - dependencySet(group: 'org.codehaus.groovy', version: '2.5.9') { + // If customJavaHome has been set, we assume we need Groovy 3.0 for testing purposes. + dependencySet(group: 'org.codehaus.groovy', version: System.getProperty("customJavaHome") ? '3.0.0-rc-3' : '2.5.9') { entry 'groovy' entry 'groovy-jsr223' entry 'groovy-templates' @@ -305,6 +306,7 @@ configure([rootProject] + javaProjects) { project -> apply plugin: "java-test-fixtures" apply plugin: "checkstyle" apply plugin: 'org.springframework.build.compile' + apply from: "${rootDir}/gradle/custom-java-home.gradle" apply from: "${rootDir}/gradle/ide.gradle" pluginManager.withPlugin("kotlin") { diff --git a/gradle/build-scan-user-data.gradle b/gradle/build-scan-user-data.gradle index d4f483d66f26..c9463e7f33d1 100644 --- a/gradle/build-scan-user-data.gradle +++ b/gradle/build-scan-user-data.gradle @@ -4,6 +4,8 @@ tagCiOrLocal() addCiMetadata() addGitMetadata() addTestTaskMetadata() +addCustomJavaHomeMetadata() +addCustomJavaSourceVersionMetadata() void tagOs() { buildScan.tag System.getProperty('os.name') @@ -60,6 +62,20 @@ void addTestTaskMetadata() { } } +void addCustomJavaHomeMetadata() { + def customJavaHome = System.getProperty("customJavaHome") + if (customJavaHome) { + buildScan.value "Custom JAVA_HOME", customJavaHome + } +} + +void addCustomJavaSourceVersionMetadata() { + def customJavaSourceVersion = System.getProperty("customJavaSourceVersion") + if (customJavaSourceVersion) { + buildScan.value "Custom Java Source Version", customJavaSourceVersion + } +} + boolean isCi() { isBamboo() } diff --git a/gradle/custom-java-home.gradle b/gradle/custom-java-home.gradle new file mode 100644 index 000000000000..39d2619e9a2f --- /dev/null +++ b/gradle/custom-java-home.gradle @@ -0,0 +1,87 @@ +// ----------------------------------------------------------------------------- +// +// This script adds support for the following two JVM system properties +// that control the build for alternative JDKs (i.e., a JDK other than +// the one used to launch the Gradle process). +// +// - customJavaHome: absolute path to the alternate JDK installation to +// use to compile Java code and execute tests. Setting this system +// property causes Groovy 3.0 RC3 to be used instead of 2.5.x. This +// system property is also used in spring-oxm.gradle to determine +// whether JiBX is supported. +// +// - customJavaSourceVersion: Java version supplied to the `--release` +// command line flag to control the Java source and target +// compatibility version. Supported versions include 9 or higher. +// Do not set this system property if Java 8 should be used. +// +// Examples: +// +// ./gradlew -DcustomJavaHome=/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home test +// +// ./gradlew --no-build-cache -DcustomJavaHome=/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home test +// +// ./gradlew -DcustomJavaHome=/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home -DcustomJavaSourceVersion=14 test +// +// ----------------------------------------------------------------------------- + +import org.gradle.internal.os.OperatingSystem +// import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile + +def customJavaHome = System.getProperty("customJavaHome") + +if (customJavaHome) { + def javacExecutable = customJavaHome + "/bin/javac" + def javaExecutable = customJavaHome + "/bin/java" + if (OperatingSystem.current().isWindows()) { + javacExecutable += ".exe" + javaExecutable += ".exe" + } + + def customJavaSourceVersion = System.getProperty("customJavaSourceVersion") + + tasks.withType(JavaCompile) { + logger.info("Java compiler for " + it.name + " task in " + project.name + ": " + javacExecutable) + doFirst { + // Avoid compiler warnings for non-existing path entries + classpath = classpath.filter { it.exists() } + } + options.fork = true + options.forkOptions.executable = javacExecutable + options.compilerArgs -= "-Werror" + if (customJavaSourceVersion) { + options.compilerArgs += [ "--release", customJavaSourceVersion] + inputs.property("customJavaSourceVersion", customJavaSourceVersion) + } + inputs.property("customJavaHome", customJavaHome) + } + + tasks.withType(GroovyCompile) { + logger.info("Java compiler for " + it.name + " task in " + project.name + ": " + javacExecutable) + options.fork = true + options.forkOptions.executable = javacExecutable + if (customJavaSourceVersion) { + options.compilerArgs += [ "--release", customJavaSourceVersion] + inputs.property("customJavaSourceVersion", customJavaSourceVersion) + } + inputs.property("customJavaHome", customJavaHome) + } + + /* + tasks.withType(KotlinJvmCompile) { + logger.info("Java home for " + it.name + " task in " + project.name + ": " + customJavaHome) + kotlinOptions.jdkHome = customJavaHome + inputs.property("customJavaHome", customJavaHome) + } + */ + + tasks.withType(Test) { + logger.info("Java executable for " + it.name + " task in " + project.name + ": " + javaExecutable) + executable = javaExecutable + inputs.property("customJavaHome", customJavaHome) + if (customJavaSourceVersion) { + inputs.property("customJavaSourceVersion", customJavaSourceVersion) + } + } + +} diff --git a/spring-oxm/spring-oxm.gradle b/spring-oxm/spring-oxm.gradle index 530245c12625..9d23276d2282 100644 --- a/spring-oxm/spring-oxm.gradle +++ b/spring-oxm/spring-oxm.gradle @@ -74,8 +74,9 @@ dependencies { testRuntime("com.sun.xml.bind:jaxb-impl") } -// JiBX compiler is currently not compatible with JDK 9+ -if (JavaVersion.current() == JavaVersion.VERSION_1_8) { +// JiBX compiler is currently not compatible with JDK 9+. +// If customJavaHome has been set, we assume the custom JDK version is 9+. +if ((JavaVersion.current() == JavaVersion.VERSION_1_8) && !System.getProperty("customJavaSourceVersion")) { compileTestJava { def bindingXml = "${projectDir}/src/test/resources/org/springframework/oxm/jibx/binding.xml" From ce2c0e4c79ca399b24ac0b1338d13ca74bc13116 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 6 Feb 2020 15:32:51 +0100 Subject: [PATCH 0405/2315] Credit @marcphilipp and @snicoll See gh-24474 --- gradle/custom-java-home.gradle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gradle/custom-java-home.gradle b/gradle/custom-java-home.gradle index 39d2619e9a2f..0e523d2e1f64 100644 --- a/gradle/custom-java-home.gradle +++ b/gradle/custom-java-home.gradle @@ -16,13 +16,16 @@ // Do not set this system property if Java 8 should be used. // // Examples: -// +// // ./gradlew -DcustomJavaHome=/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home test // // ./gradlew --no-build-cache -DcustomJavaHome=/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home test // // ./gradlew -DcustomJavaHome=/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home -DcustomJavaSourceVersion=14 test // +// +// Credits: inspired by work from Marc Philipp and Stephane Nicoll +// // ----------------------------------------------------------------------------- import org.gradle.internal.os.OperatingSystem From 711fafc924e451b9b2eae63839280aff11f381cd Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Thu, 6 Feb 2020 15:41:33 +0100 Subject: [PATCH 0406/2315] Improve assertion message in PersistenceExceptionTranslationInterceptor Closes gh-24484 --- .../support/PersistenceExceptionTranslationInterceptor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-tx/src/main/java/org/springframework/dao/support/PersistenceExceptionTranslationInterceptor.java b/spring-tx/src/main/java/org/springframework/dao/support/PersistenceExceptionTranslationInterceptor.java index 1c035451e958..772787433261 100644 --- a/spring-tx/src/main/java/org/springframework/dao/support/PersistenceExceptionTranslationInterceptor.java +++ b/spring-tx/src/main/java/org/springframework/dao/support/PersistenceExceptionTranslationInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -146,7 +146,7 @@ public Object invoke(MethodInvocation mi) throws Throwable { else { PersistenceExceptionTranslator translator = this.persistenceExceptionTranslator; if (translator == null) { - Assert.state(this.beanFactory != null, "No PersistenceExceptionTranslator set"); + Assert.state(this.beanFactory != null, "Cannot use PersistenceExceptionTranslator autodetection without ListableBeanFactory"); translator = detectPersistenceExceptionTranslators(this.beanFactory); this.persistenceExceptionTranslator = translator; } From c6484258222c469b7f06f4c934d9d2ed980cbb37 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 7 Feb 2020 10:23:07 +0100 Subject: [PATCH 0407/2315] Ignore warnings for missing classpath elements with custom JAVA_HOME Prior to this commit, the "-Werror" was removed as a command-line argument in order not to fail the build for missing classpath elements. This commit reinstates "-Werror" and removes "-Xlink:path" in order to explicitly ignore warnings for missing classpath elements when executing the build with a custom JAVA_HOME. See gh-24474 --- gradle/custom-java-home.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gradle/custom-java-home.gradle b/gradle/custom-java-home.gradle index 0e523d2e1f64..a9a41ae9c7f9 100644 --- a/gradle/custom-java-home.gradle +++ b/gradle/custom-java-home.gradle @@ -51,7 +51,9 @@ if (customJavaHome) { } options.fork = true options.forkOptions.executable = javacExecutable - options.compilerArgs -= "-Werror" + // Ignore warnings about missing classpath elements -- for example, those picked up + // via Class-Path entries in MANIFEST.MF files in artifacts like xalan-2.7.2.jar. + options.compilerArgs -= "-Xlint:path" if (customJavaSourceVersion) { options.compilerArgs += [ "--release", customJavaSourceVersion] inputs.property("customJavaSourceVersion", customJavaSourceVersion) From 45555f77a6f41956763eb06844f82691bfe5f14e Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Thu, 6 Feb 2020 10:01:13 +0100 Subject: [PATCH 0408/2315] Honour ObjectMapper feature in Jackson2Tokenizer After this commit, Jackson2Tokenizer honours ObjectMapper's DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS feature when creating TokenBuffers. Closes gh-24479 --- .../http/codec/json/Jackson2Tokenizer.java | 35 +++++++++++++----- .../codec/json/Jackson2TokenizerTests.java | 37 ++++++++++++++++++- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java index 1c110c49a8be..fd31bee84f7e 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -27,6 +27,7 @@ import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.async.ByteArrayFeeder; import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.deser.DefaultDeserializationContext; import com.fasterxml.jackson.databind.util.TokenBuffer; @@ -37,6 +38,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferLimitException; import org.springframework.core.io.buffer.DataBufferUtils; +import org.springframework.lang.Nullable; /** * {@link Function} to transform a JSON stream of arbitrary size, byte array @@ -56,16 +58,19 @@ final class Jackson2Tokenizer { private final boolean tokenizeArrayElements; - private TokenBuffer tokenBuffer; + private final boolean forceUseOfBigDecimal; + + private final int maxInMemorySize; private int objectDepth; private int arrayDepth; - private final int maxInMemorySize; - private int byteCount; + @Nullable // yet initialized by calling createToken() in the constructor + private TokenBuffer tokenBuffer; + // TODO: change to ByteBufferFeeder when supported by Jackson // See https://github.com/FasterXML/jackson-core/issues/478 @@ -73,17 +78,19 @@ final class Jackson2Tokenizer { private Jackson2Tokenizer(JsonParser parser, DeserializationContext deserializationContext, - boolean tokenizeArrayElements, int maxInMemorySize) { + boolean tokenizeArrayElements, boolean forceUseOfBigDecimal, int maxInMemorySize) { this.parser = parser; this.deserializationContext = deserializationContext; this.tokenizeArrayElements = tokenizeArrayElements; - this.tokenBuffer = new TokenBuffer(parser, deserializationContext); + this.forceUseOfBigDecimal = forceUseOfBigDecimal; this.inputFeeder = (ByteArrayFeeder) this.parser.getNonBlockingInputFeeder(); this.maxInMemorySize = maxInMemorySize; + createToken(); } + private List tokenize(DataBuffer dataBuffer) { int bufferSize = dataBuffer.readableByteCount(); byte[] bytes = new byte[bufferSize]; @@ -134,6 +141,9 @@ else if (token == null ) { // !previousNull previousNull = true; continue; } + else { + previousNull = false; + } updateDepth(token); if (!this.tokenizeArrayElements) { processTokenNormal(token, result); @@ -167,7 +177,7 @@ private void processTokenNormal(JsonToken token, List result) throw if ((token.isStructEnd() || token.isScalarValue()) && this.objectDepth == 0 && this.arrayDepth == 0) { result.add(this.tokenBuffer); - this.tokenBuffer = new TokenBuffer(this.parser, this.deserializationContext); + createToken(); } } @@ -180,10 +190,15 @@ private void processTokenArray(JsonToken token, List result) throws if (this.objectDepth == 0 && (this.arrayDepth == 0 || this.arrayDepth == 1) && (token == JsonToken.END_OBJECT || token.isScalarValue())) { result.add(this.tokenBuffer); - this.tokenBuffer = new TokenBuffer(this.parser, this.deserializationContext); + createToken(); } } + private void createToken() { + this.tokenBuffer = new TokenBuffer(this.parser, this.deserializationContext); + this.tokenBuffer.forceUseOfBigDecimal(this.forceUseOfBigDecimal); + } + private boolean isTopLevelArrayToken(JsonToken token) { return this.objectDepth == 0 && ((token == JsonToken.START_ARRAY && this.arrayDepth == 1) || (token == JsonToken.END_ARRAY && this.arrayDepth == 0)); @@ -231,7 +246,9 @@ public static Flux tokenize(Flux dataBuffers, JsonFacto context = ((DefaultDeserializationContext) context).createInstance( objectMapper.getDeserializationConfig(), parser, objectMapper.getInjectableValues()); } - Jackson2Tokenizer tokenizer = new Jackson2Tokenizer(parser, context, tokenizeArrays, maxInMemorySize); + boolean forceUseOfBigDecimal = objectMapper.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS); + Jackson2Tokenizer tokenizer = new Jackson2Tokenizer(parser, context, tokenizeArrays, forceUseOfBigDecimal, + maxInMemorySize); return dataBuffers.concatMapIterable(tokenizer::tokenize).concatWith(tokenizer.endOfInput()); } catch (IOException ex) { diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java index c42291d0c9b1..5af6a0d3b83e 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -22,12 +22,17 @@ import java.util.List; import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.TreeNode; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.util.TokenBuffer; import org.json.JSONException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.skyscreamer.jsonassert.JSONAssert; import reactor.core.publisher.Flux; import reactor.test.StepVerifier; @@ -39,6 +44,8 @@ import static java.util.Arrays.asList; import static java.util.Collections.singletonList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Arjen Poutsma @@ -259,6 +266,34 @@ public void jsonEOFExceptionIsWrappedAsDecodingError() { .verify(); } + @ParameterizedTest + @ValueSource(booleans = {false, true}) + public void useBigDecimalForFloats(boolean useBigDecimalForFloats) { + this.objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, useBigDecimalForFloats); + + Flux source = Flux.just(stringBuffer("1E+2")); + Flux tokens = Jackson2Tokenizer.tokenize(source, this.jsonFactory, this.objectMapper, false, -1); + + StepVerifier.create(tokens) + .assertNext(tokenBuffer -> { + try { + JsonParser parser = tokenBuffer.asParser(); + JsonToken token = parser.nextToken(); + assertThat(token).isEqualTo(JsonToken.VALUE_NUMBER_FLOAT); + JsonParser.NumberType numberType = parser.getNumberType(); + if (useBigDecimalForFloats) { + assertThat(numberType).isEqualTo(JsonParser.NumberType.BIG_DECIMAL); + } + else { + assertThat(numberType).isEqualTo(JsonParser.NumberType.DOUBLE); + } + } + catch (IOException ex) { + fail(ex); + } + }) + .verifyComplete(); + } private Flux decode(List source, boolean tokenize, int maxInMemorySize) { From 51fa98a1b2a1e63ce3d0bbfe72db187b727437cb Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 7 Feb 2020 11:04:03 +0100 Subject: [PATCH 0409/2315] Apply compiler conventions to test fixtures --- .../compile/CompilerConventionsPlugin.java | 20 +++++++++++-------- .../aop/testfixture/advice/MethodCounter.java | 10 ++++------ .../beans/testfixture/beans/TestBean.java | 4 ++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java b/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java index 5cb9a70a37e5..0b87a6136d8b 100644 --- a/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java +++ b/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -33,6 +33,7 @@ * with a dedicated property on the CLI: {@code "./gradlew test -PjavaSourceVersion=11"}. * * @author Brian Clozel + * @author Sam Brannen */ public class CompilerConventionsPlugin implements Plugin { @@ -40,13 +41,13 @@ public class CompilerConventionsPlugin implements Plugin { * The project property that can be used to switch the Java source * compatibility version for building source and test classes. */ - public static String JAVA_SOURCE_VERSION_PROPERTY = "javaSourceVersion"; + public static final String JAVA_SOURCE_VERSION_PROPERTY = "javaSourceVersion"; - public static JavaVersion DEFAULT_COMPILER_VERSION = JavaVersion.VERSION_1_8; + public static final JavaVersion DEFAULT_COMPILER_VERSION = JavaVersion.VERSION_1_8; - private static List COMPILER_ARGS; + private static final List COMPILER_ARGS; - private static List TEST_COMPILER_ARGS; + private static final List TEST_COMPILER_ARGS; static { List commonCompilerArgs = Arrays.asList( @@ -72,7 +73,8 @@ public void apply(Project project) { } /** - * Applies the common Java compiler options for sources and test sources. + * Applies the common Java compiler options for main sources, test fixture sources, and + * test sources. * @param project the current project */ private void applyJavaCompileConventions(Project project) { @@ -93,10 +95,12 @@ private void applyJavaCompileConventions(Project project) { compileTask.getOptions().setEncoding("UTF-8"); }); project.getTasks().withType(JavaCompile.class) - .matching(javaCompile -> javaCompile.getName().equals(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME)) + .matching(javaCompile -> javaCompile.getName().equals(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME) + || javaCompile.getName().equals("compileTestFixturesJava")) .forEach(compileTask -> { compileTask.getOptions().setCompilerArgs(TEST_COMPILER_ARGS); compileTask.getOptions().setEncoding("UTF-8"); }); } -} \ No newline at end of file + +} diff --git a/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java index 6a703fe23a76..384973bd9aa7 100644 --- a/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -25,6 +25,7 @@ * * @author Rod Johnson * @author Chris Beams + * @author Sam Brannen */ @SuppressWarnings("serial") public class MethodCounter implements Serializable { @@ -39,15 +40,12 @@ protected void count(Method m) { } protected void count(String methodName) { - Integer i = map.get(methodName); - i = (i != null) ? new Integer(i.intValue() + 1) : new Integer(1); - map.put(methodName, i); + map.merge(methodName, 1, (n, m) -> n + 1); ++allCount; } public int getCalls(String methodName) { - Integer i = map.get(methodName); - return (i != null ? i.intValue() : 0); + return map.getOrDefault(methodName, 0); } public int getCalls() { diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java index 10431c03425a..ca3850a220a6 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -75,7 +75,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt private Date date = new Date(); - private Float myFloat = new Float(0.0); + private Float myFloat = Float.valueOf(0.0f); private Collection friends = new LinkedList<>(); From c640d28a8222c9e4a28b419df40e3b76af37ddaf Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 7 Feb 2020 11:30:23 +0100 Subject: [PATCH 0410/2315] Polishing --- .../build/compile/CompilerConventionsPlugin.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java b/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java index 0b87a6136d8b..db51666f74b5 100644 --- a/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java +++ b/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java @@ -89,14 +89,14 @@ private void applyJavaCompileConventions(Project project) { java.setTargetCompatibility(DEFAULT_COMPILER_VERSION); project.getTasks().withType(JavaCompile.class) - .matching(javaCompile -> javaCompile.getName().equals(JavaPlugin.COMPILE_JAVA_TASK_NAME)) + .matching(compileTask -> compileTask.getName().equals(JavaPlugin.COMPILE_JAVA_TASK_NAME)) .forEach(compileTask -> { compileTask.getOptions().setCompilerArgs(COMPILER_ARGS); compileTask.getOptions().setEncoding("UTF-8"); }); project.getTasks().withType(JavaCompile.class) - .matching(javaCompile -> javaCompile.getName().equals(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME) - || javaCompile.getName().equals("compileTestFixturesJava")) + .matching(compileTask -> compileTask.getName().equals(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME) + || compileTask.getName().equals("compileTestFixturesJava")) .forEach(compileTask -> { compileTask.getOptions().setCompilerArgs(TEST_COMPILER_ARGS); compileTask.getOptions().setEncoding("UTF-8"); From 02e90a8645d34389d737718d72573947110e681a Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 7 Feb 2020 11:16:02 +0000 Subject: [PATCH 0411/2315] Upgrade to Spring Asciidoctor Extensions 0.4.0.RELEASE 0.4.0 provides built-in support for remembering a user's selections using local storage. This replaces the custom switch language JavaScript. The selection is stored using a key derived from the options that were available. Concretely, when the options are Java or Kotlin, the local storage key is java-kotlin. Similarly, if the choices were Java, Kotlin, and XML, the key would be java-kotlin-xml. Given local storage's domain and protocol scoping, the nature of the key that's used for storage will allow a user's selections to be applied across all documentation hosted on https://docs.spring.io that offer the same options. Closes gh-24481 --- gradle/docs.gradle | 11 ++++++- src/docs/asciidoc/docinfo-footer.html | 1 - src/docs/asciidoc/js/switch-language.js | 43 ------------------------- 3 files changed, 10 insertions(+), 45 deletions(-) delete mode 100644 src/docs/asciidoc/js/switch-language.js diff --git a/gradle/docs.gradle b/gradle/docs.gradle index 1772212c507b..e0be846ea400 100644 --- a/gradle/docs.gradle +++ b/gradle/docs.gradle @@ -3,7 +3,16 @@ configurations { } dependencies { - asciidoctorExt("io.spring.asciidoctor:spring-asciidoctor-extensions:0.2.0.RELEASE") + asciidoctorExt("io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch:0.4.0.RELEASE") +} + +repositories { + maven { + url "https://repo.spring.io/release" + mavenContent { + group "io.spring.asciidoctor" + } + } } /** diff --git a/src/docs/asciidoc/docinfo-footer.html b/src/docs/asciidoc/docinfo-footer.html index dad243ed6f94..a7a58d584ad9 100644 --- a/src/docs/asciidoc/docinfo-footer.html +++ b/src/docs/asciidoc/docinfo-footer.html @@ -1,3 +1,2 @@ - \ No newline at end of file diff --git a/src/docs/asciidoc/js/switch-language.js b/src/docs/asciidoc/js/switch-language.js deleted file mode 100644 index c3ba7a85608c..000000000000 --- a/src/docs/asciidoc/js/switch-language.js +++ /dev/null @@ -1,43 +0,0 @@ -function globalSwitch() { - - var SPRING_LANGUAGES = ["Java", "Kotlin"]; - var preferredLanguage = initPreferredLanguage(); - - function initPreferredLanguage() { - var lang = window.localStorage.getItem("preferred-spring-language"); - if (SPRING_LANGUAGES.indexOf(lang) === -1) { - window.localStorage.setItem("preferred-spring-language", SPRING_LANGUAGES[0]); - lang = SPRING_LANGUAGES[0]; - } - return lang; - } - - function switchItem(text, index) { - if (SPRING_LANGUAGES.indexOf(text) !== -1) { - window.localStorage.setItem("preferred-spring-language", text); - } - $(".switch--item").filter(function() { return ($(this).text() === text) }).each(function() { - $(this).addClass('selected'); - $(this).siblings().removeClass('selected'); - var selectedContent = $(this).parent().siblings(".content").eq(index) - selectedContent.removeClass('hidden'); - selectedContent.siblings().addClass('hidden'); - }); - } - - $('.switch--item').each(function() { - $(this).off('click'); - $(this).on('click', function() { - var selectedText = $(this).text() - var selectedIndex = $(this).index() - switchItem(selectedText, selectedIndex); - }); - }); - - var languageIndex = SPRING_LANGUAGES.indexOf(preferredLanguage); - if (languageIndex != 0) { - switchItem(preferredLanguage, languageIndex); - } -} - -$(globalSwitch); \ No newline at end of file From a03a116f6bd4c6ffa03265eeb3bbd4d7e7a9749d Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Fri, 7 Feb 2020 14:13:15 +0100 Subject: [PATCH 0412/2315] Force TokenBuffer to use BigDecimal if elementtype This commit makes the Jackson2Tokenizer enable TokenBuffer.forceUseOfBigDecimal if the element type given to the Decoder is BigDecimal. Previous to this commit, values would be converted to floats. Closes gh-24479 --- .../http/codec/json/AbstractJackson2Decoder.java | 12 ++++++++++-- .../http/codec/json/Jackson2Tokenizer.java | 7 ++++--- .../http/codec/json/Jackson2JsonDecoderTests.java | 13 ++++++++++++- .../http/codec/json/Jackson2TokenizerTests.java | 13 ++++++------- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java index 74cdbe42f544..7aae80928862 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java @@ -18,10 +18,12 @@ import java.io.IOException; import java.lang.annotation.Annotation; +import java.math.BigDecimal; import java.util.List; import java.util.Map; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; @@ -106,8 +108,14 @@ public Flux decode(Publisher input, ResolvableType elementTy @Nullable MimeType mimeType, @Nullable Map hints) { ObjectMapper mapper = getObjectMapper(); - Flux tokens = Jackson2Tokenizer.tokenize( - Flux.from(input), mapper.getFactory(), mapper, true, getMaxInMemorySize()); + + boolean forceUseOfBigDecimal = mapper.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS); + if (elementType != null && BigDecimal.class.equals(elementType.getType())) { + forceUseOfBigDecimal = true; + } + + Flux tokens = Jackson2Tokenizer.tokenize(Flux.from(input), mapper.getFactory(), mapper, + true, forceUseOfBigDecimal, getMaxInMemorySize()); ObjectReader reader = getObjectReader(elementType, hints); diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java index fd31bee84f7e..ff614066233b 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java @@ -27,7 +27,6 @@ import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.async.ByteArrayFeeder; import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.deser.DefaultDeserializationContext; import com.fasterxml.jackson.databind.util.TokenBuffer; @@ -234,10 +233,13 @@ private void raiseLimitException() { * @param objectMapper the current mapper instance * @param tokenizeArrays if {@code true} and the "top level" JSON object is * an array, each element is returned individually immediately after it is received + * @param forceUseOfBigDecimal if {@code true}, any floating point values encountered in source will use + * {@link java.math.BigDecimal} + * @param maxInMemorySize maximum memory size * @return the resulting token buffers */ public static Flux tokenize(Flux dataBuffers, JsonFactory jsonFactory, - ObjectMapper objectMapper, boolean tokenizeArrays, int maxInMemorySize) { + ObjectMapper objectMapper, boolean tokenizeArrays, boolean forceUseOfBigDecimal, int maxInMemorySize) { try { JsonParser parser = jsonFactory.createNonBlockingByteArrayParser(); @@ -246,7 +248,6 @@ public static Flux tokenize(Flux dataBuffers, JsonFacto context = ((DefaultDeserializationContext) context).createInstance( objectMapper.getDeserializationConfig(), parser, objectMapper.getInjectableValues()); } - boolean forceUseOfBigDecimal = objectMapper.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS); Jackson2Tokenizer tokenizer = new Jackson2Tokenizer(parser, context, tokenizeArrays, forceUseOfBigDecimal, maxInMemorySize); return dataBuffers.concatMapIterable(tokenizer::tokenize).concatWith(tokenizer.endOfInput()); diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java index dd2ba1334b27..a69c5bab3a45 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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,6 +17,7 @@ package org.springframework.http.codec.json; import java.io.IOException; +import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; @@ -205,6 +206,16 @@ public void customDeserializer() { ); } + @Test + public void bigDecimalFlux() { + Flux input = stringBuffer("[ 1E+2 ]").flux(); + + testDecode(input, BigDecimal.class, step -> step + .expectNext(new BigDecimal("1E+2")) + .verifyComplete() + ); + } + private Mono stringBuffer(String value) { return Mono.defer(() -> { byte[] bytes = value.getBytes(StandardCharsets.UTF_8); diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java index 5af6a0d3b83e..501e9b4bbffb 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java @@ -25,7 +25,6 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.TreeNode; -import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.util.TokenBuffer; import org.json.JSONException; @@ -249,7 +248,8 @@ public void testLimitTokenized() { public void errorInStream() { DataBuffer buffer = stringBuffer("{\"id\":1,\"name\":"); Flux source = Flux.just(buffer).concatWith(Flux.error(new RuntimeException())); - Flux result = Jackson2Tokenizer.tokenize(source, this.jsonFactory, this.objectMapper, true, -1); + Flux result = Jackson2Tokenizer.tokenize(source, this.jsonFactory, this.objectMapper, true, + false, -1); StepVerifier.create(result) .expectError(RuntimeException.class) @@ -259,7 +259,8 @@ public void errorInStream() { @Test // SPR-16521 public void jsonEOFExceptionIsWrappedAsDecodingError() { Flux source = Flux.just(stringBuffer("{\"status\": \"noClosingQuote}")); - Flux tokens = Jackson2Tokenizer.tokenize(source, this.jsonFactory, this.objectMapper, false, -1); + Flux tokens = Jackson2Tokenizer.tokenize(source, this.jsonFactory, this.objectMapper, false, + false, -1); StepVerifier.create(tokens) .expectError(DecodingException.class) @@ -269,10 +270,8 @@ public void jsonEOFExceptionIsWrappedAsDecodingError() { @ParameterizedTest @ValueSource(booleans = {false, true}) public void useBigDecimalForFloats(boolean useBigDecimalForFloats) { - this.objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, useBigDecimalForFloats); - Flux source = Flux.just(stringBuffer("1E+2")); - Flux tokens = Jackson2Tokenizer.tokenize(source, this.jsonFactory, this.objectMapper, false, -1); + Flux tokens = Jackson2Tokenizer.tokenize(source, this.jsonFactory, this.objectMapper, false, useBigDecimalForFloats, -1); StepVerifier.create(tokens) .assertNext(tokenBuffer -> { @@ -299,7 +298,7 @@ private Flux decode(List source, boolean tokenize, int maxInMemo Flux tokens = Jackson2Tokenizer.tokenize( Flux.fromIterable(source).map(this::stringBuffer), - this.jsonFactory, this.objectMapper, tokenize, maxInMemorySize); + this.jsonFactory, this.objectMapper, tokenize, false, maxInMemorySize); return tokens .map(tokenBuffer -> { From df706f4c7cc2c577f44ddf02019dca98fccf5a72 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 7 Feb 2020 21:44:44 +0000 Subject: [PATCH 0413/2315] Restore use of Flux-based encode method in HTTP Closes gh-24441 --- .../springframework/core/codec/Decoder.java | 8 +-- .../springframework/core/codec/Encoder.java | 8 +-- .../http/codec/EncoderHttpMessageWriter.java | 16 +++--- .../ServerSentEventHttpMessageWriter.java | 57 +++++++++---------- .../codec/EncoderHttpMessageWriterTests.java | 4 +- 5 files changed, 45 insertions(+), 48 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/codec/Decoder.java b/spring-core/src/main/java/org/springframework/core/codec/Decoder.java index 219e813f028e..5fd981d6ac66 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/Decoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/Decoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -78,9 +78,9 @@ Mono decodeToMono(Publisher inputStream, ResolvableType elementTy @Nullable MimeType mimeType, @Nullable Map hints); /** - * Decode a data buffer to an Object of type T. This is useful when the input - * stream consists of discrete messages (or events) and the content for each - * can be decoded on its own. + * Decode a data buffer to an Object of type T. This is useful for scenarios, + * that distinct messages (or events) are decoded and handled individually, + * in fully aggregated form. * @param buffer the {@code DataBuffer} to decode * @param targetType the expected output type * @param mimeType the MIME type associated with the data diff --git a/spring-core/src/main/java/org/springframework/core/codec/Encoder.java b/spring-core/src/main/java/org/springframework/core/codec/Encoder.java index 00f42009ae0b..aa4f5d8aff3b 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/Encoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/Encoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -68,9 +68,9 @@ Flux encode(Publisher inputStream, DataBufferFactory bu ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map hints); /** - * Encode an Object of type T to a data buffer. This is useful for scenarios - * that produce a stream of discrete messages (or events) and the - * content for each is encoded individually. + * Encode an Object of type T to a data buffer. This is useful for scenarios, + * that distinct messages (or events) are encoded and handled individually, + * in fully aggregated form. *

    By default this method raises {@link UnsupportedOperationException} * and it is expected that some encoders cannot produce a single buffer or * cannot do so synchronously (e.g. encoding a {@code Resource}). diff --git a/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java index bd6c98ba6403..a5ed28274175 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -29,7 +29,6 @@ import org.springframework.core.codec.Encoder; import org.springframework.core.codec.Hints; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.PooledDataBuffer; import org.springframework.http.HttpLogging; import org.springframework.http.MediaType; @@ -114,24 +113,23 @@ public Mono write(Publisher inputStream, ResolvableType eleme MediaType contentType = updateContentType(message, mediaType); + Flux body = this.encoder.encode( + inputStream, message.bufferFactory(), elementType, contentType, hints); + if (inputStream instanceof Mono) { - return Mono.from(inputStream) + return body + .singleOrEmpty() .switchIfEmpty(Mono.defer(() -> { message.getHeaders().setContentLength(0); return message.setComplete().then(Mono.empty()); })) - .flatMap(value -> { - DataBufferFactory factory = message.bufferFactory(); - DataBuffer buffer = this.encoder.encodeValue(value, factory, elementType, contentType, hints); + .flatMap(buffer -> { message.getHeaders().setContentLength(buffer.readableByteCount()); return message.writeWith(Mono.just(buffer) .doOnDiscard(PooledDataBuffer.class, PooledDataBuffer::release)); }); } - Flux body = this.encoder.encode( - inputStream, message.bufferFactory(), elementType, contentType, hints); - if (isStreamingMediaType(contentType)) { return message.writeAndFlushWith(body.map(buffer -> Mono.just(buffer).doOnDiscard(PooledDataBuffer.class, PooledDataBuffer::release))); diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java index 3840bae3082e..aeb536cd6c41 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -18,7 +18,7 @@ import java.nio.charset.StandardCharsets; import java.time.Duration; -import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -112,7 +112,7 @@ public Mono write(Publisher input, ResolvableType elementType, @Nullabl } private Flux> encode(Publisher input, ResolvableType elementType, - MediaType mediaType, DataBufferFactory bufferFactory, Map hints) { + MediaType mediaType, DataBufferFactory factory, Map hints) { ResolvableType dataType = (ServerSentEvent.class.isAssignableFrom(elementType.toClass()) ? elementType.getGeneric() : elementType); @@ -144,13 +144,35 @@ private Flux> encode(Publisher input, ResolvableType el sb.append("data:"); } - Mono bufferMono = Mono.fromCallable(() -> - bufferFactory.join(encodeEvent(sb, data, dataType, mediaType, bufferFactory, hints))); + Flux result; + if (data == null) { + result = Flux.just(encodeText(sb + "\n", mediaType, factory)); + } + else if (data instanceof String) { + data = StringUtils.replace((String) data, "\n", "\ndata:"); + result = Flux.just(encodeText(sb + (String) data + "\n\n", mediaType, factory)); + } + else { + result = encodeEvent(sb.toString(), data, dataType, mediaType, factory, hints); + } - return bufferMono.doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release); + return result.doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release); }); } + @SuppressWarnings("unchecked") + private Flux encodeEvent(String eventContent, T data, ResolvableType dataType, + MediaType mediaType, DataBufferFactory factory, Map hints) { + + if (this.encoder == null) { + throw new CodecException("No SSE encoder configured and the data is not String."); + } + return Flux.just(factory.join(Arrays.asList( + encodeText(eventContent, mediaType, factory), + ((Encoder) this.encoder).encodeValue(data, factory, dataType, mediaType, hints), + encodeText("\n\n", mediaType, factory)))); + } + private void writeField(String fieldName, Object fieldValue, StringBuilder sb) { sb.append(fieldName); sb.append(':'); @@ -158,29 +180,6 @@ private void writeField(String fieldName, Object fieldValue, StringBuilder sb) { sb.append("\n"); } - @SuppressWarnings("unchecked") - private List encodeEvent(CharSequence markup, @Nullable T data, ResolvableType dataType, - MediaType mediaType, DataBufferFactory factory, Map hints) { - - List result = new ArrayList<>(4); - result.add(encodeText(markup, mediaType, factory)); - if (data != null) { - if (data instanceof String) { - String dataLine = StringUtils.replace((String) data, "\n", "\ndata:") + "\n"; - result.add(encodeText(dataLine, mediaType, factory)); - } - else if (this.encoder == null) { - throw new CodecException("No SSE encoder configured and the data is not String."); - } - else { - result.add(((Encoder) this.encoder).encodeValue(data, factory, dataType, mediaType, hints)); - result.add(encodeText("\n", mediaType, factory)); - } - } - result.add(encodeText("\n", mediaType, factory)); - return result; - } - private DataBuffer encodeText(CharSequence text, MediaType mediaType, DataBufferFactory bufferFactory) { Assert.notNull(mediaType.getCharset(), "Expected MediaType with charset"); byte[] bytes = text.toString().getBytes(mediaType.getCharset()); diff --git a/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java index c7133f3f28e4..39e831b5fcc2 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -157,7 +157,7 @@ void useHttpOutputMessageMediaType() { void setContentLengthForMonoBody() { DefaultDataBufferFactory factory = new DefaultDataBufferFactory(); DataBuffer buffer = factory.wrap("body".getBytes(StandardCharsets.UTF_8)); - configureEncoder(buffer, MimeTypeUtils.TEXT_PLAIN); + configureEncoder(Flux.just(buffer), MimeTypeUtils.TEXT_PLAIN); HttpMessageWriter writer = new EncoderHttpMessageWriter<>(this.encoder); writer.write(Mono.just("body"), forClass(String.class), TEXT_PLAIN, this.response, NO_HINTS).block(); From 009dfbfafc35ffdcb308bb30f5c3fddb1cbd727b Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 10 Feb 2020 15:01:47 +0000 Subject: [PATCH 0414/2315] MockRestServiceServer clears failed requests map Closes gh-24486 --- .../AbstractRequestExpectationManager.java | 3 +- .../client/MockRestServiceServerTests.java | 32 +++++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/client/AbstractRequestExpectationManager.java b/spring-test/src/main/java/org/springframework/test/web/client/AbstractRequestExpectationManager.java index a70b9488600e..23de6e133b11 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/AbstractRequestExpectationManager.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/AbstractRequestExpectationManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -199,6 +199,7 @@ protected AssertionError createUnexpectedRequestError(ClientHttpRequest request) public void reset() { this.expectations.clear(); this.requests.clear(); + this.requestFailures.clear(); } diff --git a/spring-test/src/test/java/org/springframework/test/web/client/MockRestServiceServerTests.java b/spring-test/src/test/java/org/springframework/test/web/client/MockRestServiceServerTests.java index ff556a2be182..14f62fee21b7 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/MockRestServiceServerTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/MockRestServiceServerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -117,6 +117,24 @@ public void resetAndReuseServerWithUnorderedExpectationManager() { server.verify(); } + @Test // gh-24486 + public void resetClearsRequestFailures() { + MockRestServiceServer server = MockRestServiceServer.bindTo(this.restTemplate).build(); + server.expect(once(), requestTo("/remoteurl")).andRespond(withSuccess()); + this.restTemplate.postForEntity("/remoteurl", null, String.class); + server.verify(); + + assertThatExceptionOfType(AssertionError.class) + .isThrownBy(() -> this.restTemplate.postForEntity("/remoteurl", null, String.class)) + .withMessageStartingWith("No further requests expected"); + + server.reset(); + + server.expect(once(), requestTo("/remoteurl")).andRespond(withSuccess()); + this.restTemplate.postForEntity("/remoteurl", null, String.class); + server.verify(); + } + @Test // SPR-16132 public void followUpRequestAfterFailure() { MockRestServiceServer server = MockRestServiceServer.bindTo(this.restTemplate).build(); @@ -144,13 +162,13 @@ public void verifyShouldFailIfRequestsFailed() { server.expect(once(), requestTo("/remoteurl")).andRespond(withSuccess()); this.restTemplate.postForEntity("/remoteurl", null, String.class); - assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> - this.restTemplate.postForEntity("/remoteurl", null, String.class)) - .withMessageStartingWith("No further requests expected"); + assertThatExceptionOfType(AssertionError.class) + .isThrownBy(() -> this.restTemplate.postForEntity("/remoteurl", null, String.class)) + .withMessageStartingWith("No further requests expected"); - assertThatExceptionOfType(AssertionError.class).isThrownBy( - server::verify) - .withMessageStartingWith("Some requests did not execute successfully"); + assertThatExceptionOfType(AssertionError.class) + .isThrownBy(server::verify) + .withMessageStartingWith("Some requests did not execute successfully"); } } From d521d37f14f03688a17b6657df30ff533f2d5f9f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 10 Feb 2020 18:10:41 +0100 Subject: [PATCH 0415/2315] Upgrade to Hibernate ORM 5.4.11 and Groovy 3.0 final --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index e597ed582e03..bdc9543026de 100644 --- a/build.gradle +++ b/build.gradle @@ -61,7 +61,7 @@ configure(allprojects) { project -> entry 'aspectjweaver' } // If customJavaHome has been set, we assume we need Groovy 3.0 for testing purposes. - dependencySet(group: 'org.codehaus.groovy', version: System.getProperty("customJavaHome") ? '3.0.0-rc-3' : '2.5.9') { + dependencySet(group: 'org.codehaus.groovy', version: System.getProperty("customJavaHome") ? '3.0.0' : '2.5.9') { entry 'groovy' entry 'groovy-jsr223' entry 'groovy-templates' @@ -125,7 +125,7 @@ configure(allprojects) { project -> dependency "net.sf.ehcache:ehcache:2.10.6" dependency "org.ehcache:jcache:1.0.1" dependency "org.ehcache:ehcache:3.4.0" - dependency "org.hibernate:hibernate-core:5.4.10.Final" + dependency "org.hibernate:hibernate-core:5.4.11.Final" dependency "org.hibernate:hibernate-validator:6.1.2.Final" dependency "org.webjars:webjars-locator-core:0.43" dependency "org.webjars:underscorejs:1.8.3" From e4a530efac8955151dedec67e1916b0321462699 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 11 Feb 2020 10:39:35 +0000 Subject: [PATCH 0416/2315] Minor refactoring in CommonsLogWriter Closes gh-24495 --- .../org/springframework/util/CommonsLogWriter.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/CommonsLogWriter.java b/spring-core/src/main/java/org/springframework/util/CommonsLogWriter.java index 30800b90d87b..c3c5744e8d1e 100644 --- a/spring-core/src/main/java/org/springframework/util/CommonsLogWriter.java +++ b/spring-core/src/main/java/org/springframework/util/CommonsLogWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -56,14 +56,7 @@ public void write(char ch) { @Override public void write(char[] buffer, int offset, int length) { for (int i = 0; i < length; i++) { - char ch = buffer[offset + i]; - if (ch == '\n' && this.buffer.length() > 0) { - logger.debug(this.buffer.toString()); - this.buffer.setLength(0); - } - else { - this.buffer.append(ch); - } + write(buffer[offset + i]); } } From 7d1d9895351091a390cc54ea5fed24d8ec51611a Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 11 Feb 2020 10:49:28 +0000 Subject: [PATCH 0417/2315] Minor polishing in ConcurrentReferenceHashMap Closes gh-24494 --- .../springframework/util/ConcurrentReferenceHashMap.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java index bb8dc01f5710..ea9960441d86 100644 --- a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java +++ b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -329,7 +329,7 @@ protected Boolean execute(@Nullable Reference ref, @Nullable Entry e return false; } }); - return (result == Boolean.TRUE); + return (Boolean.TRUE.equals(result)); } @Override @@ -344,7 +344,7 @@ protected Boolean execute(@Nullable Reference ref, @Nullable Entry e return false; } }); - return (result == Boolean.TRUE); + return (Boolean.TRUE.equals(result)); } @Override From 28a95e89f35600199ee1254dee9e8ed53f958bcc Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 11 Feb 2020 12:51:35 +0000 Subject: [PATCH 0418/2315] Upgrade to Dysprosium SR5 snapshots See gh-24355 --- build.gradle | 3 +- .../core/codec/StringDecoder.java | 70 +++++-------------- .../core/codec/StringDecoderTests.java | 9 ++- .../tcp/reactor/ReactorNettyTcpClient.java | 8 ++- .../reactive/ReactorResourceFactory.java | 1 + .../ErrorHandlerIntegrationTests.java | 8 +-- .../ReactorNettyRequestUpgradeStrategy.java | 1 + 7 files changed, 35 insertions(+), 65 deletions(-) diff --git a/build.gradle b/build.gradle index bdc9543026de..201220ee29f7 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ configure(allprojects) { project -> imports { mavenBom "com.fasterxml.jackson:jackson-bom:2.10.2" mavenBom "io.netty:netty-bom:4.1.45.Final" - mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR4" + mavenBom "io.projectreactor:reactor-bom:Dysprosium-BUILD-SNAPSHOT" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC6" mavenBom "org.eclipse.jetty:jetty-bom:9.4.26.v20200117" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.61" @@ -289,6 +289,7 @@ configure(allprojects) { project -> repositories { mavenCentral() maven { url "https://repo.spring.io/libs-spring-framework-build" } + maven { url "https://repo.spring.io/snapshot" } // Reactor Dysprosium snapshots } } configurations.all { diff --git a/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java b/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java index abbe66a3b3b0..e36345de02a5 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java @@ -32,7 +32,6 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.io.buffer.DataBufferLimitException; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DataBufferWrapper; import org.springframework.core.io.buffer.DefaultDataBufferFactory; @@ -96,42 +95,25 @@ public Flux decode(Publisher input, ResolvableType elementTy Flux inputFlux = Flux.defer(() -> { DataBufferUtils.Matcher matcher = DataBufferUtils.matcher(delimiterBytes); - if (getMaxInMemorySize() != -1) { - - // Passing limiter into endFrameAfterDelimiter helps to ensure that in case of one DataBuffer - // containing multiple lines, the limit is checked and raised immediately without accumulating - // subsequent lines. This is necessary because concatMapIterable doesn't respect doOnDiscard. - // When reactor-core#1925 is resolved, we could replace bufferUntil with: - - // .windowUntil(buffer -> buffer instanceof EndFrameBuffer) - // .concatMap(fluxes -> fluxes.collect(() -> new LimitedDataBufferList(getMaxInMemorySize()), LimitedDataBufferList::add)) - LimitedDataBufferList limiter = new LimitedDataBufferList(getMaxInMemorySize()); + Flux buffers = Flux.from(input) + .concatMapIterable(buffer -> endFrameAfterDelimiter(buffer, matcher)); - return Flux.from(input) - .concatMapIterable(buffer -> endFrameAfterDelimiter(buffer, matcher, limiter)) - .bufferUntil(buffer -> buffer instanceof EndFrameBuffer) - .map(buffers -> joinAndStrip(buffers, this.stripDelimiter)) - .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release); + Flux> delimitedBuffers; + if (getMaxInMemorySize() != -1) { + delimitedBuffers = buffers + .windowUntil(buffer -> buffer instanceof EndFrameBuffer) + .concatMap(window -> window.collect( + () -> new LimitedDataBufferList(getMaxInMemorySize()), + LimitedDataBufferList::add)); } else { - - // When the decoder is unlimited (-1), concatMapIterable will cache buffers that may not - // be released if cancel is signalled before they are turned into String lines - // (see test maxInMemoryLimitReleasesUnprocessedLinesWhenUnlimited). - // When reactor-core#1925 is resolved, the workaround can be removed and the entire - // else clause possibly dropped. - - ConcatMapIterableDiscardWorkaroundCache cache = new ConcatMapIterableDiscardWorkaroundCache(); - - return Flux.from(input) - .concatMapIterable(buffer -> cache.addAll(endFrameAfterDelimiter(buffer, matcher, null))) - .doOnNext(cache) - .doOnCancel(cache) - .bufferUntil(buffer -> buffer instanceof EndFrameBuffer) - .map(buffers -> joinAndStrip(buffers, this.stripDelimiter)) - .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release); + delimitedBuffers = buffers.bufferUntil(buffer -> buffer instanceof EndFrameBuffer); } + + return delimitedBuffers + .map(list -> joinAndStrip(list, this.stripDelimiter)) + .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release); }); return super.decode(inputFlux, elementType, mimeType, hints); @@ -176,14 +158,11 @@ private static Charset getCharset(@Nullable MimeType mimeType) { * * @param dataBuffer the buffer to find delimiters in * @param matcher used to find the first delimiters - * @param limiter to enforce maxInMemorySize with * @return a flux of buffers, containing {@link EndFrameBuffer} after each delimiter that was * found in {@code dataBuffer}. Returns Flux, because returning List (w/ flatMapIterable) * results in memory leaks due to pre-fetching. */ - private static List endFrameAfterDelimiter( - DataBuffer dataBuffer, DataBufferUtils.Matcher matcher, @Nullable LimitedDataBufferList limiter) { - + private static List endFrameAfterDelimiter(DataBuffer dataBuffer, DataBufferUtils.Matcher matcher) { List result = new ArrayList<>(); try { do { @@ -195,27 +174,14 @@ private static List endFrameAfterDelimiter( result.add(slice); result.add(new EndFrameBuffer(matcher.delimiter())); dataBuffer.readPosition(endIdx + 1); - if (limiter != null) { - limiter.add(slice); // enforce the limit - limiter.clear(); - } } else { result.add(DataBufferUtils.retain(dataBuffer)); - if (limiter != null) { - limiter.add(dataBuffer); - } break; } } while (dataBuffer.readableByteCount() > 0); } - catch (DataBufferLimitException ex) { - if (limiter != null) { - limiter.releaseAndClear(); - } - throw ex; - } finally { DataBufferUtils.release(dataBuffer); } @@ -230,9 +196,7 @@ private static List endFrameAfterDelimiter( * @param stripDelimiter whether to strip the delimiter * @return the joined buffer */ - private static DataBuffer joinAndStrip(List dataBuffers, - boolean stripDelimiter) { - + private static DataBuffer joinAndStrip(List dataBuffers, boolean stripDelimiter) { Assert.state(!dataBuffers.isEmpty(), "DataBuffers should not be empty"); byte[] matchingDelimiter = null; @@ -241,7 +205,7 @@ private static DataBuffer joinAndStrip(List dataBuffers, DataBuffer lastBuffer = dataBuffers.get(lastIdx); if (lastBuffer instanceof EndFrameBuffer) { matchingDelimiter = ((EndFrameBuffer) lastBuffer).delimiter(); - dataBuffers.remove(lastIdx); + dataBuffers = dataBuffers.subList(0, lastIdx); } DataBuffer result = dataBuffers.get(0).factory().join(dataBuffers); diff --git a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java index fad7a1ec102c..7057c52865bb 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java @@ -75,7 +75,14 @@ public void decode() { String s = String.format("%s\n%s\n%s", u, e, o); Flux input = toDataBuffers(s, 1, UTF_8); - testDecodeAll(input, TYPE, step -> step.expectNext(u, e, o).verifyComplete(), null, null); + // TODO: temporarily replace testDecodeAll with explicit decode/cancel/empty + // see https://github.com/reactor/reactor-core/issues/2041 + + testDecode(input, TYPE, step -> step.expectNext(u, e, o).verifyComplete(), null, null); + testDecodeCancel(input, TYPE, null, null); + testDecodeEmpty(TYPE, null, null); + + // testDecodeAll(input, TYPE, step -> step.expectNext(u, e, o).verifyComplete(), null, null); } @Test diff --git a/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/ReactorNettyTcpClient.java b/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/ReactorNettyTcpClient.java index 078ec12c1ea4..d7489158fab5 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/ReactorNettyTcpClient.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/ReactorNettyTcpClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -103,13 +103,14 @@ public class ReactorNettyTcpClient

    implements TcpOperations

    { * @param codec for encoding and decoding the input/output byte streams * @see org.springframework.messaging.simp.stomp.StompReactorNettyCodec */ + @SuppressWarnings("deprecation") public ReactorNettyTcpClient(String host, int port, ReactorNettyCodec

    codec) { Assert.notNull(host, "host is required"); Assert.notNull(codec, "ReactorNettyCodec is required"); this.channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE); this.loopResources = LoopResources.create("tcp-client-loop"); - this.poolResources = ConnectionProvider.elastic("tcp-client-pool"); + this.poolResources = ConnectionProvider.fixed("tcp-client-pool", 10000); this.codec = codec; this.tcpClient = TcpClient.create(this.poolResources) @@ -128,12 +129,13 @@ public ReactorNettyTcpClient(String host, int port, ReactorNettyCodec

    codec) * @since 5.1.3 * @see org.springframework.messaging.simp.stomp.StompReactorNettyCodec */ + @SuppressWarnings("deprecation") public ReactorNettyTcpClient(Function clientConfigurer, ReactorNettyCodec

    codec) { Assert.notNull(codec, "ReactorNettyCodec is required"); this.channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE); this.loopResources = LoopResources.create("tcp-client-loop"); - this.poolResources = ConnectionProvider.elastic("tcp-client-pool"); + this.poolResources = ConnectionProvider.fixed("tcp-client-pool", 10000); this.codec = codec; this.tcpClient = clientConfigurer.apply(TcpClient diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java index 8e696504b4f0..46d1f57c602d 100644 --- a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java +++ b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java @@ -46,6 +46,7 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean @Nullable private Consumer globalResourcesConsumer; + @SuppressWarnings("deprecation") private Supplier connectionProviderSupplier = () -> ConnectionProvider.fixed("webflux", 500); private Supplier loopResourcesSupplier = () -> LoopResources.create("webflux-http"); diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java index c7a925b47201..44bbd00a296e 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -18,7 +18,6 @@ import java.net.URI; -import org.junit.jupiter.api.Assumptions; import reactor.core.publisher.Mono; import org.springframework.http.HttpStatus; @@ -28,7 +27,6 @@ import org.springframework.web.client.RestTemplate; import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; -import org.springframework.web.testfixture.http.server.reactive.bootstrap.ReactorHttpServer; import static org.assertj.core.api.Assertions.assertThat; @@ -74,10 +72,6 @@ void handlingError(HttpServer httpServer) throws Exception { @ParameterizedHttpServerTest // SPR-15560 void emptyPathSegments(HttpServer httpServer) throws Exception { - - /* Temporarily necessary for https://github.com/reactor/reactor-netty/issues/948 */ - Assumptions.assumeFalse(httpServer instanceof ReactorHttpServer); - startServer(httpServer); RestTemplate restTemplate = new RestTemplate(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java index afd8315f6cbf..f7d6575b104f 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java @@ -95,6 +95,7 @@ public boolean getHandlePing() { @Override + @SuppressWarnings("deprecation") public Mono upgrade(ServerWebExchange exchange, WebSocketHandler handler, @Nullable String subProtocol, Supplier handshakeInfoFactory) { From 0a974511bd4826136f0a6e8be3d326587314a229 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 11 Feb 2020 13:42:47 +0000 Subject: [PATCH 0419/2315] Expose awaitTerminationMillis presion Closes gh-24496 --- .../ExecutorConfigurationSupport.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java index 85351467846f..2a2fbdccab9c 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -59,7 +59,7 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac private boolean waitForTasksToCompleteOnShutdown = false; - private int awaitTerminationSeconds = 0; + private long awaitTerminationMillis = 0; @Nullable private String beanName; @@ -145,9 +145,20 @@ public void setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnS * @see java.util.concurrent.ExecutorService#awaitTermination */ public void setAwaitTerminationSeconds(int awaitTerminationSeconds) { - this.awaitTerminationSeconds = awaitTerminationSeconds; + this.awaitTerminationMillis = awaitTerminationSeconds * 1000; } + /** + * Variant of {@link #setAwaitTerminationSeconds} with millisecond precision. + * @since 5.2.4 + * @see java.util.concurrent.ExecutorService#shutdown() + * @see java.util.concurrent.ExecutorService#awaitTermination + */ + public void setAwaitTerminationMillis(long awaitTerminationMillis) { + this.awaitTerminationMillis = awaitTerminationMillis; + } + + @Override public void setBeanName(String name) { this.beanName = name; @@ -239,9 +250,9 @@ protected void cancelRemainingTask(Runnable task) { * {@link #setAwaitTerminationSeconds "awaitTerminationSeconds"} property. */ private void awaitTerminationIfNecessary(ExecutorService executor) { - if (this.awaitTerminationSeconds > 0) { + if (this.awaitTerminationMillis > 0) { try { - if (!executor.awaitTermination(this.awaitTerminationSeconds, TimeUnit.SECONDS)) { + if (!executor.awaitTermination(this.awaitTerminationMillis, TimeUnit.MILLISECONDS)) { if (logger.isWarnEnabled()) { logger.warn("Timed out while waiting for executor" + (this.beanName != null ? " '" + this.beanName + "'" : "") + " to terminate"); From e35d3b8bb55245b29b0b243079dee73b312d504d Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 11 Feb 2020 14:01:21 +0000 Subject: [PATCH 0420/2315] Update advice on RestTemplate Closes gh-24503 --- .../springframework/web/client/RestTemplate.java | 13 +++++-------- src/docs/asciidoc/integration.adoc | 8 ++++---- src/docs/asciidoc/web/webmvc-client.adoc | 10 ++++------ 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java index 9ccd5e4dd731..edba0711c97f 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -72,13 +72,10 @@ * addition to the generalized {@code exchange} and {@code execute} methods that * support of less frequent cases. * - *

    NOTE: As of 5.0, the non-blocking, reactive - * {@code org.springframework.web.reactive.client.WebClient} offers a - * modern alternative to the {@code RestTemplate} with efficient support for - * both sync and async, as well as streaming scenarios. The {@code RestTemplate} - * will be deprecated in a future version and will not have major new features - * added going forward. See the WebClient section of the Spring Framework reference - * documentation for more details and example code. + *

    NOTE: As of 5.0 this class is in maintenance mode, with + * only minor requests for changes and bugs to be accepted going forward. Please, + * consider using the {@code org.springframework.web.reactive.client.WebClient} + * which has a more modern API and supports sync, async, and streaming scenarios. * * @author Arjen Poutsma * @author Brian Clozel diff --git a/src/docs/asciidoc/integration.adoc b/src/docs/asciidoc/integration.adoc index 3d5c0534d3d0..b1da44a06ddb 100644 --- a/src/docs/asciidoc/integration.adoc +++ b/src/docs/asciidoc/integration.adoc @@ -920,10 +920,10 @@ method API. * <>: a non-blocking, reactive alternative that supports both synchronous and asynchronous as well as streaming scenarios. -NOTE: As of 5.0, the non-blocking, reactive `WebClient` offers a modern alternative to the -`RestTemplate` with efficient support for both synchronous and asynchronous as well as streaming -scenarios. The `RestTemplate` will be deprecated in a future version and will not have -major new features added going forward. +NOTE: As of 5.0 the `RestTemplate` is in maintenance mode, with only minor requests for +changes and bugs to be accepted going forward. Please, consider using the +<> which offers a more modern API and +supports sync, async, and streaming scenarios. [[rest-resttemplate]] diff --git a/src/docs/asciidoc/web/webmvc-client.adoc b/src/docs/asciidoc/web/webmvc-client.adoc index b1184ee030fe..147344c78d66 100644 --- a/src/docs/asciidoc/web/webmvc-client.adoc +++ b/src/docs/asciidoc/web/webmvc-client.adoc @@ -13,12 +13,10 @@ This section describes options for client-side access to REST endpoints. Spring REST client and exposes a simple, template-method API over underlying HTTP client libraries. -NOTE: As of 5.0, the non-blocking, reactive `WebClient` offers a modern alternative to the -`RestTemplate`, with efficient support for both -<>, as well as -streaming scenarios. The `RestTemplate` will be deprecated in a future version and will -not have major new features added going forward. - +NOTE: As of 5.0 the `RestTemplate` is in maintenance mode, with only minor requests for +changes and bugs to be accepted going forward. Please, consider using the +<> which offers a more modern API and +supports sync, async, and streaming scenarios. See <> for details. From d55210551612e7ded3a068818ebc76a1e151bab3 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 11 Feb 2020 16:49:21 +0000 Subject: [PATCH 0421/2315] Eliminate windowUntil from StringDecoder This is a follow-up on the earlier commit 28a95e89f35600199ee1254dee9e8ed53f958bcc eliminating windowUntil entirely which generates a BubblingException wrapper. This also keeps the chain a little simpler. See gh-24355 --- .../core/codec/StringDecoder.java | 59 ++++++++----------- .../core/io/buffer/DataBufferUtils.java | 3 - .../core/codec/StringDecoderTests.java | 8 +-- 3 files changed, 28 insertions(+), 42 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java b/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java index e36345de02a5..bd6c5c7c0070 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java @@ -32,6 +32,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.io.buffer.DataBufferLimitException; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DataBufferWrapper; import org.springframework.core.io.buffer.DefaultDataBufferFactory; @@ -96,22 +97,13 @@ public Flux decode(Publisher input, ResolvableType elementTy Flux inputFlux = Flux.defer(() -> { DataBufferUtils.Matcher matcher = DataBufferUtils.matcher(delimiterBytes); - Flux buffers = Flux.from(input) - .concatMapIterable(buffer -> endFrameAfterDelimiter(buffer, matcher)); + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") + LimitChecker limiter = new LimitChecker(getMaxInMemorySize()); - Flux> delimitedBuffers; - if (getMaxInMemorySize() != -1) { - delimitedBuffers = buffers - .windowUntil(buffer -> buffer instanceof EndFrameBuffer) - .concatMap(window -> window.collect( - () -> new LimitedDataBufferList(getMaxInMemorySize()), - LimitedDataBufferList::add)); - } - else { - delimitedBuffers = buffers.bufferUntil(buffer -> buffer instanceof EndFrameBuffer); - } - - return delimitedBuffers + return Flux.from(input) + .concatMapIterable(buffer -> endFrameAfterDelimiter(buffer, matcher)) + .doOnNext(limiter) + .bufferUntil(buffer -> buffer instanceof EndFrameBuffer) .map(list -> joinAndStrip(list, this.stripDelimiter)) .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release); }); @@ -205,7 +197,7 @@ private static DataBuffer joinAndStrip(List dataBuffers, boolean str DataBuffer lastBuffer = dataBuffers.get(lastIdx); if (lastBuffer instanceof EndFrameBuffer) { matchingDelimiter = ((EndFrameBuffer) lastBuffer).delimiter(); - dataBuffers = dataBuffers.subList(0, lastIdx); + dataBuffers.remove(lastIdx); } DataBuffer result = dataBuffers.get(0).factory().join(dataBuffers); @@ -296,31 +288,28 @@ public byte[] delimiter() { } - private class ConcatMapIterableDiscardWorkaroundCache implements Consumer, Runnable { + private static class LimitChecker implements Consumer { - private final List buffers = new ArrayList<>(); + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") + private final LimitedDataBufferList list; - public List addAll(List buffersToAdd) { - this.buffers.addAll(buffersToAdd); - return buffersToAdd; - } - - @Override - public void accept(DataBuffer dataBuffer) { - this.buffers.remove(dataBuffer); + LimitChecker(int maxInMemorySize) { + this.list = new LimitedDataBufferList(maxInMemorySize); } @Override - public void run() { - this.buffers.forEach(buffer -> { - try { - DataBufferUtils.release(buffer); - } - catch (Throwable ex) { - // Keep going.. - } - }); + public void accept(DataBuffer buffer) { + if (buffer instanceof EndFrameBuffer) { + this.list.clear(); + } + try { + this.list.add(buffer); + } + catch (DataBufferLimitException ex) { + DataBufferUtils.release(buffer); + throw ex; + } } } diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java index b1beb6f2cbdc..a11c3edcc3ec 100644 --- a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java +++ b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java @@ -547,13 +547,10 @@ public static Mono join(Publisher buffers, int return (Mono) buffers; } - // TODO: Drop doOnDiscard(LimitedDataBufferList.class, ...) (reactor-core#1924) - return Flux.from(buffers) .collect(() -> new LimitedDataBufferList(maxByteCount), LimitedDataBufferList::add) .filter(list -> !list.isEmpty()) .map(list -> list.get(0).factory().join(list)) - .doOnDiscard(LimitedDataBufferList.class, LimitedDataBufferList::releaseAndClear) .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release); } diff --git a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java index 7057c52865bb..b3bcdfe8f7ad 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java @@ -78,11 +78,11 @@ public void decode() { // TODO: temporarily replace testDecodeAll with explicit decode/cancel/empty // see https://github.com/reactor/reactor-core/issues/2041 - testDecode(input, TYPE, step -> step.expectNext(u, e, o).verifyComplete(), null, null); - testDecodeCancel(input, TYPE, null, null); - testDecodeEmpty(TYPE, null, null); +// testDecode(input, TYPE, step -> step.expectNext(u, e, o).verifyComplete(), null, null); +// testDecodeCancel(input, TYPE, null, null); +// testDecodeEmpty(TYPE, null, null); - // testDecodeAll(input, TYPE, step -> step.expectNext(u, e, o).verifyComplete(), null, null); + testDecodeAll(input, TYPE, step -> step.expectNext(u, e, o).verifyComplete(), null, null); } @Test From 9277b470404ce1dce790fa82e684c9d8220940e7 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 11 Feb 2020 16:51:35 +0000 Subject: [PATCH 0422/2315] Polishing: remove use of cast where avoidable --- .../web/server/handler/ExceptionHandlingWebHandler.java | 4 ++-- .../web/server/session/InMemoryWebSessionStore.java | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/server/handler/ExceptionHandlingWebHandler.java b/spring-web/src/main/java/org/springframework/web/server/handler/ExceptionHandlingWebHandler.java index da53f6a3c072..a1e61e1eea63 100644 --- a/spring-web/src/main/java/org/springframework/web/server/handler/ExceptionHandlingWebHandler.java +++ b/spring-web/src/main/java/org/springframework/web/server/handler/ExceptionHandlingWebHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -95,7 +95,7 @@ public Mono handle(ServerWebExchange exchange, Throwable ex) { String query = StringUtils.hasText(rawQuery) ? "?" + rawQuery : ""; HttpMethod httpMethod = request.getMethod(); String description = "HTTP " + httpMethod + " \"" + request.getPath() + query + "\""; - return Mono.error(ex).checkpoint(description + " [ExceptionHandlingWebHandler]").cast(Void.class); + return Mono.error(ex).checkpoint(description + " [ExceptionHandlingWebHandler]"); } } diff --git a/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java b/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java index 09eb47560e0f..825fddbdc573 100644 --- a/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java +++ b/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java @@ -117,9 +117,8 @@ public Mono createWebSession() { Instant now = this.clock.instant(); this.expiredSessionChecker.checkIfNecessary(now); - return Mono.fromSupplier(() -> new InMemoryWebSession(now)) - .subscribeOn(Schedulers.boundedElastic()) - .cast(WebSession.class); + return Mono.fromSupplier(() -> new InMemoryWebSession(now)) + .subscribeOn(Schedulers.boundedElastic()); } @Override From 974cacac31a2e2d7fa784e962b6a66e6e72dfff4 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 19 Jan 2020 16:55:46 +0100 Subject: [PATCH 0423/2315] Support nested annotations in ASM-based processing again Spring Framework 5.0 introduced a regression in ASM-based annotation processing. Specifically, nested annotations were no longer supported, and component scanning resulted in an exception if a candidate component was annotated with an annotation that contained nested annotations. This commit fixes this regression by introducing special handling in AnnotationTypeMapping that supports extracting values from objects of type TypeMappedAnnotation when necessary. Closes gh-24375 --- ...Component.java => AnnotatedComponent.java} | 4 +-- .../{A.java => EnclosingAnnotation.java} | 11 ++++--- .../gh24375/{B.java => NestedAnnotation.java} | 3 +- ...anningCandidateComponentProviderTests.java | 10 +++--- .../annotation/AnnotationTypeMapping.java | 14 +++++--- .../core/annotation/TypeMappedAnnotation.java | 2 +- .../java/example/type/AnnotatedComponent.java | 21 ++++++++++++ .../example/type/EnclosingAnnotation.java | 33 +++++++++++++++++++ .../java/example/type/NestedAnnotation.java | 29 ++++++++++++++++ .../AnnotationTypeMappingsTests.java | 20 ++++++----- .../type/AbstractMethodMetadataTests.java | 11 ++++++- 11 files changed, 130 insertions(+), 28 deletions(-) rename spring-context/src/test/java/example/gh24375/{MyComponent.java => AnnotatedComponent.java} (89%) rename spring-context/src/test/java/example/gh24375/{A.java => EnclosingAnnotation.java} (82%) rename spring-context/src/test/java/example/gh24375/{B.java => NestedAnnotation.java} (96%) create mode 100644 spring-core/src/test/java/example/type/AnnotatedComponent.java create mode 100644 spring-core/src/test/java/example/type/EnclosingAnnotation.java create mode 100644 spring-core/src/test/java/example/type/NestedAnnotation.java diff --git a/spring-context/src/test/java/example/gh24375/MyComponent.java b/spring-context/src/test/java/example/gh24375/AnnotatedComponent.java similarity index 89% rename from spring-context/src/test/java/example/gh24375/MyComponent.java rename to spring-context/src/test/java/example/gh24375/AnnotatedComponent.java index ce21ae567ef9..4eb7fdefb73d 100644 --- a/spring-context/src/test/java/example/gh24375/MyComponent.java +++ b/spring-context/src/test/java/example/gh24375/AnnotatedComponent.java @@ -19,6 +19,6 @@ import org.springframework.stereotype.Component; @Component -@A(other = @B) -public class MyComponent { +@EnclosingAnnotation(nested2 = @NestedAnnotation) +public class AnnotatedComponent { } diff --git a/spring-context/src/test/java/example/gh24375/A.java b/spring-context/src/test/java/example/gh24375/EnclosingAnnotation.java similarity index 82% rename from spring-context/src/test/java/example/gh24375/A.java rename to spring-context/src/test/java/example/gh24375/EnclosingAnnotation.java index a55f3406c247..1a925de59ae1 100644 --- a/spring-context/src/test/java/example/gh24375/A.java +++ b/spring-context/src/test/java/example/gh24375/EnclosingAnnotation.java @@ -25,11 +25,12 @@ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface A { +public @interface EnclosingAnnotation { - @AliasFor("value") - B other() default @B; + @AliasFor("nested2") + NestedAnnotation nested1() default @NestedAnnotation; + + @AliasFor("nested1") + NestedAnnotation nested2() default @NestedAnnotation; - @AliasFor("other") - B value() default @B; } diff --git a/spring-context/src/test/java/example/gh24375/B.java b/spring-context/src/test/java/example/gh24375/NestedAnnotation.java similarity index 96% rename from spring-context/src/test/java/example/gh24375/B.java rename to spring-context/src/test/java/example/gh24375/NestedAnnotation.java index 96f3e9c94aa7..531de72d6bfd 100644 --- a/spring-context/src/test/java/example/gh24375/B.java +++ b/spring-context/src/test/java/example/gh24375/NestedAnnotation.java @@ -23,7 +23,8 @@ @Target(ElementType.ANNOTATION_TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface B { +public @interface NestedAnnotation { String name() default ""; + } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java index 9d46c7d3f162..f4809a51d592 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java @@ -21,7 +21,7 @@ import java.util.Set; import java.util.regex.Pattern; -import example.gh24375.MyComponent; +import example.gh24375.AnnotatedComponent; import example.profilescan.DevComponent; import example.profilescan.ProfileAnnotatedComponent; import example.profilescan.ProfileMetaAnnotatedComponent; @@ -39,7 +39,6 @@ import example.scannable.StubFooDao; import example.scannable.sub.BarComponent; import org.aspectj.lang.annotation.Aspect; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; @@ -503,12 +502,11 @@ public void testIntegrationWithAnnotationConfigApplicationContext_metaProfile() } @Test - @Disabled("Disabled until gh-24375 is resolved") - public void gh24375() { + public void componentScanningFindsComponentsAnnotatedWithAnnotationsContainingNestedAnnotations() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true); - Set components = provider.findCandidateComponents(MyComponent.class.getPackage().getName()); + Set components = provider.findCandidateComponents(AnnotatedComponent.class.getPackage().getName()); assertThat(components).hasSize(1); - assertThat(components.iterator().next().getBeanClassName()).isEqualTo(MyComponent.class.getName()); + assertThat(components.iterator().next().getBeanClassName()).isEqualTo(AnnotatedComponent.class.getName()); } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java index f788127cc7f3..19a3189564af 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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,7 +47,6 @@ */ final class AnnotationTypeMapping { - private static final MirrorSet[] EMPTY_MIRROR_SETS = new MirrorSet[0]; @@ -534,8 +533,15 @@ private static boolean areEquivalent(Annotation annotation, @Nullable Object ext AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType()); for (int i = 0; i < attributes.size(); i++) { Method attribute = attributes.get(i); - if (!areEquivalent(ReflectionUtils.invokeMethod(attribute, annotation), - valueExtractor.apply(attribute, extractedValue), valueExtractor)) { + Object value1 = ReflectionUtils.invokeMethod(attribute, annotation); + Object value2; + if (extractedValue instanceof TypeMappedAnnotation) { + value2 = ((TypeMappedAnnotation) extractedValue).getValue(attribute.getName()).orElse(null); + } + else { + value2 = valueExtractor.apply(attribute, extractedValue); + } + if (!areEquivalent(value1, value2, valueExtractor)) { return false; } } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java index 8975dc3f63ee..cc612a1b9b37 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java @@ -685,7 +685,7 @@ private static TypeMappedAnnotation createIfPossible( @SuppressWarnings("unchecked") @Nullable - private static Object extractFromMap(Method attribute, @Nullable Object map) { + static Object extractFromMap(Method attribute, @Nullable Object map) { return (map != null ? ((Map) map).get(attribute.getName()) : null); } diff --git a/spring-core/src/test/java/example/type/AnnotatedComponent.java b/spring-core/src/test/java/example/type/AnnotatedComponent.java new file mode 100644 index 000000000000..33fab84028ec --- /dev/null +++ b/spring-core/src/test/java/example/type/AnnotatedComponent.java @@ -0,0 +1,21 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package example.type; + +@EnclosingAnnotation(nested2 = @NestedAnnotation) +public class AnnotatedComponent { +} diff --git a/spring-core/src/test/java/example/type/EnclosingAnnotation.java b/spring-core/src/test/java/example/type/EnclosingAnnotation.java new file mode 100644 index 000000000000..8c9bbd25d2cf --- /dev/null +++ b/spring-core/src/test/java/example/type/EnclosingAnnotation.java @@ -0,0 +1,33 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package example.type; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import org.springframework.core.annotation.AliasFor; + +@Retention(RetentionPolicy.RUNTIME) +public @interface EnclosingAnnotation { + + @AliasFor("nested2") + NestedAnnotation nested1() default @NestedAnnotation; + + @AliasFor("nested1") + NestedAnnotation nested2() default @NestedAnnotation; + +} diff --git a/spring-core/src/test/java/example/type/NestedAnnotation.java b/spring-core/src/test/java/example/type/NestedAnnotation.java new file mode 100644 index 000000000000..8d3789fa52d2 --- /dev/null +++ b/spring-core/src/test/java/example/type/NestedAnnotation.java @@ -0,0 +1,29 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package example.type; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.ANNOTATION_TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface NestedAnnotation { + + String name() default ""; +} diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java index f5cb39ec6d20..412e9c51a977 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -45,6 +45,7 @@ * Tests for {@link AnnotationTypeMappings} and {@link AnnotationTypeMapping}. * * @author Phillip Webb + * @author Sam Brannen */ class AnnotationTypeMappingsTests { @@ -440,10 +441,18 @@ void isEquivalentToDefaultValueWhenClassArrayAndStringArrayNamesMatchReturnsTrue } @Test - void isEquivalentToDefaultValueWhenNestedAnnotationAndExtractedValuesMatchReturnsTrue() { + void isEquivalentToDefaultValueWhenNestedAnnotationAndExtractedValuesMatchReturnsTrueAndValueSuppliedAsMap() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(NestedValue.class).get(0); Map value = Collections.singletonMap("value", "java.io.InputStream"); - assertThat(mapping.isEquivalentToDefaultValue(0, value, this::extractFromMap)).isTrue(); + assertThat(mapping.isEquivalentToDefaultValue(0, value, TypeMappedAnnotation::extractFromMap)).isTrue(); + } + + @Test // gh-24375 + void isEquivalentToDefaultValueWhenNestedAnnotationAndExtractedValuesMatchReturnsTrueAndValueSuppliedAsTypeMappedAnnotation() { + AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(NestedValue.class).get(0); + Map attributes = Collections.singletonMap("value", "java.io.InputStream"); + MergedAnnotation value = TypeMappedAnnotation.of(getClass().getClassLoader(), null, ClassValue.class, attributes); + assertThat(mapping.isEquivalentToDefaultValue(0, value, TypeMappedAnnotation::extractFromMap)).isTrue(); } @Test @@ -504,11 +513,6 @@ private List getNames(MirrorSet mirrorSet) { return names; } - @SuppressWarnings("unchecked") - private Object extractFromMap(Method attribute, Object map) { - return map != null ? ((Map) map).get(attribute.getName()) : null; - } - @Retention(RetentionPolicy.RUNTIME) @interface SimpleAnnotation { diff --git a/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java index e1190866a942..07d48e479678 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -19,6 +19,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import example.type.AnnotatedComponent; +import example.type.EnclosingAnnotation; import org.junit.jupiter.api.Test; import org.springframework.core.annotation.MergedAnnotation; @@ -31,6 +33,7 @@ * Base class for {@link MethodMetadata} tests. * * @author Phillip Webb + * @author Sam Brannen */ public abstract class AbstractMethodMetadataTests { @@ -138,6 +141,12 @@ public void getAllAnnotationAttributesReturnsAllAttributes() { assertThat(attributes.get("size")).containsExactlyInAnyOrder(1, 2); } + @Test // gh-24375 + public void metadataLoadsForNestedAnnotations() { + AnnotationMetadata annotationMetadata = get(AnnotatedComponent.class); + assertThat(annotationMetadata.getAnnotationTypes()).containsExactly(EnclosingAnnotation.class.getName()); + } + protected MethodMetadata getTagged(Class source) { return get(source, Tag.class.getName()); } From 5d4f1d9e094504bb7d705aa7f56a164d98fe13cc Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 12 Feb 2020 10:47:15 +0100 Subject: [PATCH 0424/2315] Extract ValueExtractor functional interface See gh-24375 --- .../annotation/AnnotationTypeMapping.java | 22 ++++------ .../core/annotation/TypeMappedAnnotation.java | 25 +++++------ .../core/annotation/ValueExtractor.java | 43 +++++++++++++++++++ 3 files changed, 62 insertions(+), 28 deletions(-) create mode 100644 spring-core/src/main/java/org/springframework/core/annotation/ValueExtractor.java diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java index 19a3189564af..657e34d5a50d 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.function.BiFunction; import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets.MirrorSet; import org.springframework.lang.Nullable; @@ -465,8 +464,7 @@ Object getMappedAnnotationValue(int attributeIndex, boolean metaAnnotationsOnly) * nested annotations * @return {@code true} if the value is equivalent to the default value */ - boolean isEquivalentToDefaultValue(int attributeIndex, Object value, - BiFunction valueExtractor) { + boolean isEquivalentToDefaultValue(int attributeIndex, Object value, ValueExtractor valueExtractor) { Method attribute = this.attributes.get(attributeIndex); return isEquivalentToDefaultValue(attribute, value, valueExtractor); @@ -488,13 +486,13 @@ private static int[] filledIntArray(int size) { } private static boolean isEquivalentToDefaultValue(Method attribute, Object value, - BiFunction valueExtractor) { + ValueExtractor valueExtractor) { return areEquivalent(attribute.getDefaultValue(), value, valueExtractor); } private static boolean areEquivalent(@Nullable Object value, @Nullable Object extractedValue, - BiFunction valueExtractor) { + ValueExtractor valueExtractor) { if (ObjectUtils.nullSafeEquals(value, extractedValue)) { return true; @@ -528,7 +526,7 @@ private static boolean areEquivalent(Class value, String extractedValue) { } private static boolean areEquivalent(Annotation annotation, @Nullable Object extractedValue, - BiFunction valueExtractor) { + ValueExtractor valueExtractor) { AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType()); for (int i = 0; i < attributes.size(); i++) { @@ -539,7 +537,7 @@ private static boolean areEquivalent(Annotation annotation, @Nullable Object ext value2 = ((TypeMappedAnnotation) extractedValue).getValue(attribute.getName()).orElse(null); } else { - value2 = valueExtractor.apply(attribute, extractedValue); + value2 = valueExtractor.extract(attribute, extractedValue); } if (!areEquivalent(value1, value2, valueExtractor)) { return false; @@ -603,9 +601,7 @@ MirrorSet getAssigned(int attributeIndex) { return this.assigned[attributeIndex]; } - int[] resolve(@Nullable Object source, @Nullable Object annotation, - BiFunction valueExtractor) { - + int[] resolve(@Nullable Object source, @Nullable Object annotation, ValueExtractor valueExtractor) { int[] result = new int[attributes.size()]; for (int i = 0; i < result.length; i++) { result[i] = i; @@ -641,14 +637,12 @@ void update() { } } - int resolve(@Nullable Object source, @Nullable A annotation, - BiFunction valueExtractor) { - + int resolve(@Nullable Object source, @Nullable A annotation, ValueExtractor valueExtractor) { int result = -1; Object lastValue = null; for (int i = 0; i < this.size; i++) { Method attribute = attributes.get(this.indexes[i]); - Object value = valueExtractor.apply(attribute, annotation); + Object value = valueExtractor.extract(attribute, annotation); boolean isDefaultValue = (value == null || isEquivalentToDefaultValue(attribute, value, valueExtractor)); if (isDefaultValue || ObjectUtils.nullSafeEquals(lastValue, value)) { diff --git a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java index cc612a1b9b37..68a67ea7bc9d 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java @@ -27,7 +27,6 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Optional; -import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Predicate; @@ -64,6 +63,7 @@ * * @author Phillip Webb * @author Juergen Hoeller + * @author Sam Brannen * @since 5.2 * @param the annotation type * @see TypeMappedAnnotations @@ -96,7 +96,7 @@ final class TypeMappedAnnotation extends AbstractMergedAnn @Nullable private final Object rootAttributes; - private final BiFunction valueExtractor; + private final ValueExtractor valueExtractor; private final int aggregateIndex; @@ -114,16 +114,15 @@ final class TypeMappedAnnotation extends AbstractMergedAnn private TypeMappedAnnotation(AnnotationTypeMapping mapping, @Nullable ClassLoader classLoader, - @Nullable Object source, @Nullable Object rootAttributes, - BiFunction valueExtractor, int aggregateIndex) { + @Nullable Object source, @Nullable Object rootAttributes, ValueExtractor valueExtractor, + int aggregateIndex) { this(mapping, classLoader, source, rootAttributes, valueExtractor, aggregateIndex, null); } private TypeMappedAnnotation(AnnotationTypeMapping mapping, @Nullable ClassLoader classLoader, - @Nullable Object source, @Nullable Object rootAttributes, - BiFunction valueExtractor, int aggregateIndex, - @Nullable int[] resolvedRootMirrors) { + @Nullable Object source, @Nullable Object rootAttributes, ValueExtractor valueExtractor, + int aggregateIndex, @Nullable int[] resolvedRootMirrors) { this.mapping = mapping; this.classLoader = classLoader; @@ -140,9 +139,8 @@ private TypeMappedAnnotation(AnnotationTypeMapping mapping, @Nullable ClassLoade } private TypeMappedAnnotation(AnnotationTypeMapping mapping, @Nullable ClassLoader classLoader, - @Nullable Object source, @Nullable Object rootAnnotation, - BiFunction valueExtractor, int aggregateIndex, - boolean useMergedValues, @Nullable Predicate attributeFilter, + @Nullable Object source, @Nullable Object rootAnnotation, ValueExtractor valueExtractor, + int aggregateIndex, boolean useMergedValues, @Nullable Predicate attributeFilter, int[] resolvedRootMirrors, int[] resolvedMirrors) { this.classLoader = classLoader; @@ -426,7 +424,7 @@ private Object getValue(int attributeIndex, boolean useConventionMapping, boolea } if (mapping.getDistance() == 0) { Method attribute = mapping.getAttributes().get(attributeIndex); - Object result = this.valueExtractor.apply(attribute, this.rootAttributes); + Object result = this.valueExtractor.extract(attribute, this.rootAttributes); return (result != null) ? result : attribute.getDefaultValue(); } return getValueFromMetaAnnotation(attributeIndex, forMirrorResolution); @@ -562,7 +560,7 @@ private MergedAnnotation adaptToMergedAnnotation(Object value, Class getValueExtractor(Object value) { + private ValueExtractor getValueExtractor(Object value) { if (value instanceof Annotation) { return ReflectionUtils::invokeMethod; } @@ -664,8 +662,7 @@ static TypeMappedAnnotation createIfPossible( @Nullable private static TypeMappedAnnotation createIfPossible( AnnotationTypeMapping mapping, @Nullable Object source, @Nullable Object rootAttribute, - BiFunction valueExtractor, - int aggregateIndex, IntrospectionFailureLogger logger) { + ValueExtractor valueExtractor, int aggregateIndex, IntrospectionFailureLogger logger) { try { return new TypeMappedAnnotation<>(mapping, null, source, rootAttribute, diff --git a/spring-core/src/main/java/org/springframework/core/annotation/ValueExtractor.java b/spring-core/src/main/java/org/springframework/core/annotation/ValueExtractor.java new file mode 100644 index 000000000000..62438f629bf7 --- /dev/null +++ b/spring-core/src/main/java/org/springframework/core/annotation/ValueExtractor.java @@ -0,0 +1,43 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.core.annotation; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.Map; + +import org.springframework.lang.Nullable; + +/** + * Strategy API for extracting a value for an annotation attribute from a given + * source object which is typically an {@link Annotation}, {@link Map}, or + * {@link TypeMappedAnnotation}. + * + * @since 5.2.4 + * @author Sam Brannen + */ +@FunctionalInterface +interface ValueExtractor { + + /** + * Extract the annotation attribute represented by the supplied {@link Method} + * from the supplied source {@link Object}. + */ + @Nullable + Object extract(Method attribute, @Nullable Object object); + +} From 9dbd411f81ca14bd1a490bc9086a757398329bee Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 12 Feb 2020 11:04:07 +0100 Subject: [PATCH 0425/2315] Suppress warnings in Gradle build --- .../org/springframework/aop/framework/CglibProxyTests.java | 3 ++- .../springframework/aop/framework/JdkDynamicProxyTests.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java index 02a956479cdb..ba247ed89a9b 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -387,6 +387,7 @@ public void testProxyTargetClassInCaseOfNoInterfaces() { } @Test // SPR-13328 + @SuppressWarnings("unchecked") public void testVarargsWithEnumArray() { ProxyFactory proxyFactory = new ProxyFactory(new MyBean()); MyBean proxy = (MyBean) proxyFactory.getProxy(); diff --git a/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java index 1488d384715b..306c3d49909d 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -141,6 +141,7 @@ public void testEqualsAndHashCodeDefined() { } @Test // SPR-13328 + @SuppressWarnings("unchecked") public void testVarargsWithEnumArray() { ProxyFactory proxyFactory = new ProxyFactory(new VarargTestBean()); VarargTestInterface proxy = (VarargTestInterface) proxyFactory.getProxy(); @@ -213,6 +214,7 @@ public int hashCode() { public interface VarargTestInterface { + @SuppressWarnings("unchecked") boolean doWithVarargs(V... args); } From de7bed2ab28d0804dcfa1879a75f65c96f7bd4f7 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 12 Feb 2020 14:30:29 +0100 Subject: [PATCH 0426/2315] Simplify custom_java_home.gradle script Setting `options.fork = true` causes the classpath in the forked compiler process to include Class-Path entries from MANIFEST.MF files in JARs in the classpath, which results in warnings about missing classpath entries. This commit removes the `options.fork = true` declaration and further simplifies the script. See gh-24474 --- gradle/custom-java-home.gradle | 35 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/gradle/custom-java-home.gradle b/gradle/custom-java-home.gradle index a9a41ae9c7f9..eca268e65f2f 100644 --- a/gradle/custom-java-home.gradle +++ b/gradle/custom-java-home.gradle @@ -34,53 +34,42 @@ import org.gradle.internal.os.OperatingSystem def customJavaHome = System.getProperty("customJavaHome") if (customJavaHome) { - def javacExecutable = customJavaHome + "/bin/javac" - def javaExecutable = customJavaHome + "/bin/java" - if (OperatingSystem.current().isWindows()) { - javacExecutable += ".exe" - javaExecutable += ".exe" - } - + def customJavaHomeDir = new File(customJavaHome) def customJavaSourceVersion = System.getProperty("customJavaSourceVersion") tasks.withType(JavaCompile) { - logger.info("Java compiler for " + it.name + " task in " + project.name + ": " + javacExecutable) - doFirst { - // Avoid compiler warnings for non-existing path entries - classpath = classpath.filter { it.exists() } - } - options.fork = true - options.forkOptions.executable = javacExecutable - // Ignore warnings about missing classpath elements -- for example, those picked up - // via Class-Path entries in MANIFEST.MF files in artifacts like xalan-2.7.2.jar. - options.compilerArgs -= "-Xlint:path" + logger.info("Java home for " + it.name + " task in " + project.name + ": " + customJavaHomeDir) + options.forkOptions.javaHome = customJavaHomeDir + inputs.property("customJavaHome", customJavaHome) if (customJavaSourceVersion) { options.compilerArgs += [ "--release", customJavaSourceVersion] inputs.property("customJavaSourceVersion", customJavaSourceVersion) } - inputs.property("customJavaHome", customJavaHome) } tasks.withType(GroovyCompile) { - logger.info("Java compiler for " + it.name + " task in " + project.name + ": " + javacExecutable) - options.fork = true - options.forkOptions.executable = javacExecutable + logger.info("Java home for " + it.name + " task in " + project.name + ": " + customJavaHomeDir) + options.forkOptions.executable = customJavaHomeDir + inputs.property("customJavaHome", customJavaHome) if (customJavaSourceVersion) { options.compilerArgs += [ "--release", customJavaSourceVersion] inputs.property("customJavaSourceVersion", customJavaSourceVersion) } - inputs.property("customJavaHome", customJavaHome) } /* tasks.withType(KotlinJvmCompile) { logger.info("Java home for " + it.name + " task in " + project.name + ": " + customJavaHome) - kotlinOptions.jdkHome = customJavaHome + kotlinOptions.jdkHome = customJavaHomeDir inputs.property("customJavaHome", customJavaHome) } */ tasks.withType(Test) { + def javaExecutable = customJavaHome + "/bin/java" + if (OperatingSystem.current().isWindows()) { + javaExecutable += ".exe" + } logger.info("Java executable for " + it.name + " task in " + project.name + ": " + javaExecutable) executable = javaExecutable inputs.property("customJavaHome", customJavaHome) From a9d9b76d090e912c7cac646df235fddce4353d48 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 12 Feb 2020 15:33:01 +0100 Subject: [PATCH 0427/2315] Support SpEL compilation of interface methods again Spring Framework 5.1.8 introduced a regression for the compilation of SpEL expressions referencing a method declared in an interface. An attempt to compile such an expression resulted in a SpelEvaluationException caused by an IncompatibleClassChangeError. This commit fixes this regression by adding explicit support in ReflectivePropertyAccessor.OptimalPropertyAccessor.generateCode() for methods declared in interfaces. Closes gh-24357 --- .../support/ReflectivePropertyAccessor.java | 10 +++- .../spel/standard/SpelCompilerTests.java | 59 +++++++++++++++++++ 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelCompilerTests.java diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java index aa3819a3c914..e8cf3dad6044 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -55,6 +55,7 @@ * @author Andy Clement * @author Juergen Hoeller * @author Phillip Webb + * @author Sam Brannen * @since 3.0 * @see StandardEvaluationContext * @see SimpleEvaluationContext @@ -765,8 +766,11 @@ public void generateCode(String propertyName, MethodVisitor mv, CodeFlow cf) { } if (this.member instanceof Method) { - mv.visitMethodInsn((isStatic ? INVOKESTATIC : INVOKEVIRTUAL), classDesc, this.member.getName(), - CodeFlow.createSignatureDescriptor((Method) this.member), false); + Method method = (Method) this.member; + boolean isInterface = method.getDeclaringClass().isInterface(); + int opcode = (isStatic ? INVOKESTATIC : isInterface ? INVOKEINTERFACE : INVOKEVIRTUAL); + mv.visitMethodInsn(opcode, classDesc, method.getName(), + CodeFlow.createSignatureDescriptor(method), isInterface); } else { mv.visitFieldInsn((isStatic ? GETSTATIC : GETFIELD), classDesc, this.member.getName(), diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelCompilerTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelCompilerTests.java new file mode 100644 index 000000000000..dc80b9c90dec --- /dev/null +++ b/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelCompilerTests.java @@ -0,0 +1,59 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.expression.spel.standard; + +import java.util.stream.IntStream; + +import org.junit.jupiter.api.Test; + +import org.springframework.core.Ordered; +import org.springframework.expression.Expression; +import org.springframework.expression.spel.SpelCompilerMode; +import org.springframework.expression.spel.SpelParserConfiguration; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for the {@link SpelCompiler}. + * + * @author Sam Brannen + * @since 5.1.14 + */ +class SpelCompilerTests { + + @Test // gh-24357 + void expressionCompilesWhenMethodComesFromPublicInterface() { + SpelParserConfiguration config = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null); + SpelExpressionParser parser = new SpelExpressionParser(config); + + OrderedComponent component = new OrderedComponent(); + Expression expression = parser.parseExpression("order"); + + // Evaluate the expression multiple times to ensure that it gets compiled. + IntStream.rangeClosed(1, 5).forEach(i -> assertThat(expression.getValue(component)).isEqualTo(42)); + } + + + static class OrderedComponent implements Ordered { + + @Override + public int getOrder() { + return 42; + } + } + +} From b889700548681382911e06701b257549bb81e929 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 12 Feb 2020 16:48:32 +0100 Subject: [PATCH 0428/2315] Differentiate MismatchedInputException versus ValueInstantiationException Closes gh-24455 --- .../codec/json/AbstractJackson2Decoder.java | 16 +++++++++++--- .../codec/json/AbstractJackson2Encoder.java | 21 ++++++++++++------- .../AbstractJackson2HttpMessageConverter.java | 19 ++++++++++++++--- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java index 7aae80928862..91507fdb2483 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java @@ -25,9 +25,11 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; +import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.util.TokenBuffer; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; @@ -188,10 +190,18 @@ private void logValue(@Nullable Object value, @Nullable Map hint } private CodecException processException(IOException ex) { - if (ex instanceof InvalidDefinitionException) { + if (ex instanceof MismatchedInputException) { // specific kind of JsonMappingException + String originalMessage = ((MismatchedInputException) ex).getOriginalMessage(); + return new DecodingException("Invalid JSON input: " + originalMessage, ex); + } + if (ex instanceof InvalidDefinitionException) { // another kind of JsonMappingException JavaType type = ((InvalidDefinitionException) ex).getType(); return new CodecException("Type definition error: " + type, ex); } + if (ex instanceof JsonMappingException) { // typically ValueInstantiationException + String originalMessage = ((JsonMappingException) ex).getOriginalMessage(); + return new CodecException("JSON conversion problem: " + originalMessage, ex); + } if (ex instanceof JsonProcessingException) { String originalMessage = ((JsonProcessingException) ex).getOriginalMessage(); return new DecodingException("JSON decoding error: " + originalMessage, ex); @@ -200,7 +210,7 @@ private CodecException processException(IOException ex) { } - // HttpMessageDecoder... + // HttpMessageDecoder @Override public Map getDecodeHints(ResolvableType actualType, ResolvableType elementType, @@ -214,7 +224,7 @@ public List getDecodableMimeTypes() { return getMimeTypes(); } - // Jackson2CodecSupport ... + // Jackson2CodecSupport @Override protected A getAnnotation(MethodParameter parameter, Class annotType) { diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java index b195c9acd61f..adccdd808314 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java @@ -30,10 +30,12 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.util.ByteArrayBuilder; import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.SequenceWriter; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; +import com.fasterxml.jackson.databind.exc.MismatchedInputException; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -164,15 +166,20 @@ public DataBuffer encodeValue(Object value, DataBufferFactory bufferFactory, writer.writeValue(generator, value); generator.flush(); } - catch (InvalidDefinitionException ex) { + catch (MismatchedInputException ex) { // specific kind of JsonMappingException + throw new EncodingException("Invalid JSON input: " + ex.getOriginalMessage(), ex); + } + catch (InvalidDefinitionException ex) { // another kind of JsonMappingException throw new CodecException("Type definition error: " + ex.getType(), ex); } + catch (JsonMappingException ex) { // typically ValueInstantiationException + throw new CodecException("JSON conversion problem: " + ex.getOriginalMessage(), ex); + } catch (JsonProcessingException ex) { throw new EncodingException("JSON encoding error: " + ex.getOriginalMessage(), ex); } catch (IOException ex) { - throw new IllegalStateException("Unexpected I/O error while writing to byte array builder", - ex); + throw new IllegalStateException("Unexpected I/O error while writing to byte array builder", ex); } byte[] bytes = byteBuilder.toByteArray(); @@ -198,8 +205,7 @@ private DataBuffer encodeStreamingValue(Object value, DataBufferFactory bufferFa throw new EncodingException("JSON encoding error: " + ex.getOriginalMessage(), ex); } catch (IOException ex) { - throw new IllegalStateException("Unexpected I/O error while writing to byte array builder", - ex); + throw new IllegalStateException("Unexpected I/O error while writing to byte array builder", ex); } byte[] bytes = byteArrayBuilder.toByteArray(); @@ -281,7 +287,7 @@ protected JsonEncoding getJsonEncoding(@Nullable MimeType mimeType) { } - // HttpMessageEncoder... + // HttpMessageEncoder @Override public List getEncodableMimeTypes() { @@ -300,7 +306,8 @@ public Map getEncodeHints(@Nullable ResolvableType actualType, R return (actualType != null ? getHints(actualType) : Hints.none()); } - // Jackson2CodecSupport ... + + // Jackson2CodecSupport @Override protected A getAnnotation(MethodParameter parameter, Class annotType) { diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java index 615f197d3ff5..04106d9462b0 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -36,6 +36,7 @@ import com.fasterxml.jackson.databind.SerializationConfig; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; +import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.type.TypeFactory; @@ -238,9 +239,15 @@ private Object readJavaType(JavaType javaType, HttpInputMessage inputMessage) th } return this.objectMapper.readValue(inputMessage.getBody(), javaType); } - catch (InvalidDefinitionException ex) { + catch (MismatchedInputException ex) { // specific kind of JsonMappingException + throw new HttpMessageNotReadableException("Invalid JSON input: " + ex.getOriginalMessage(), ex, inputMessage); + } + catch (InvalidDefinitionException ex) { // another kind of JsonMappingException throw new HttpMessageConversionException("Type definition error: " + ex.getType(), ex); } + catch (JsonMappingException ex) { // typically ValueInstantiationException + throw new HttpMessageConversionException("JSON conversion problem: " + ex.getOriginalMessage(), ex); + } catch (JsonProcessingException ex) { throw new HttpMessageNotReadableException("JSON parse error: " + ex.getOriginalMessage(), ex, inputMessage); } @@ -289,9 +296,15 @@ protected void writeInternal(Object object, @Nullable Type type, HttpOutputMessa writeSuffix(generator, object); generator.flush(); } - catch (InvalidDefinitionException ex) { + catch (MismatchedInputException ex) { // specific kind of JsonMappingException + throw new HttpMessageNotWritableException("Invalid JSON input: " + ex.getOriginalMessage(), ex); + } + catch (InvalidDefinitionException ex) { // another kind of JsonMappingException throw new HttpMessageConversionException("Type definition error: " + ex.getType(), ex); } + catch (JsonMappingException ex) { // typically ValueInstantiationException + throw new HttpMessageConversionException("JSON mapping problem: " + ex.getPathReference(), ex); + } catch (JsonProcessingException ex) { throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getOriginalMessage(), ex); } From e0319b1f7906890e0b961f588996e56a6d9ddd15 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 12 Feb 2020 16:48:42 +0100 Subject: [PATCH 0429/2315] Raise log level for exceptions from EntityManager close call Closes gh-24501 --- .../jms/connection/SingleConnectionFactory.java | 4 ++-- .../orm/hibernate5/SessionFactoryUtils.java | 7 ++----- .../springframework/orm/jpa/EntityManagerFactoryUtils.java | 7 ++----- .../org/springframework/orm/jpa/JpaTransactionManager.java | 6 +++--- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java index bc1f74c48c30..84b2378ab056 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -505,7 +505,7 @@ protected void closeConnection(Connection con) { logger.debug("Ignoring Connection state exception - assuming already closed: " + ex); } catch (Throwable ex) { - logger.debug("Could not close shared JMS Connection", ex); + logger.warn("Could not close shared JMS Connection", ex); } } diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SessionFactoryUtils.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SessionFactoryUtils.java index 79b0cecf2fe6..87ba5cc2a071 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SessionFactoryUtils.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SessionFactoryUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -170,11 +170,8 @@ public static void closeSession(@Nullable Session session) { try { session.close(); } - catch (HibernateException ex) { - logger.debug("Could not close Hibernate Session", ex); - } catch (Throwable ex) { - logger.debug("Unexpected exception on closing Hibernate Session", ex); + logger.error("Failed to release Hibernate Session", ex); } } } diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java index b5a148ed3d84..e8fb5e15fb8c 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -427,11 +427,8 @@ public static void closeEntityManager(@Nullable EntityManager em) { em.close(); } } - catch (PersistenceException ex) { - logger.debug("Could not close JPA EntityManager", ex); - } catch (Throwable ex) { - logger.debug("Unexpected exception on closing JPA EntityManager", ex); + logger.error("Failed to release JPA EntityManager", ex); } } } diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java index ff6db7957d14..baca6c773e7d 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -604,9 +604,9 @@ protected void doCleanupAfterCompletion(Object transaction) { getJpaDialect().releaseJdbcConnection(conHandle, txObject.getEntityManagerHolder().getEntityManager()); } - catch (Exception ex) { + catch (Throwable ex) { // Just log it, to keep a transaction-related exception. - logger.error("Could not close JDBC connection after transaction", ex); + logger.error("Failed to release JDBC connection after transaction", ex); } } } From d1c7083e77cb0b6218153cd46defc18b698ccd82 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 12 Feb 2020 16:49:02 +0100 Subject: [PATCH 0430/2315] Consistent ROLE_INFRASTRUCTURE declarations for configuration classes Closes gh-24509 --- .../scheduling/aspectj/AspectJAsyncConfiguration.java | 3 ++- .../AspectJJtaTransactionManagementConfiguration.java | 3 ++- .../AspectJTransactionManagementConfiguration.java | 3 ++- .../annotation/LoadTimeWeavingConfiguration.java | 3 ++- .../context/annotation/MBeanExportConfiguration.java | 3 ++- .../ProxyTransactionManagementConfiguration.java | 10 +++++----- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AspectJAsyncConfiguration.java b/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AspectJAsyncConfiguration.java index ef93148652ac..e13a595b42d4 100644 --- a/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AspectJAsyncConfiguration.java +++ b/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AspectJAsyncConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -37,6 +37,7 @@ * @see org.springframework.scheduling.annotation.ProxyAsyncConfiguration */ @Configuration +@Role(BeanDefinition.ROLE_INFRASTRUCTURE) public class AspectJAsyncConfiguration extends AbstractAsyncConfiguration { @Bean(name = TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME) diff --git a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJJtaTransactionManagementConfiguration.java b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJJtaTransactionManagementConfiguration.java index caa7cc3c2f72..ec733d3cf2b9 100644 --- a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJJtaTransactionManagementConfiguration.java +++ b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJJtaTransactionManagementConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -36,6 +36,7 @@ * @see TransactionManagementConfigurationSelector */ @Configuration +@Role(BeanDefinition.ROLE_INFRASTRUCTURE) public class AspectJJtaTransactionManagementConfiguration extends AspectJTransactionManagementConfiguration { @Bean(name = TransactionManagementConfigUtils.JTA_TRANSACTION_ASPECT_BEAN_NAME) diff --git a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJTransactionManagementConfiguration.java b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJTransactionManagementConfiguration.java index 2784a733e7c2..2c99c3050744 100644 --- a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJTransactionManagementConfiguration.java +++ b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJTransactionManagementConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -38,6 +38,7 @@ * @see AspectJJtaTransactionManagementConfiguration */ @Configuration +@Role(BeanDefinition.ROLE_INFRASTRUCTURE) public class AspectJTransactionManagementConfiguration extends AbstractTransactionManagementConfiguration { @Bean(name = TransactionManagementConfigUtils.TRANSACTION_ASPECT_BEAN_NAME) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfiguration.java b/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfiguration.java index 65cbe15a2754..8c54ca4971bf 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfiguration.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -42,6 +42,7 @@ * @see ConfigurableApplicationContext#LOAD_TIME_WEAVER_BEAN_NAME */ @Configuration +@Role(BeanDefinition.ROLE_INFRASTRUCTURE) public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoaderAware { @Nullable diff --git a/spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java b/spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java index 02a9d40b9296..04fb3ff00bca 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -50,6 +50,7 @@ * @see EnableMBeanExport */ @Configuration +@Role(BeanDefinition.ROLE_INFRASTRUCTURE) public class MBeanExportConfiguration implements ImportAware, EnvironmentAware, BeanFactoryAware { private static final String MBEAN_EXPORTER_BEAN_NAME = "mbeanExporter"; diff --git a/spring-tx/src/main/java/org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.java b/spring-tx/src/main/java/org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.java index ddcdb15ace6b..206cd512abc7 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.java +++ b/spring-tx/src/main/java/org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -36,13 +36,14 @@ * @see TransactionManagementConfigurationSelector */ @Configuration(proxyBeanMethods = false) +@Role(BeanDefinition.ROLE_INFRASTRUCTURE) public class ProxyTransactionManagementConfiguration extends AbstractTransactionManagementConfiguration { @Bean(name = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor( - TransactionAttributeSource transactionAttributeSource, - TransactionInterceptor transactionInterceptor) { + TransactionAttributeSource transactionAttributeSource, TransactionInterceptor transactionInterceptor) { + BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor(); advisor.setTransactionAttributeSource(transactionAttributeSource); advisor.setAdvice(transactionInterceptor); @@ -60,8 +61,7 @@ public TransactionAttributeSource transactionAttributeSource() { @Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) - public TransactionInterceptor transactionInterceptor( - TransactionAttributeSource transactionAttributeSource) { + public TransactionInterceptor transactionInterceptor(TransactionAttributeSource transactionAttributeSource) { TransactionInterceptor interceptor = new TransactionInterceptor(); interceptor.setTransactionAttributeSource(transactionAttributeSource); if (this.txManager != null) { From 9f6572a09572f3166737ee7f44f6fa6787090e17 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 12 Feb 2020 16:49:19 +0100 Subject: [PATCH 0431/2315] Add missing final declaration for static field --- .../main/java/org/springframework/web/client/RestTemplate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java index edba0711c97f..d8bb4f730f0f 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java @@ -90,7 +90,7 @@ */ public class RestTemplate extends InterceptingHttpAccessor implements RestOperations { - private static boolean romePresent; + private static final boolean romePresent; private static final boolean jaxb2Present; From d0d8c6e749b6fa52ae41902b831d75e2afc4bc94 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 12 Feb 2020 17:14:33 +0000 Subject: [PATCH 0432/2315] Use Gradle Enterprise Conventions Plugin to configure build scans Closes gh-24512 --- build.gradle | 11 +--- gradle/build-scan-user-data.gradle | 90 ------------------------------ 2 files changed, 1 insertion(+), 100 deletions(-) diff --git a/build.gradle b/build.gradle index 201220ee29f7..4c35df062bd4 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ plugins { id 'org.jetbrains.kotlin.jvm' version '1.3.61' apply false id 'org.jetbrains.dokka' version '0.9.18' apply false id 'org.asciidoctor.jvm.convert' version '2.4.0' + id 'io.spring.gradle-enterprise-conventions' version '0.0.2' id 'io.spring.nohttp' version '0.0.4.RELEASE' id 'de.undercouch.download' version '4.0.0' id 'com.gradle.build-scan' version '3.1.1' @@ -12,16 +13,6 @@ plugins { } apply from: "$rootDir/gradle/build-scan-user-data.gradle" -buildScan { - captureTaskInputFiles = true - obfuscation { - ipAddresses { addresses -> addresses.collect { address -> '0.0.0.0'} } - } - publishAlways() - publishIfAuthenticated() - server = 'https://ge.spring.io' -} - ext { moduleProjects = subprojects.findAll { it.name.startsWith("spring-") } javaProjects = subprojects - project(":framework-bom") diff --git a/gradle/build-scan-user-data.gradle b/gradle/build-scan-user-data.gradle index c9463e7f33d1..156191d11526 100644 --- a/gradle/build-scan-user-data.gradle +++ b/gradle/build-scan-user-data.gradle @@ -1,67 +1,6 @@ -tagOs() -tagIde() -tagCiOrLocal() -addCiMetadata() -addGitMetadata() -addTestTaskMetadata() addCustomJavaHomeMetadata() addCustomJavaSourceVersionMetadata() -void tagOs() { - buildScan.tag System.getProperty('os.name') -} - -void tagIde() { - if (System.getProperty('idea.version')) { - buildScan.tag 'IntelliJ IDEA' - } else if (System.getProperty('eclipse.buildId')) { - buildScan.tag 'Eclipse' - } -} - -void tagCiOrLocal() { - buildScan.tag(isCi() ? 'CI' : 'LOCAL') -} - -void addGitMetadata() { - buildScan.background { - def gitCommitId = execAndGetStdout('git', 'rev-parse', '--short=8', '--verify', 'HEAD') - def gitBranchName = execAndGetStdout('git', 'rev-parse', '--abbrev-ref', 'HEAD') - def gitStatus = execAndGetStdout('git', 'status', '--porcelain') - - if(gitCommitId) { - def commitIdLabel = 'Git Commit ID' - value commitIdLabel, gitCommitId - link 'Git commit build scans', customValueSearchUrl([(commitIdLabel): gitCommitId]) - } - if (gitBranchName) { - tag gitBranchName - value 'Git branch', gitBranchName - } - if (gitStatus) { - tag 'dirty' - value 'Git status', gitStatus - } - } -} - -void addCiMetadata() { - def ciBuild = 'CI BUILD' - if (isBamboo()) { - buildScan.link ciBuild, System.getenv('bamboo_resultsUrl') - } -} - -void addTestTaskMetadata() { - allprojects { - tasks.withType(Test) { test -> - doFirst { - buildScan.value "Test#maxParallelForks[${test.path}]", test.maxParallelForks.toString() - } - } - } -} - void addCustomJavaHomeMetadata() { def customJavaHome = System.getProperty("customJavaHome") if (customJavaHome) { @@ -75,32 +14,3 @@ void addCustomJavaSourceVersionMetadata() { buildScan.value "Custom Java Source Version", customJavaSourceVersion } } - -boolean isCi() { - isBamboo() -} - -boolean isBamboo() { - System.getenv('bamboo_resultsUrl') -} - -String execAndGetStdout(String... args) { - def stdout = new ByteArrayOutputStream() - exec { - commandLine(args) - standardOutput = stdout - } - return stdout.toString().trim() -} - -String customValueSearchUrl(Map search) { - def query = search.collect { name, value -> - "search.names=${encodeURL(name)}&search.values=${encodeURL(value)}" - }.join('&') - - "$buildScan.server/scans?$query" -} - -String encodeURL(String url) { - URLEncoder.encode(url, 'UTF-8') -} From a4179b479599c62a89b5e67dbfa0d28ad61c638b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 12 Feb 2020 18:32:32 +0100 Subject: [PATCH 0433/2315] Polishing --- .../context/annotation/ImportSelectorTests.java | 1 + .../http/codec/json/AbstractJackson2Decoder.java | 3 ++- .../http/codec/json/AbstractJackson2Encoder.java | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java index f310720b6522..337c4c5d90a9 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java @@ -541,6 +541,7 @@ static Map> allImports() { .collect(Collectors.toMap(entry -> entry.getKey().getClassName(), Map.Entry::getValue)); } + private final List instanceImports = new ArrayList<>(); @Override diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java index 91507fdb2483..2a2a50193148 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java @@ -112,7 +112,7 @@ public Flux decode(Publisher input, ResolvableType elementTy ObjectMapper mapper = getObjectMapper(); boolean forceUseOfBigDecimal = mapper.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS); - if (elementType != null && BigDecimal.class.equals(elementType.getType())) { + if (BigDecimal.class.equals(elementType.getType())) { forceUseOfBigDecimal = true; } @@ -224,6 +224,7 @@ public List getDecodableMimeTypes() { return getMimeTypes(); } + // Jackson2CodecSupport @Override diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java index adccdd808314..7d2e4421edf2 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java @@ -240,6 +240,7 @@ private void logValue(@Nullable Map hints, Object value) { private ObjectWriter createObjectWriter(ResolvableType valueType, @Nullable MimeType mimeType, @Nullable Map hints) { + JavaType javaType = getJavaType(valueType.getType(), null); Class jsonView = (hints != null ? (Class) hints.get(Jackson2CodecSupport.JSON_VIEW_HINT) : null); ObjectWriter writer = (jsonView != null ? From d481b81b7e784399e4918bd9bca11866855d0931 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 12 Feb 2020 23:08:42 +0100 Subject: [PATCH 0434/2315] Fix copy-n-paste error in custom_java_home.gradle script See gh-24474 --- gradle/custom-java-home.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/custom-java-home.gradle b/gradle/custom-java-home.gradle index eca268e65f2f..1dd7fa119691 100644 --- a/gradle/custom-java-home.gradle +++ b/gradle/custom-java-home.gradle @@ -49,7 +49,7 @@ if (customJavaHome) { tasks.withType(GroovyCompile) { logger.info("Java home for " + it.name + " task in " + project.name + ": " + customJavaHomeDir) - options.forkOptions.executable = customJavaHomeDir + options.forkOptions.javaHome = customJavaHomeDir inputs.property("customJavaHome", customJavaHome) if (customJavaSourceVersion) { options.compilerArgs += [ "--release", customJavaSourceVersion] From 05301d24c12951d9e255bb4c0e8ebb8a6149426d Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 13 Feb 2020 15:44:58 +0100 Subject: [PATCH 0435/2315] Upgrade to JUnit Jupiter 5.6 Closes gh-24299 --- build.gradle | 4 ++-- .../FailingBeforeAndAfterMethodsSpringExtensionTests.java | 4 ++-- .../transaction/TimedTransactionalSpringExtensionTests.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 4c35df062bd4..1aafb87a636c 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ configure(allprojects) { project -> mavenBom "org.eclipse.jetty:jetty-bom:9.4.26.v20200117" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.61" mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.2" - mavenBom "org.junit:junit-bom:5.5.2" + mavenBom "org.junit:junit-bom:5.6.0" } dependencies { dependencySet(group: 'org.apache.logging.log4j', version: '2.13.0') { @@ -368,7 +368,7 @@ configure([rootProject] + javaProjects) { project -> "https://fasterxml.github.io/jackson-dataformat-xml/javadoc/2.10/", "https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/", "https://junit.org/junit4/javadoc/4.12/", - "https://junit.org/junit5/docs/5.5.2/api/" + "https://junit.org/junit5/docs/5.6.0/api/" ] as String[] } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.java index 0acfe96068e3..bb40b5669933 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -82,7 +82,7 @@ void failingBeforeAndAfterCallbacks(Class testClass) { Events events = EngineTestKit.engine("junit-jupiter") .selectors(selectClass(testClass)) .execute() - .tests() + .testEvents() .assertStatistics(stats -> stats .skipped(0) .aborted(0) diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/transaction/TimedTransactionalSpringExtensionTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/transaction/TimedTransactionalSpringExtensionTests.java index 79a623894c32..27837936ad6c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/transaction/TimedTransactionalSpringExtensionTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/transaction/TimedTransactionalSpringExtensionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -60,7 +60,7 @@ void springTransactionsWorkWithJUnitJupiterTimeouts() { Events events = EngineTestKit.engine("junit-jupiter") .selectors(selectClass(TestCase.class)) .execute() - .tests() + .testEvents() .assertStatistics(stats -> stats.started(4).succeeded(2).failed(2)); events.failed().assertThatEvents().haveExactly(2, From 4cbc61abfc38c5c7421603ceb8241a2c2b3d3cd8 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 13 Feb 2020 16:14:49 +0100 Subject: [PATCH 0436/2315] Upgrade to Tomcat 9.0.31, Apache HttpClient 4.5.11, Mockito 3.2.4, HtmlUnit 2.37 --- build.gradle | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 1aafb87a636c..853d7d88b616 100644 --- a/build.gradle +++ b/build.gradle @@ -121,14 +121,14 @@ configure(allprojects) { project -> dependency "org.webjars:webjars-locator-core:0.43" dependency "org.webjars:underscorejs:1.8.3" - dependencySet(group: 'org.apache.tomcat', version: '9.0.30') { + dependencySet(group: 'org.apache.tomcat', version: '9.0.31') { entry 'tomcat-util' entry('tomcat-websocket') { exclude group: "org.apache.tomcat", name: "tomcat-websocket-api" exclude group: "org.apache.tomcat", name: "tomcat-servlet-api" } } - dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.30') { + dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.31') { entry 'tomcat-embed-core' entry 'tomcat-embed-websocket' } @@ -147,7 +147,7 @@ configure(allprojects) { project -> entry 'okhttp' entry 'mockwebserver' } - dependency("org.apache.httpcomponents:httpclient:4.5.10") { + dependency("org.apache.httpcomponents:httpclient:4.5.11") { exclude group: "commons-logging", name: "commons-logging" } dependency("org.apache.httpcomponents:httpasyncclient:4.1.4") { @@ -187,7 +187,7 @@ configure(allprojects) { project -> exclude group: "org.hamcrest", name: "hamcrest-core" } } - dependencySet(group: 'org.mockito', version: '3.2.0') { + dependencySet(group: 'org.mockito', version: '3.2.4') { entry('mockito-core') { exclude group: "org.hamcrest", name: "hamcrest-core" } @@ -195,10 +195,10 @@ configure(allprojects) { project -> } dependency "io.mockk:mockk:1.9.3" - dependency("net.sourceforge.htmlunit:htmlunit:2.36.0") { + dependency("net.sourceforge.htmlunit:htmlunit:2.37.0") { exclude group: "commons-logging", name: "commons-logging" } - dependency("org.seleniumhq.selenium:htmlunit-driver:2.36.0") { + dependency("org.seleniumhq.selenium:htmlunit-driver:2.37.0") { exclude group: "commons-logging", name: "commons-logging" } dependency("org.seleniumhq.selenium:selenium-java:3.141.59") { From 13f23dc32ba0f17cc6d26e068c09e0b2578c6ffc Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 13 Feb 2020 21:34:37 +0100 Subject: [PATCH 0437/2315] Mark response as complete before WebSocket upgrade Prior to this commit, some WebSocket `RequestUpgradeStrategy` reactive implementations would prevent the application from writing HTTP headers and cookies to the response. For Reactor Netty and Undertow, handling the upgrade and starting the WebSocket communication marks the response status and headers as sent and the application cannot update HTTP response headers after that. This commit ensures that the `RequestUpgradeStrategy` implementations mark the responses as "complete", so that headers are written before we delegate to the server implementation. Fixes gh-24475 --- .../ReactorNettyRequestUpgradeStrategy.java | 18 +++---- .../UndertowRequestUpgradeStrategy.java | 23 ++++----- .../socket/WebSocketIntegrationTests.java | 47 ++++++++++++++++++- 3 files changed, 64 insertions(+), 24 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java index f7d6575b104f..f29c4f63564c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java @@ -103,15 +103,15 @@ public Mono upgrade(ServerWebExchange exchange, WebSocketHandler handler, HttpServerResponse reactorResponse = getNativeResponse(response); HandshakeInfo handshakeInfo = handshakeInfoFactory.get(); NettyDataBufferFactory bufferFactory = (NettyDataBufferFactory) response.bufferFactory(); - - return reactorResponse.sendWebsocket(subProtocol, this.maxFramePayloadLength, this.handlePing, - (in, out) -> { - ReactorNettyWebSocketSession session = - new ReactorNettyWebSocketSession( - in, out, handshakeInfo, bufferFactory, this.maxFramePayloadLength); - URI uri = exchange.getRequest().getURI(); - return handler.handle(session).checkpoint(uri + " [ReactorNettyRequestUpgradeStrategy]"); - }); + return response.setComplete() + .then(Mono.defer(() -> reactorResponse.sendWebsocket(subProtocol, this.maxFramePayloadLength, this.handlePing, + (in, out) -> { + ReactorNettyWebSocketSession session = + new ReactorNettyWebSocketSession( + in, out, handshakeInfo, bufferFactory, this.maxFramePayloadLength); + URI uri = exchange.getRequest().getURI(); + return handler.handle(session).checkpoint(uri + " [ReactorNettyRequestUpgradeStrategy]"); + }))); } private static HttpServerResponse getNativeResponse(ServerHttpResponse response) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/UndertowRequestUpgradeStrategy.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/UndertowRequestUpgradeStrategy.java index 30c06ed4f4fa..8307c8eed010 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/UndertowRequestUpgradeStrategy.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/UndertowRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -43,10 +43,11 @@ import org.springframework.web.server.ServerWebExchange; /** -* A {@link RequestUpgradeStrategy} for use with Undertow. - * + * A {@link RequestUpgradeStrategy} for use with Undertow. + * * @author Violeta Georgieva * @author Rossen Stoyanchev + * @author Brian Clozel * @since 5.0 */ public class UndertowRequestUpgradeStrategy implements RequestUpgradeStrategy { @@ -63,16 +64,12 @@ public Mono upgrade(ServerWebExchange exchange, WebSocketHandler handler, HandshakeInfo handshakeInfo = handshakeInfoFactory.get(); DataBufferFactory bufferFactory = exchange.getResponse().bufferFactory(); - - try { - DefaultCallback callback = new DefaultCallback(handshakeInfo, handler, bufferFactory); - new WebSocketProtocolHandshakeHandler(handshakes, callback).handleRequest(httpExchange); - } - catch (Exception ex) { - return Mono.error(ex); - } - - return Mono.empty(); + return exchange.getResponse().setComplete() + .then(Mono.fromCallable(() -> { + DefaultCallback callback = new DefaultCallback(handshakeInfo, handler, bufferFactory); + new WebSocketProtocolHandshakeHandler(handshakes, callback).handleRequest(httpExchange); + return null; + })); } private static HttpServerExchange getNativeRequest(ServerHttpRequest request) { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java index 0e970b49658c..4ac544d83e8b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -33,9 +33,11 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseCookie; import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping; import org.springframework.web.reactive.socket.client.WebSocketClient; +import org.springframework.web.server.WebFilter; import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; @@ -45,6 +47,7 @@ * * @author Rossen Stoyanchev * @author Sam Brannen + * @author Brian Clozel */ class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { @@ -91,6 +94,7 @@ void subProtocol(WebSocketClient client, HttpServer server, Class serverConfi public List getSubProtocols() { return Collections.singletonList(protocol); } + @Override public Mono handle(WebSocketSession session) { infoRef.set(session.getHandshakeInfo()); @@ -138,12 +142,31 @@ void sessionClosing(WebSocketClient client, HttpServer server, Class serverCo .doOnNext(s -> logger.debug("inbound " + s)) .then() .doFinally(signalType -> - logger.debug("Completed with: " + signalType) + logger.debug("Completed with: " + signalType) ); }) .block(TIMEOUT); } + @ParameterizedWebSocketTest + void cookie(WebSocketClient client, HttpServer server, Class serverConfigClass) throws Exception { + startServer(client, server, serverConfigClass); + + MonoProcessor output = MonoProcessor.create(); + AtomicReference cookie = new AtomicReference<>(); + this.client.execute(getUrl("/cookie"), + session -> { + cookie.set(session.getHandshakeInfo().getHeaders().getFirst("Set-Cookie")); + return session.receive() + .map(WebSocketMessage::getPayloadAsText) + .subscribeWith(output) + .then(); + }) + .block(TIMEOUT); + assertThat(output.block(TIMEOUT)).isEqualTo("cookie"); + assertThat(cookie.get()).isEqualTo("project=spring"); + } + @Configuration static class WebConfig { @@ -155,8 +178,19 @@ public HandlerMapping handlerMapping() { map.put("/sub-protocol", new SubProtocolWebSocketHandler()); map.put("/custom-header", new CustomHeaderHandler()); map.put("/close", new SessionClosingHandler()); + map.put("/cookie", new CookieHandler()); return new SimpleUrlHandlerMapping(map); } + + @Bean + public WebFilter cookieWebFilter() { + return (exchange, chain) -> { + if (exchange.getRequest().getPath().value().startsWith("/cookie")) { + exchange.getResponse().addCookie(ResponseCookie.from("project", "spring").build()); + } + return chain.filter(exchange); + }; + } } @@ -209,4 +243,13 @@ public Mono handle(WebSocketSession session) { } } + private static class CookieHandler implements WebSocketHandler { + + @Override + public Mono handle(WebSocketSession session) { + WebSocketMessage message = session.textMessage("cookie"); + return session.send(Mono.just(message)); + } + } + } From 9e7ab4d308a5fee37c4a5addf346483034efbdd8 Mon Sep 17 00:00:00 2001 From: Sviatoslav Hryb Date: Mon, 17 Feb 2020 16:25:17 +0200 Subject: [PATCH 0438/2315] Correct formatting of MessageSource example in documentation Closes gh-24531 --- src/docs/asciidoc/core/core-beans.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc index 667a6f94dcfd..0bb0e595ae3b 100644 --- a/src/docs/asciidoc/core/core-beans.adoc +++ b/src/docs/asciidoc/core/core-beans.adoc @@ -10421,7 +10421,7 @@ resolved is specified manually: [literal,subs="verbatim,quotes"] ---- # in exceptions_en_GB.properties -argument.required=Ebagum lad, the {0} argument is required, I say, required. +argument.required=Ebagum lad, the ''{0}'' argument is required, I say, required. ---- [source,java,indent=0,subs="verbatim,quotes",role="primary"] From 6add7b4dec627f8d4b476ed3410da25abbc6860e Mon Sep 17 00:00:00 2001 From: ZhangT Date: Tue, 18 Feb 2020 00:33:39 +0800 Subject: [PATCH 0439/2315] Polishing Closes gh-24543 --- .../TrickyAspectJPointcutExpressionTests.java | 2 +- .../beans/CollectingReaderEventListener.java | 6 +----- .../cache/config/CacheAdviceParser.java | 18 +++--------------- .../concurrent/ConcurrentMapCacheTests.java | 3 +-- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java index a69b4c76b2a5..bac21dadf9fc 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java @@ -87,7 +87,7 @@ public void testManualProxyJavaWithStaticPointcutAndTwoClassLoaders() throws Exc testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, new TestServiceImpl(), "TestServiceImpl"); // Then try again with a different class loader on the target... - SimpleThrowawayClassLoader loader = new SimpleThrowawayClassLoader(new TestServiceImpl().getClass().getClassLoader()); + SimpleThrowawayClassLoader loader = new SimpleThrowawayClassLoader(TestServiceImpl.class.getClassLoader()); // Make sure the interface is loaded from the parent class loader loader.excludeClass(TestService.class.getName()); loader.excludeClass(TestException.class.getName()); diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CollectingReaderEventListener.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CollectingReaderEventListener.java index 63e2e20a4267..f5b6193e348b 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CollectingReaderEventListener.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/CollectingReaderEventListener.java @@ -70,11 +70,7 @@ public ComponentDefinition[] getComponentDefinitions() { @Override public void aliasRegistered(AliasDefinition aliasDefinition) { - List aliases = this.aliasMap.get(aliasDefinition.getBeanName()); - if (aliases == null) { - aliases = new ArrayList<>(); - this.aliasMap.put(aliasDefinition.getBeanName(), aliases); - } + List aliases = this.aliasMap.computeIfAbsent(aliasDefinition.getBeanName(), k -> new ArrayList<>()); aliases.add(aliasDefinition); } diff --git a/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java b/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java index e57bbab99d2d..2d75593e50da 100644 --- a/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java +++ b/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java @@ -113,11 +113,7 @@ private RootBeanDefinition parseDefinitionSource(Element definition, ParserConte builder.setUnless(getAttributeValue(opElement, "unless", "")); builder.setSync(Boolean.parseBoolean(getAttributeValue(opElement, "sync", "false"))); - Collection col = cacheOpMap.get(nameHolder); - if (col == null) { - col = new ArrayList<>(2); - cacheOpMap.put(nameHolder, col); - } + Collection col = cacheOpMap.computeIfAbsent(nameHolder, k -> new ArrayList<>(2)); col.add(builder.build()); } @@ -140,11 +136,7 @@ private RootBeanDefinition parseDefinitionSource(Element definition, ParserConte builder.setBeforeInvocation(Boolean.parseBoolean(after.trim())); } - Collection col = cacheOpMap.get(nameHolder); - if (col == null) { - col = new ArrayList<>(2); - cacheOpMap.put(nameHolder, col); - } + Collection col = cacheOpMap.computeIfAbsent(nameHolder, k -> new ArrayList<>(2)); col.add(builder.build()); } @@ -158,11 +150,7 @@ private RootBeanDefinition parseDefinitionSource(Element definition, ParserConte parserContext.getReaderContext(), new CachePutOperation.Builder()); builder.setUnless(getAttributeValue(opElement, "unless", "")); - Collection col = cacheOpMap.get(nameHolder); - if (col == null) { - col = new ArrayList<>(2); - cacheOpMap.put(nameHolder, col); - } + Collection col = cacheOpMap.computeIfAbsent(nameHolder, k -> new ArrayList<>(2)); col.add(builder.build()); } diff --git a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java index 5ac1d4b225ef..96715e5e3c41 100644 --- a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java +++ b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java @@ -85,8 +85,7 @@ public void testSerializer() { assertThat(serializeCache.isStoreByValue()).isTrue(); Object key = createRandomKey(); - List content = new ArrayList<>(); - content.addAll(Arrays.asList("one", "two", "three")); + List content = new ArrayList<>(Arrays.asList("one", "two", "three")); serializeCache.put(key, content); content.remove(0); List entry = (List) serializeCache.get(key).get(); From 9036cc689912b9a3dea8707fc5de5eb78ef4344b Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 17 Feb 2020 20:54:58 +0100 Subject: [PATCH 0440/2315] Remove unnecessary dependency on spring-orm Prior to this commit, spring-aspects would consider spring-orm as a module providing aspects, which is not the case (anymore). This commit removes that dependency as a result. Fixes gh-24491 --- spring-aspects/spring-aspects.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-aspects/spring-aspects.gradle b/spring-aspects/spring-aspects.gradle index d9b42ea4f712..12adbfb7e5f4 100644 --- a/spring-aspects/spring-aspects.gradle +++ b/spring-aspects/spring-aspects.gradle @@ -11,7 +11,6 @@ sourceSets.test.java.srcDirs = files() aspectj.version = dependencyManagement.managedVersions['org.aspectj:aspectjweaver'] dependencies { - aspect(project(":spring-orm")) compile("org.aspectj:aspectjweaver") compileOnly("org.aspectj:aspectjrt") optional(project(":spring-aop")) // for @Async support From df1145b797d1cdb4eb44343ad2cb9a2c26b9b499 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 12 Feb 2020 17:33:44 +0000 Subject: [PATCH 0441/2315] Correct documentation error in section on BeanWrapper Closes gh-24510 --- src/docs/asciidoc/core/core-validation.adoc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/docs/asciidoc/core/core-validation.adoc b/src/docs/asciidoc/core/core-validation.adoc index ca2783632979..05eda69536f3 100644 --- a/src/docs/asciidoc/core/core-validation.adoc +++ b/src/docs/asciidoc/core/core-validation.adoc @@ -278,11 +278,9 @@ perform actions on that bean, such as setting and retrieving properties. [[beans-beans-conventions]] === Setting and Getting Basic and Nested Properties -Setting and getting properties is done by using the `setPropertyValue`, -`setPropertyValues`, `getPropertyValue`, and `getPropertyValues` methods which come -with a couple of overloaded variants. Springs javadoc describes them in more detail. -The JavaBeans specification has conventions for indicating properties of an -object. The following table shows some examples of these conventions: +Setting and getting properties is done through the `setPropertyValue` and +`getPropertyValue` overloaded method variants of `BeanWrapper`. See their Javadoc for +details. The below table shows some examples of these conventions: [[beans-beans-conventions-properties-tbl]] .Examples of properties From fb6ee012815345285fafe081009fe2fb9f4a6589 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 14 Feb 2020 17:19:17 +0000 Subject: [PATCH 0442/2315] Consistently call setComplete before WS upgrade Even thought Tomcat and Jetty, which commit the response more lazily, were not impacted by this issue, it still makes sense for them to complete the WebFlux response (and pre-commit actions) at the same time as for other servers for consistent behavior. See gh-24475 --- .../upgrade/JettyRequestUpgradeStrategy.java | 27 +++++++++---------- .../ReactorNettyRequestUpgradeStrategy.java | 7 ++++- .../upgrade/TomcatRequestUpgradeStrategy.java | 20 ++++++-------- .../UndertowRequestUpgradeStrategy.java | 2 ++ 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/JettyRequestUpgradeStrategy.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/JettyRequestUpgradeStrategy.java index f5fe5cd5eced..ec41e8cf6c37 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/JettyRequestUpgradeStrategy.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/JettyRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -16,7 +16,6 @@ package org.springframework.web.reactive.socket.server.upgrade; -import java.io.IOException; import java.util.function.Supplier; import javax.servlet.ServletContext; @@ -162,18 +161,18 @@ public Mono upgrade(ServerWebExchange exchange, WebSocketHandler handler, boolean isUpgrade = this.factory.isUpgradeRequest(servletRequest, servletResponse); Assert.isTrue(isUpgrade, "Not a WebSocket handshake"); - try { - adapterHolder.set(new WebSocketHandlerContainer(adapter, subProtocol)); - this.factory.acceptWebSocket(servletRequest, servletResponse); - } - catch (IOException ex) { - return Mono.error(ex); - } - finally { - adapterHolder.remove(); - } - - return Mono.empty(); + // Trigger WebFlux preCommit actions and upgrade + return exchange.getResponse().setComplete() + .then(Mono.fromCallable(() -> { + try { + adapterHolder.set(new WebSocketHandlerContainer(adapter, subProtocol)); + this.factory.acceptWebSocket(servletRequest, servletResponse); + } + finally { + adapterHolder.remove(); + } + return null; + })); } private static HttpServletRequest getNativeRequest(ServerHttpRequest request) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java index f29c4f63564c..8753d4bc3242 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java @@ -103,8 +103,13 @@ public Mono upgrade(ServerWebExchange exchange, WebSocketHandler handler, HttpServerResponse reactorResponse = getNativeResponse(response); HandshakeInfo handshakeInfo = handshakeInfoFactory.get(); NettyDataBufferFactory bufferFactory = (NettyDataBufferFactory) response.bufferFactory(); + + // Trigger WebFlux preCommit actions and upgrade return response.setComplete() - .then(Mono.defer(() -> reactorResponse.sendWebsocket(subProtocol, this.maxFramePayloadLength, this.handlePing, + .then(Mono.defer(() -> reactorResponse.sendWebsocket( + subProtocol, + this.maxFramePayloadLength, + this.handlePing, (in, out) -> { ReactorNettyWebSocketSession session = new ReactorNettyWebSocketSession( diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/TomcatRequestUpgradeStrategy.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/TomcatRequestUpgradeStrategy.java index fb4ef36dd07e..ad56c0370f10 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/TomcatRequestUpgradeStrategy.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/TomcatRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -16,11 +16,9 @@ package org.springframework.web.reactive.socket.server.upgrade; -import java.io.IOException; import java.util.Collections; import java.util.function.Supplier; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.websocket.Endpoint; @@ -147,15 +145,13 @@ public Mono upgrade(ServerWebExchange exchange, WebSocketHandler handler, config.setSubprotocols(subProtocol != null ? Collections.singletonList(subProtocol) : Collections.emptyList()); - try { - WsServerContainer container = getContainer(servletRequest); - container.doUpgrade(servletRequest, servletResponse, config, Collections.emptyMap()); - } - catch (ServletException | IOException ex) { - return Mono.error(ex); - } - - return Mono.empty(); + // Trigger WebFlux preCommit actions and upgrade + return exchange.getResponse().setComplete() + .then(Mono.fromCallable(() -> { + WsServerContainer container = getContainer(servletRequest); + container.doUpgrade(servletRequest, servletResponse, config, Collections.emptyMap()); + return null; + })); } private static HttpServletRequest getNativeRequest(ServerHttpRequest request) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/UndertowRequestUpgradeStrategy.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/UndertowRequestUpgradeStrategy.java index 8307c8eed010..d57fb1b9481c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/UndertowRequestUpgradeStrategy.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/UndertowRequestUpgradeStrategy.java @@ -64,6 +64,8 @@ public Mono upgrade(ServerWebExchange exchange, WebSocketHandler handler, HandshakeInfo handshakeInfo = handshakeInfoFactory.get(); DataBufferFactory bufferFactory = exchange.getResponse().bufferFactory(); + + // Trigger WebFlux preCommit actions and upgrade return exchange.getResponse().setComplete() .then(Mono.fromCallable(() -> { DefaultCallback callback = new DefaultCallback(handshakeInfo, handler, bufferFactory); From 37ba57a92192de623cf2c699abd56e3be24b9dc6 Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Tue, 18 Feb 2020 20:24:10 +0900 Subject: [PATCH 0443/2315] Polish some test classes by using predefined constants Closes gh-24532 --- .../http/RequestEntityTests.java | 18 +++++++++--------- .../http/ResponseEntityTests.java | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java b/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java index bd9162733144..7d7101cf758e 100644 --- a/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -86,8 +86,8 @@ public void get() { assertThat(requestEntity).isNotNull(); assertThat(requestEntity.getMethod()).isEqualTo(HttpMethod.GET); - assertThat(requestEntity.getHeaders().containsKey("Accept")).isTrue(); - assertThat(requestEntity.getHeaders().getFirst("Accept")).isEqualTo("image/gif, image/jpeg, image/png"); + assertThat(requestEntity.getHeaders().containsKey(HttpHeaders.ACCEPT)).isTrue(); + assertThat(requestEntity.getHeaders().getFirst(HttpHeaders.ACCEPT)).isEqualTo("image/gif, image/jpeg, image/png"); assertThat(requestEntity.getBody()).isNull(); } @@ -114,12 +114,12 @@ public void headers() throws URISyntaxException { assertThat(responseEntity.getUrl()).isEqualTo(new URI("https://example.com")); HttpHeaders responseHeaders = responseEntity.getHeaders(); - assertThat(responseHeaders.getFirst("Accept")).isEqualTo("text/plain"); - assertThat(responseHeaders.getFirst("Accept-Charset")).isEqualTo("utf-8"); - assertThat(responseHeaders.getFirst("If-Modified-Since")).isEqualTo("Thu, 01 Jan 1970 00:00:12 GMT"); - assertThat(responseHeaders.getFirst("If-None-Match")).isEqualTo(ifNoneMatch); - assertThat(responseHeaders.getFirst("Content-Length")).isEqualTo(String.valueOf(contentLength)); - assertThat(responseHeaders.getFirst("Content-Type")).isEqualTo(contentType.toString()); + assertThat(responseHeaders.getFirst(HttpHeaders.ACCEPT)).isEqualTo(MediaType.TEXT_PLAIN_VALUE); + assertThat(responseHeaders.getFirst(HttpHeaders.ACCEPT_CHARSET)).isEqualTo("utf-8"); + assertThat(responseHeaders.getFirst(HttpHeaders.IF_MODIFIED_SINCE)).isEqualTo("Thu, 01 Jan 1970 00:00:12 GMT"); + assertThat(responseHeaders.getFirst(HttpHeaders.IF_NONE_MATCH)).isEqualTo(ifNoneMatch); + assertThat(responseHeaders.getFirst(HttpHeaders.CONTENT_LENGTH)).isEqualTo(String.valueOf(contentLength)); + assertThat(responseHeaders.getFirst(HttpHeaders.CONTENT_TYPE)).isEqualTo(contentType.toString()); assertThat(responseEntity.getBody()).isNull(); } diff --git a/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java b/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java index a06a291d1946..0bf7025f183b 100644 --- a/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -98,8 +98,8 @@ public void createdLocation() throws URISyntaxException { assertThat(responseEntity).isNotNull(); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED); - assertThat(responseEntity.getHeaders().containsKey("Location")).isTrue(); - assertThat(responseEntity.getHeaders().getFirst("Location")).isEqualTo(location.toString()); + assertThat(responseEntity.getHeaders().containsKey(HttpHeaders.LOCATION)).isTrue(); + assertThat(responseEntity.getHeaders().getFirst(HttpHeaders.LOCATION)).isEqualTo(location.toString()); assertThat(responseEntity.getBody()).isNull(); ResponseEntity.created(location).header("MyResponseHeader", "MyValue").body("Hello World"); @@ -178,11 +178,11 @@ public void headers() throws URISyntaxException { assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK); HttpHeaders responseHeaders = responseEntity.getHeaders(); - assertThat(responseHeaders.getFirst("Allow")).isEqualTo("GET"); - assertThat(responseHeaders.getFirst("Last-Modified")).isEqualTo("Thu, 01 Jan 1970 00:00:12 GMT"); - assertThat(responseHeaders.getFirst("Location")).isEqualTo(location.toASCIIString()); - assertThat(responseHeaders.getFirst("Content-Length")).isEqualTo(String.valueOf(contentLength)); - assertThat(responseHeaders.getFirst("Content-Type")).isEqualTo(contentType.toString()); + assertThat(responseHeaders.getFirst(HttpHeaders.ALLOW)).isEqualTo(HttpMethod.GET.name()); + assertThat(responseHeaders.getFirst(HttpHeaders.LAST_MODIFIED)).isEqualTo("Thu, 01 Jan 1970 00:00:12 GMT"); + assertThat(responseHeaders.getFirst(HttpHeaders.LOCATION)).isEqualTo(location.toASCIIString()); + assertThat(responseHeaders.getFirst(HttpHeaders.CONTENT_LENGTH)).isEqualTo(String.valueOf(contentLength)); + assertThat(responseHeaders.getFirst(HttpHeaders.CONTENT_TYPE)).isEqualTo(contentType.toString()); assertThat((Object) responseEntity.getBody()).isNull(); } From 87f866b68871049fe2706a5b916214244e969a65 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 18 Feb 2020 13:51:59 +0000 Subject: [PATCH 0444/2315] Update DigestUtils Javadoc with regards to InputStream Closes gh-24534 --- .../main/java/org/springframework/util/DigestUtils.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/DigestUtils.java b/spring-core/src/main/java/org/springframework/util/DigestUtils.java index 0be01a502c14..58c0ec1abce7 100644 --- a/spring-core/src/main/java/org/springframework/util/DigestUtils.java +++ b/spring-core/src/main/java/org/springframework/util/DigestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2020 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. @@ -51,7 +51,8 @@ public static byte[] md5Digest(byte[] bytes) { } /** - * Calculate the MD5 digest of the given stream. + * Calculate the MD5 digest of the given stream. This method does + * not close the input stream. * @param inputStream the InputStream to calculate the digest over * @return the digest * @since 4.2 @@ -71,6 +72,7 @@ public static String md5DigestAsHex(byte[] bytes) { /** * Return a hexadecimal string representation of the MD5 digest of the given stream. + * This method does not close the input stream. * @param inputStream the InputStream to calculate the digest over * @return a hexadecimal digest string * @since 4.2 @@ -92,7 +94,8 @@ public static StringBuilder appendMd5DigestAsHex(byte[] bytes, StringBuilder bui /** * Append a hexadecimal string representation of the MD5 digest of the given - * inputStream to the given {@link StringBuilder}. + * inputStream to the given {@link StringBuilder}. This method does + * not close the input stream. * @param inputStream the inputStream to calculate the digest over * @param builder the string builder to append the digest to * @return the given string builder From 68b980f8498a7a07004ed05547400f4997252bad Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 18 Feb 2020 21:50:38 +0000 Subject: [PATCH 0445/2315] Remove producible request attribute before mapping The attribute was previously removed only before exception resolution in the DispatcherServlet in order to allow error rendering to make an independent choice on content negotation. However, Boot rendering happens later in an ERROR dispatch which could also be a nested dispatch on some servers. So the attribute must also generally be removed prior to mapping. We also move the methods where this is done to the base RequestMappingInfoHandlerMapping class which also deals with the produces condition and where the producible attribute is added in the first place. Closes gh-24466 --- .../method/RequestMappingInfoHandlerMapping.java | 10 ++++++++++ .../annotation/RequestMappingHandlerMapping.java | 12 +----------- .../method/RequestMappingInfoHandlerMapping.java | 14 +++++++++++++- .../annotation/RequestMappingHandlerMapping.java | 11 ----------- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java index 3e66ed8c4862..eaccc2122297 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java @@ -27,6 +27,8 @@ import java.util.Set; import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.InvalidMediaTypeException; @@ -38,6 +40,7 @@ import org.springframework.web.method.HandlerMethod; import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.reactive.result.condition.NameValueExpression; +import org.springframework.web.reactive.result.condition.ProducesRequestCondition; import org.springframework.web.server.MethodNotAllowedException; import org.springframework.web.server.NotAcceptableStatusException; import org.springframework.web.server.ServerWebExchange; @@ -87,6 +90,13 @@ protected Comparator getMappingComparator(final ServerWebExc return (info1, info2) -> info1.compareTo(info2, exchange); } + @Override + public Mono getHandlerInternal(ServerWebExchange exchange) { + exchange.getAttributes().remove(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE); + return super.getHandlerInternal(exchange) + .doOnTerminate(() -> ProducesRequestCondition.clearMediaTypesAttribute(exchange)); + } + /** * Expose URI template variables, matrix variables, and producible media types in the request. * @see HandlerMapping#URI_TEMPLATE_VARIABLES_ATTRIBUTE diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java index e6e0751aba1a..fa82f405f746 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -24,8 +24,6 @@ import java.util.Map; import java.util.function.Predicate; -import reactor.core.publisher.Mono; - import org.springframework.context.EmbeddedValueResolverAware; import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.MergedAnnotation; @@ -45,11 +43,9 @@ import org.springframework.web.reactive.accept.RequestedContentTypeResolver; import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder; import org.springframework.web.reactive.result.condition.ConsumesRequestCondition; -import org.springframework.web.reactive.result.condition.ProducesRequestCondition; import org.springframework.web.reactive.result.condition.RequestCondition; import org.springframework.web.reactive.result.method.RequestMappingInfo; import org.springframework.web.reactive.result.method.RequestMappingInfoHandlerMapping; -import org.springframework.web.server.ServerWebExchange; /** * An extension of {@link RequestMappingInfoHandlerMapping} that creates @@ -356,10 +352,4 @@ private String resolveCorsAnnotationValue(String value) { } } - @Override - public Mono getHandlerInternal(ServerWebExchange exchange) { - return super.getHandlerInternal(exchange) - .doOnTerminate(() -> ProducesRequestCondition.clearMediaTypesAttribute(exchange)); - } - } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java index 6e352b233679..0d6bd808950e 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -45,6 +45,7 @@ import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.handler.AbstractHandlerMethodMapping; import org.springframework.web.servlet.mvc.condition.NameValueExpression; +import org.springframework.web.servlet.mvc.condition.ProducesRequestCondition; import org.springframework.web.util.WebUtils; /** @@ -102,6 +103,17 @@ protected Comparator getMappingComparator(final HttpServletR return (info1, info2) -> info1.compareTo(info2, request); } + @Override + protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception { + request.removeAttribute(PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE); + try { + return super.getHandlerInternal(request); + } + finally { + ProducesRequestCondition.clearMediaTypesAttribute(request); + } + } + /** * Expose URI template variables, matrix variables, and producible media types in the request. * @see HandlerMapping#URI_TEMPLATE_VARIABLES_ATTRIBUTE diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java index 5b6d42ed49e0..9b679e493818 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java @@ -49,7 +49,6 @@ import org.springframework.web.servlet.mvc.condition.AbstractRequestCondition; import org.springframework.web.servlet.mvc.condition.CompositeRequestCondition; import org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition; -import org.springframework.web.servlet.mvc.condition.ProducesRequestCondition; import org.springframework.web.servlet.mvc.condition.RequestCondition; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; @@ -473,14 +472,4 @@ private String resolveCorsAnnotationValue(String value) { } } - @Override - protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception { - try { - return super.getHandlerInternal(request); - } - finally { - ProducesRequestCondition.clearMediaTypesAttribute(request); - } - } - } From 2ad4602ca09797cd7de096d825415571742243df Mon Sep 17 00:00:00 2001 From: Sviatoslav Hryb Date: Wed, 19 Feb 2020 11:51:16 +0200 Subject: [PATCH 0446/2315] Correct Ant-style Patterns example in documentation Closes gh-24552 --- src/docs/asciidoc/core/core-resources.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/docs/asciidoc/core/core-resources.adoc b/src/docs/asciidoc/core/core-resources.adoc index 17ffdeba8c7a..ff2b1dd2cbfd 100644 --- a/src/docs/asciidoc/core/core-resources.adoc +++ b/src/docs/asciidoc/core/core-resources.adoc @@ -596,9 +596,9 @@ Path locations can contain Ant-style patterns, as the following example shows: [literal,subs="verbatim,quotes"] ---- -/WEB-INF/*-context.xml -com/mycompany/**/applicationContext.xml -file:C:/some/path/*-context.xml +/WEB-INF/\*-context.xml +com/mycompany/\**/applicationContext.xml +file:C:/some/path/\*-context.xml classpath:com/mycompany/**/applicationContext.xml ---- From acae174f8f0a9013b10b10a65e63c0caf2a28337 Mon Sep 17 00:00:00 2001 From: Qimiao Chen Date: Wed, 19 Feb 2020 18:04:25 +0800 Subject: [PATCH 0447/2315] Fix javadoc in DependencyDescriptor Closes gh-24551 --- .../beans/factory/config/DependencyDescriptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java index d63a3ddfc044..c934f89a3f8b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java @@ -371,7 +371,7 @@ public void initParameterNameDiscovery(@Nullable ParameterNameDiscoverer paramet /** * Determine the name of the wrapped parameter/field. - * @return the declared name (never {@code null}) + * @return the declared name (may be {@code null}) */ @Nullable public String getDependencyName() { From 8ff1ac59e0bb49a40c07cf785c6505e55ff41386 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 19 Feb 2020 11:08:10 +0100 Subject: [PATCH 0448/2315] Polishing --- .../java/org/springframework/util/DigestUtils.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/DigestUtils.java b/spring-core/src/main/java/org/springframework/util/DigestUtils.java index 58c0ec1abce7..b76a2b47995c 100644 --- a/spring-core/src/main/java/org/springframework/util/DigestUtils.java +++ b/spring-core/src/main/java/org/springframework/util/DigestUtils.java @@ -51,8 +51,8 @@ public static byte[] md5Digest(byte[] bytes) { } /** - * Calculate the MD5 digest of the given stream. This method does - * not close the input stream. + * Calculate the MD5 digest of the given stream. + *

    This method does not close the input stream. * @param inputStream the InputStream to calculate the digest over * @return the digest * @since 4.2 @@ -72,7 +72,7 @@ public static String md5DigestAsHex(byte[] bytes) { /** * Return a hexadecimal string representation of the MD5 digest of the given stream. - * This method does not close the input stream. + *

    This method does not close the input stream. * @param inputStream the InputStream to calculate the digest over * @return a hexadecimal digest string * @since 4.2 @@ -94,8 +94,8 @@ public static StringBuilder appendMd5DigestAsHex(byte[] bytes, StringBuilder bui /** * Append a hexadecimal string representation of the MD5 digest of the given - * inputStream to the given {@link StringBuilder}. This method does - * not close the input stream. + * inputStream to the given {@link StringBuilder}. + *

    This method does not close the input stream. * @param inputStream the inputStream to calculate the digest over * @param builder the string builder to append the digest to * @return the given string builder @@ -108,7 +108,7 @@ public static StringBuilder appendMd5DigestAsHex(InputStream inputStream, String /** * Create a new {@link MessageDigest} with the given algorithm. - * Necessary because {@code MessageDigest} is not thread-safe. + *

    Necessary because {@code MessageDigest} is not thread-safe. */ private static MessageDigest getDigest(String algorithm) { try { From e029dbf607468b65bc0811cc198fb771012d6da9 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 19 Feb 2020 11:46:03 +0100 Subject: [PATCH 0449/2315] Polish Javadoc for ClientHttpResponse --- .../http/client/ClientHttpResponse.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/client/ClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/ClientHttpResponse.java index b3b08c2350ea..f0ecff26ebdb 100644 --- a/spring-web/src/main/java/org/springframework/http/client/ClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/ClientHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -24,7 +24,8 @@ /** * Represents a client-side HTTP response. - * Obtained via an calling of the {@link ClientHttpRequest#execute()}. + * + *

    Obtained via an invocation of {@link ClientHttpRequest#execute()}. * *

    A {@code ClientHttpResponse} must be {@linkplain #close() closed}, * typically in a {@code finally} block. @@ -35,7 +36,9 @@ public interface ClientHttpResponse extends HttpInputMessage, Closeable { /** - * Return the HTTP status code as an {@link HttpStatus} enum value. + * Get the HTTP status code as an {@link HttpStatus} enum value. + *

    For status codes not supported by {@code HttpStatus}, use + * {@link #getRawStatusCode()} instead. * @return the HTTP status as an HttpStatus enum value (never {@code null}) * @throws IOException in case of I/O errors * @throws IllegalArgumentException in case of an unknown HTTP status code @@ -45,7 +48,7 @@ public interface ClientHttpResponse extends HttpInputMessage, Closeable { HttpStatus getStatusCode() throws IOException; /** - * Return the HTTP status code (potentially non-standard and not + * Get the HTTP status code (potentially non-standard and not * resolvable through the {@link HttpStatus} enum) as an integer. * @return the HTTP status as an integer value * @throws IOException in case of I/O errors @@ -56,7 +59,7 @@ public interface ClientHttpResponse extends HttpInputMessage, Closeable { int getRawStatusCode() throws IOException; /** - * Return the HTTP status text of the response. + * Get the HTTP status text of the response. * @return the HTTP status text * @throws IOException in case of I/O errors */ From 7528b9487d15fcdb4fbf86714bee32a99a0bed23 Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Thu, 20 Feb 2020 01:28:22 +0900 Subject: [PATCH 0450/2315] Simplify code in spring-test by using Collections.addAll Closes gh-24555 --- .../test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java | 7 +++---- .../htmlunit/MockMvcWebConnectionBuilderSupport.java | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java index e6a9f9f68ff6..6308d61603dd 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -22,6 +22,7 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.List; import java.util.Locale; @@ -291,9 +292,7 @@ private void cookies(MockHttpServletRequest request) { Cookie[] parentCookies = request.getCookies(); if (parentCookies != null) { - for (Cookie cookie : parentCookies) { - cookies.add(cookie); - } + Collections.addAll(cookies, parentCookies); } if (!ObjectUtils.isEmpty(cookies)) { diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionBuilderSupport.java b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionBuilderSupport.java index fa343d4fd518..fa4418e52329 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionBuilderSupport.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionBuilderSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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,6 +17,7 @@ package org.springframework.test.web.servlet.htmlunit; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import com.gargoylesoftware.htmlunit.WebClient; @@ -118,9 +119,7 @@ public T alwaysUseMockMvc() { */ @SuppressWarnings("unchecked") public T useMockMvc(WebRequestMatcher... matchers) { - for (WebRequestMatcher matcher : matchers) { - this.requestMatchers.add(matcher); - } + Collections.addAll(this.requestMatchers, matchers); return (T) this; } From 4882eb278d3ed71a75f0183c790228847b5bc08b Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 17 Feb 2020 15:08:34 +0100 Subject: [PATCH 0451/2315] Convert non-UTF-8 JSON Jackson's asynchronous parser does not support any encoding except UTF-8 (or ASCII). This commit converts non-UTF-8/ASCII encoded JSON to UTF-8. Closes gh-24489 --- .../codec/json/AbstractJackson2Decoder.java | 20 ++++++++- .../http/codec/json/Jackson2JsonDecoder.java | 45 ++++++++++++++++++- .../codec/json/Jackson2JsonDecoderTests.java | 32 ++++++++++++- 3 files changed, 94 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java index 2a2a50193148..351954a3ad6d 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java @@ -116,7 +116,8 @@ public Flux decode(Publisher input, ResolvableType elementTy forceUseOfBigDecimal = true; } - Flux tokens = Jackson2Tokenizer.tokenize(Flux.from(input), mapper.getFactory(), mapper, + Flux processed = processInput(input, elementType, mimeType, hints); + Flux tokens = Jackson2Tokenizer.tokenize(processed, mapper.getFactory(), mapper, true, forceUseOfBigDecimal, getMaxInMemorySize()); ObjectReader reader = getObjectReader(elementType, hints); @@ -135,6 +136,23 @@ public Flux decode(Publisher input, ResolvableType elementTy }); } + /** + * Process the input publisher into a flux. Default implementation returns + * {@link Flux#from(Publisher)}, but subclasses can choose to to customize + * this behaviour. + * @param input the {@code DataBuffer} input stream to process + * @param elementType the expected type of elements in the output stream + * @param mimeType the MIME type associated with the input stream (optional) + * @param hints additional information about how to do encode + * @return the processed flux + * @since 5.1.14 + */ + protected Flux processInput(Publisher input, ResolvableType elementType, + @Nullable MimeType mimeType, @Nullable Map hints) { + + return Flux.from(input); + } + @Override public Mono decodeToMono(Publisher input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map hints) { diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2JsonDecoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2JsonDecoder.java index b9372ff5831a..861fa05be268 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2JsonDecoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2JsonDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -16,10 +16,24 @@ package org.springframework.http.codec.json; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Map; + import com.fasterxml.jackson.databind.ObjectMapper; +import org.reactivestreams.Publisher; +import reactor.core.publisher.Flux; +import org.springframework.core.ResolvableType; +import org.springframework.core.codec.StringDecoder; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.io.buffer.DataBufferFactory; +import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import org.springframework.lang.Nullable; import org.springframework.util.MimeType; +import org.springframework.util.MimeTypeUtils; /** * Decode a byte stream into JSON and convert to Object's with Jackson 2.9, @@ -32,6 +46,11 @@ */ public class Jackson2JsonDecoder extends AbstractJackson2Decoder { + private static final StringDecoder STRING_DECODER = StringDecoder.textPlainOnly(Arrays.asList(",", "\n"), false); + + private static final ResolvableType STRING_TYPE = ResolvableType.forClass(String.class); + + public Jackson2JsonDecoder() { super(Jackson2ObjectMapperBuilder.json().build()); } @@ -40,4 +59,28 @@ public Jackson2JsonDecoder(ObjectMapper mapper, MimeType... mimeTypes) { super(mapper, mimeTypes); } + @Override + protected Flux processInput(Publisher input, ResolvableType elementType, + @Nullable MimeType mimeType, @Nullable Map hints) { + + Flux flux = Flux.from(input); + if (mimeType == null) { + return flux; + } + + // Jackson asynchronous parser only supports UTF-8 + Charset charset = mimeType.getCharset(); + if (charset == null || StandardCharsets.UTF_8.equals(charset) || StandardCharsets.US_ASCII.equals(charset)) { + return flux; + } + + // Potentially, the memory consumption of this conversion could be improved by using CharBuffers instead + // of allocating Strings, but that would require refactoring the buffer tokenization code from StringDecoder + + MimeType textMimeType = new MimeType(MimeTypeUtils.TEXT_PLAIN, charset); + Flux decoded = STRING_DECODER.decode(input, STRING_TYPE, textMimeType, null); + DataBufferFactory factory = new DefaultDataBufferFactory(); + return decoded.map(s -> factory.wrap(s.getBytes(StandardCharsets.UTF_8))); + } + } diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java index a69c5bab3a45..8bcc27c3c7fa 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java @@ -18,6 +18,7 @@ import java.io.IOException; import java.math.BigDecimal; +import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; @@ -34,6 +35,7 @@ import reactor.core.publisher.Mono; import reactor.test.StepVerifier; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ResolvableType; import org.springframework.core.codec.CodecException; import org.springframework.core.codec.DecodingException; @@ -216,9 +218,37 @@ public void bigDecimalFlux() { ); } + @Test + public void decodeNonUtf8Encoding() { + Mono input = stringBuffer("{\"foo\":\"bar\"}", StandardCharsets.UTF_16); + + testDecode(input, ResolvableType.forType(new ParameterizedTypeReference>() { + }), + step -> step.assertNext(o -> assertThat((Map) o).containsEntry("foo", "bar")) + .verifyComplete(), + MediaType.parseMediaType("application/json; charset=utf-16"), + null); + } + + @Test + public void decodeMonoNonUtf8Encoding() { + Mono input = stringBuffer("{\"foo\":\"bar\"}", StandardCharsets.UTF_16); + + testDecodeToMono(input, ResolvableType.forType(new ParameterizedTypeReference>() { + }), + step -> step.assertNext(o -> assertThat((Map) o).containsEntry("foo", "bar")) + .verifyComplete(), + MediaType.parseMediaType("application/json; charset=utf-16"), + null); + } + private Mono stringBuffer(String value) { + return stringBuffer(value, StandardCharsets.UTF_8); + } + + private Mono stringBuffer(String value, Charset charset) { return Mono.defer(() -> { - byte[] bytes = value.getBytes(StandardCharsets.UTF_8); + byte[] bytes = value.getBytes(charset); DataBuffer buffer = this.bufferFactory.allocateBuffer(bytes.length); buffer.write(bytes); return Mono.just(buffer); From a134e92e7f382dd78b0542aec07aa66519222c4f Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 20 Feb 2020 10:54:58 +0000 Subject: [PATCH 0452/2315] Improve checks on URI string in MockMvc request builder Closes gh-24556 --- .../request/MockHttpServletRequestBuilder.java | 11 +++++++++-- .../request/MockHttpServletRequestBuilderTests.java | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java index ef178c394bb6..e315c948a8a6 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -145,7 +145,14 @@ public class MockHttpServletRequestBuilder * @param vars zero or more URI variables */ MockHttpServletRequestBuilder(HttpMethod httpMethod, String url, Object... vars) { - this(httpMethod.name(), UriComponentsBuilder.fromUriString(url).buildAndExpand(vars).encode().toUri()); + this(httpMethod.name(), initUri(url, vars)); + } + + private static URI initUri(String url, Object[] vars) { + Assert.notNull(url, "'url' must not be null"); + Assert.isTrue(url.startsWith("/") || url.startsWith("http://") || url.startsWith("https://"), "" + + "'url' should start with a path or be a complete HTTP URL: " + url); + return UriComponentsBuilder.fromUriString(url).buildAndExpand(vars).encode().toUri(); } /** diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java index 17fb123acec3..47f51e1046f8 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -49,6 +49,7 @@ import org.springframework.web.util.UriComponentsBuilder; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; /** * Unit tests for building a {@link MockHttpServletRequest} with @@ -88,7 +89,8 @@ public void uri() { assertThat(request.getServerName()).isEqualTo("java.sun.com"); assertThat(request.getServerPort()).isEqualTo(8080); assertThat(request.getRequestURI()).isEqualTo("/javase/6/docs/api/java/util/BitSet.html"); - assertThat(request.getRequestURL().toString()).isEqualTo("https://java.sun.com:8080/javase/6/docs/api/java/util/BitSet.html"); + assertThat(request.getRequestURL().toString()) + .isEqualTo("https://java.sun.com:8080/javase/6/docs/api/java/util/BitSet.html"); } @Test @@ -107,6 +109,12 @@ public void requestUriWithDoubleSlashes() throws URISyntaxException { assertThat(request.getRequestURI()).isEqualTo("/test//currentlyValid/0"); } + @Test // gh-24556 + public void requestUriWithoutScheme() { + assertThatIllegalArgumentException().isThrownBy(() -> MockMvcRequestBuilders.get("localhost:8080/path")) + .withMessage("'url' should start with a path or be a complete HTTP URL: localhost:8080/path"); + } + @Test public void contextPathEmpty() { this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/foo"); From ae9268004ddbf462fd16db6aa9f06065ed4de1cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Gru=CC=88ndler?= Date: Thu, 13 Feb 2020 08:36:00 +0100 Subject: [PATCH 0453/2315] Added debug logging to DefaultWebSessionManager See gh-24518 --- .../server/session/DefaultWebSessionManager.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/spring-web/src/main/java/org/springframework/web/server/session/DefaultWebSessionManager.java b/spring-web/src/main/java/org/springframework/web/server/session/DefaultWebSessionManager.java index 60e2d4352a5d..1236f3d777f7 100644 --- a/spring-web/src/main/java/org/springframework/web/server/session/DefaultWebSessionManager.java +++ b/spring-web/src/main/java/org/springframework/web/server/session/DefaultWebSessionManager.java @@ -18,10 +18,13 @@ import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import org.springframework.util.Assert; +import org.springframework.web.context.request.async.WebAsyncManager; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebSession; @@ -36,6 +39,8 @@ */ public class DefaultWebSessionManager implements WebSessionManager { + private static final Log logger = LogFactory.getLog(DefaultWebSessionManager.class); + private WebSessionIdResolver sessionIdResolver = new CookieWebSessionIdResolver(); private WebSessionStore sessionStore = new InMemoryWebSessionStore(); @@ -79,7 +84,12 @@ public WebSessionStore getSessionStore() { @Override public Mono getSession(ServerWebExchange exchange) { return Mono.defer(() -> retrieveSession(exchange) - .switchIfEmpty(this.sessionStore.createWebSession()) + .switchIfEmpty(Mono.defer(() -> { + if (logger.isDebugEnabled()) { + logger.debug("Did not find an existing WebSession, creating a new one."); + } + return this.sessionStore.createWebSession(); + })) .doOnNext(session -> exchange.getResponse().beforeCommit(() -> save(exchange, session)))); } @@ -95,6 +105,9 @@ private Mono save(ServerWebExchange exchange, WebSession session) { if (!session.isStarted() || session.isExpired()) { if (!ids.isEmpty()) { // Expired on retrieve or while processing request, or invalidated.. + if (logger.isDebugEnabled()) { + logger.debug("Expiring existing sessionIds while saving session."); + } this.sessionIdResolver.expireSession(exchange); } return Mono.empty(); From de608a08ed9517a64cfc279810cbb55071017490 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 20 Feb 2020 15:54:19 +0000 Subject: [PATCH 0454/2315] Polishing contribution See gh-24518 --- .../session/DefaultWebSessionManager.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/server/session/DefaultWebSessionManager.java b/spring-web/src/main/java/org/springframework/web/server/session/DefaultWebSessionManager.java index 1236f3d777f7..cde58e392ea6 100644 --- a/spring-web/src/main/java/org/springframework/web/server/session/DefaultWebSessionManager.java +++ b/spring-web/src/main/java/org/springframework/web/server/session/DefaultWebSessionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -24,7 +24,6 @@ import reactor.core.publisher.Mono; import org.springframework.util.Assert; -import org.springframework.web.context.request.async.WebAsyncManager; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebSession; @@ -41,6 +40,7 @@ public class DefaultWebSessionManager implements WebSessionManager { private static final Log logger = LogFactory.getLog(DefaultWebSessionManager.class); + private WebSessionIdResolver sessionIdResolver = new CookieWebSessionIdResolver(); private WebSessionStore sessionStore = new InMemoryWebSessionStore(); @@ -84,15 +84,18 @@ public WebSessionStore getSessionStore() { @Override public Mono getSession(ServerWebExchange exchange) { return Mono.defer(() -> retrieveSession(exchange) - .switchIfEmpty(Mono.defer(() -> { - if (logger.isDebugEnabled()) { - logger.debug("Did not find an existing WebSession, creating a new one."); - } - return this.sessionStore.createWebSession(); - })) + .switchIfEmpty(createWebSession()) .doOnNext(session -> exchange.getResponse().beforeCommit(() -> save(exchange, session)))); } + private Mono createWebSession() { + Mono session = this.sessionStore.createWebSession(); + if (logger.isDebugEnabled()) { + session = session.doOnNext(s -> logger.debug("Created new WebSession.")); + } + return session; + } + private Mono retrieveSession(ServerWebExchange exchange) { return Flux.fromIterable(getSessionIdResolver().resolveSessionIds(exchange)) .concatMap(this.sessionStore::retrieveSession) @@ -106,7 +109,7 @@ private Mono save(ServerWebExchange exchange, WebSession session) { if (!ids.isEmpty()) { // Expired on retrieve or while processing request, or invalidated.. if (logger.isDebugEnabled()) { - logger.debug("Expiring existing sessionIds while saving session."); + logger.debug("WebSession expired or has been invalidated"); } this.sessionIdResolver.expireSession(exchange); } From 96e77d417bb7311e860a5c2cd9cb1e55506c6d06 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 20 Feb 2020 16:28:22 +0000 Subject: [PATCH 0455/2315] Update WebFlux section on HTTP/2 Closes gh-24558 --- src/docs/asciidoc/web/webflux.adoc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index 2a001476bc08..7094f135754b 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -4268,11 +4268,6 @@ the classpath. == HTTP/2 [.small]#<># -Servlet 4 containers are required to support HTTP/2, and Spring Framework 5 is compatible -with Servlet API 4. From a programming model perspective, there is nothing specific that -applications need to do. However, there are considerations related to server configuration. -For more details, see the +HTTP/2 is supported with Reactor Netty, Tomcat, Jetty, and Undertow. However, there are +considerations related to server configuration. For more details, see the https://github.com/spring-projects/spring-framework/wiki/HTTP-2-support[HTTP/2 wiki page]. - -Currently, Spring WebFlux does not support HTTP/2 with Netty. There is also no support for -pushing resources programmatically to the client. From 97ba00eff263a63d302bb72b83f444275ddc4e9c Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 20 Feb 2020 17:28:15 +0000 Subject: [PATCH 0456/2315] Use try-with-resource in XmlBeanDefinitionReader Closes gh-24492 --- .../factory/xml/XmlBeanDefinitionReader.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java index 05501d3ce0dd..f6e87a15ac5a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -327,18 +327,13 @@ public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefin throw new BeanDefinitionStoreException( "Detected cyclic loading of " + encodedResource + " - check your import definitions!"); } - try { - InputStream inputStream = encodedResource.getResource().getInputStream(); - try { - InputSource inputSource = new InputSource(inputStream); - if (encodedResource.getEncoding() != null) { - inputSource.setEncoding(encodedResource.getEncoding()); - } - return doLoadBeanDefinitions(inputSource, encodedResource.getResource()); - } - finally { - inputStream.close(); + + try (InputStream inputStream = encodedResource.getResource().getInputStream()) { + InputSource inputSource = new InputSource(inputStream); + if (encodedResource.getEncoding() != null) { + inputSource.setEncoding(encodedResource.getEncoding()); } + return doLoadBeanDefinitions(inputSource, encodedResource.getResource()); } catch (IOException ex) { throw new BeanDefinitionStoreException( From a09f02f64e89edd88d5c6a6e0e23f290d0461efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=85=B6=E8=8B=97?= Date: Sun, 9 Feb 2020 15:32:23 +0800 Subject: [PATCH 0457/2315] Minor refactoring in AbstractPlatformTransactionManager See gh-24493 --- .../AbstractPlatformTransactionManager.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java b/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java index 5a11d8f2201b..c27156a33ca8 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java +++ b/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.core.Constants; +import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; import org.springframework.transaction.IllegalTransactionStateException; import org.springframework.transaction.InvalidTimeoutException; @@ -370,12 +371,7 @@ else if (def.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUI logger.debug("Creating new transaction with name [" + def.getName() + "]: " + def); } try { - boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER); - DefaultTransactionStatus status = newTransactionStatus( - def, transaction, true, newSynchronization, debugEnabled, suspendedResources); - doBegin(transaction, def); - prepareSynchronization(status, def); - return status; + return openNewTransaction(def, transaction, debugEnabled, suspendedResources); } catch (RuntimeException | Error ex) { resume(null, suspendedResources); @@ -393,6 +389,20 @@ else if (def.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUI } } + /** + * Open a new transaction with transaction definition. + */ + @NonNull + private TransactionStatus openNewTransaction(TransactionDefinition def, Object transaction, + boolean debugEnabled, @Nullable SuspendedResourcesHolder suspendedResources) { + boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER); + DefaultTransactionStatus status = newTransactionStatus( + def, transaction, true, newSynchronization, debugEnabled, suspendedResources); + doBegin(transaction, def); + prepareSynchronization(status, def); + return status; + } + /** * Create a TransactionStatus for an existing transaction. */ @@ -422,12 +432,7 @@ private TransactionStatus handleExistingTransaction( } SuspendedResourcesHolder suspendedResources = suspend(transaction); try { - boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER); - DefaultTransactionStatus status = newTransactionStatus( - definition, transaction, true, newSynchronization, debugEnabled, suspendedResources); - doBegin(transaction, definition); - prepareSynchronization(status, definition); - return status; + return openNewTransaction(definition, transaction, debugEnabled, suspendedResources); } catch (RuntimeException | Error beginEx) { resumeAfterBeginException(transaction, suspendedResources, beginEx); @@ -457,12 +462,7 @@ private TransactionStatus handleExistingTransaction( // Nested transaction through nested begin and commit/rollback calls. // Usually only for JTA: Spring synchronization might get activated here // in case of a pre-existing JTA transaction. - boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER); - DefaultTransactionStatus status = newTransactionStatus( - definition, transaction, true, newSynchronization, debugEnabled, null); - doBegin(transaction, definition); - prepareSynchronization(status, definition); - return status; + return openNewTransaction(definition, transaction, debugEnabled, null); } } From adc13f203030d56dc5e0ed870879f0814cd68a53 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 20 Feb 2020 17:58:47 +0000 Subject: [PATCH 0458/2315] Polishing contribution See gh-24493 --- .../AbstractPlatformTransactionManager.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java b/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java index c27156a33ca8..3617ca8c4875 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java +++ b/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java @@ -25,7 +25,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.core.Constants; -import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; import org.springframework.transaction.IllegalTransactionStateException; import org.springframework.transaction.InvalidTimeoutException; @@ -371,7 +370,7 @@ else if (def.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUI logger.debug("Creating new transaction with name [" + def.getName() + "]: " + def); } try { - return openNewTransaction(def, transaction, debugEnabled, suspendedResources); + return startTransaction(def, transaction, debugEnabled, suspendedResources); } catch (RuntimeException | Error ex) { resume(null, suspendedResources); @@ -390,16 +389,16 @@ else if (def.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUI } /** - * Open a new transaction with transaction definition. + * Start a new transaction. */ - @NonNull - private TransactionStatus openNewTransaction(TransactionDefinition def, Object transaction, + private TransactionStatus startTransaction(TransactionDefinition definition, Object transaction, boolean debugEnabled, @Nullable SuspendedResourcesHolder suspendedResources) { + boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER); DefaultTransactionStatus status = newTransactionStatus( - def, transaction, true, newSynchronization, debugEnabled, suspendedResources); - doBegin(transaction, def); - prepareSynchronization(status, def); + definition, transaction, true, newSynchronization, debugEnabled, suspendedResources); + doBegin(transaction, definition); + prepareSynchronization(status, definition); return status; } @@ -432,7 +431,7 @@ private TransactionStatus handleExistingTransaction( } SuspendedResourcesHolder suspendedResources = suspend(transaction); try { - return openNewTransaction(definition, transaction, debugEnabled, suspendedResources); + return startTransaction(definition, transaction, debugEnabled, suspendedResources); } catch (RuntimeException | Error beginEx) { resumeAfterBeginException(transaction, suspendedResources, beginEx); @@ -462,7 +461,7 @@ private TransactionStatus handleExistingTransaction( // Nested transaction through nested begin and commit/rollback calls. // Usually only for JTA: Spring synchronization might get activated here // in case of a pre-existing JTA transaction. - return openNewTransaction(definition, transaction, debugEnabled, null); + return startTransaction(definition, transaction, debugEnabled, null); } } From f78c21e40b99707827e815efd06de7f92cfc5f70 Mon Sep 17 00:00:00 2001 From: Qimiao Chen Date: Sun, 23 Feb 2020 01:32:02 +0800 Subject: [PATCH 0459/2315] Fix typos in tests Closes gh-24566 --- .../core/annotation/AnnotationsScannerTests.java | 10 +++++----- .../core/annotation/MergedAnnotationsTests.java | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationsScannerTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationsScannerTests.java index 190b0b333040..4c60994d324d 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationsScannerTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationsScannerTests.java @@ -45,7 +45,7 @@ class AnnotationsScannerTests { @Test - void directStrategyOnClassWhenNotAnnoatedScansNone() { + void directStrategyOnClassWhenNotAnnotatedScansNone() { Class source = WithNoAnnotations.class; assertThat(scan(source, SearchStrategy.DIRECT)).isEmpty(); } @@ -423,7 +423,7 @@ void dirextStrategyOnBridgedMethodScansAnnotations() throws Exception { @Test void typeHierarchyStrategyOnMethodWithIgnorablesScansAnnotations() throws Exception { - Method source = methodFrom(Ignoreable.class); + Method source = methodFrom(Ignorable.class); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( "0:TestAnnotation1"); } @@ -752,7 +752,7 @@ interface BridgeMethod { } @SuppressWarnings("serial") - static class Ignoreable implements IgnoreableOverrideInterface1, IgnoreableOverrideInterface2, Serializable { + static class Ignorable implements IgnorableOverrideInterface1, IgnorableOverrideInterface2, Serializable { @Override @TestAnnotation1 @@ -760,13 +760,13 @@ public void method() { } } - interface IgnoreableOverrideInterface1 { + interface IgnorableOverrideInterface1 { @Nullable void method(); } - interface IgnoreableOverrideInterface2 { + interface IgnorableOverrideInterface2 { @Nullable void method(); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java index 4b6ab16ca923..9bbc20e95722 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java @@ -338,8 +338,8 @@ void getWithInheritedAnnotationsAttributesWithConventionBasedComposedAnnotation( @Test void getWithInheritedAnnotationsFromHalfConventionBasedAndHalfAliasedComposedAnnotation1() { - // SPR-13554: convention mapping mixed with AlaisFor annotations - // xmlConfigFiles can be used because it has an AlaisFor annotation + // SPR-13554: convention mapping mixed with AliasFor annotations + // xmlConfigFiles can be used because it has an AliasFor annotation MergedAnnotation annotation = MergedAnnotations.from( HalfConventionBasedAndHalfAliasedComposedContextConfigurationClass1.class, SearchStrategy.INHERITED_ANNOTATIONS).get(ContextConfiguration.class); @@ -351,8 +351,8 @@ void getWithInheritedAnnotationsFromHalfConventionBasedAndHalfAliasedComposedAnn @Test void withInheritedAnnotationsFromHalfConventionBasedAndHalfAliasedComposedAnnotation2() { - // SPR-13554: convention mapping mixed with AlaisFor annotations - // locations doesn't apply because it has no AlaisFor annotation + // SPR-13554: convention mapping mixed with AliasFor annotations + // locations doesn't apply because it has no AliasFor annotation MergedAnnotation annotation = MergedAnnotations.from( HalfConventionBasedAndHalfAliasedComposedContextConfigurationClass2.class, SearchStrategy.INHERITED_ANNOTATIONS).get(ContextConfiguration.class); From 809ed9d46989c47c5ca58e17de4397de8a5a32f8 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 23 Feb 2020 18:21:53 +0100 Subject: [PATCH 0460/2315] Rename PropertyResolverExtensionsTests to Kotlin* --- ...sionsTests.kt => KotlinPropertyResolverExtensionsTests.kt} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename spring-core/src/test/kotlin/org/springframework/core/env/{PropertyResolverExtensionsTests.kt => KotlinPropertyResolverExtensionsTests.kt} (93%) diff --git a/spring-core/src/test/kotlin/org/springframework/core/env/PropertyResolverExtensionsTests.kt b/spring-core/src/test/kotlin/org/springframework/core/env/KotlinPropertyResolverExtensionsTests.kt similarity index 93% rename from spring-core/src/test/kotlin/org/springframework/core/env/PropertyResolverExtensionsTests.kt rename to spring-core/src/test/kotlin/org/springframework/core/env/KotlinPropertyResolverExtensionsTests.kt index 54a867ea1861..631017379c0b 100644 --- a/spring-core/src/test/kotlin/org/springframework/core/env/PropertyResolverExtensionsTests.kt +++ b/spring-core/src/test/kotlin/org/springframework/core/env/KotlinPropertyResolverExtensionsTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test * * @author Sebastien Deleuze */ -class PropertyResolverExtensionsTests { +class KotlinPropertyResolverExtensionsTests { val propertyResolver = mockk() From d1a6e494750a3ec39a79f047601c279de96ff99f Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 23 Feb 2020 18:33:56 +0100 Subject: [PATCH 0461/2315] Reset SecurityManager in finally-block and polish --- .../core/env/StandardEnvironmentTests.java | 136 +++++++++--------- 1 file changed, 66 insertions(+), 70 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java index ee87b557100d..acd6d84acabb 100644 --- a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -38,6 +38,7 @@ * * @author Chris Beams * @author Juergen Hoeller + * @author Sam Brannen */ @SuppressWarnings("deprecation") public class StandardEnvironmentTests { @@ -134,50 +135,42 @@ void setActiveProfiles() { @Test void setActiveProfiles_withNullProfileArray() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.setActiveProfiles((String[]) null)); + assertThatIllegalArgumentException().isThrownBy(() -> environment.setActiveProfiles((String[]) null)); } @Test void setActiveProfiles_withNullProfile() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.setActiveProfiles((String) null)); + assertThatIllegalArgumentException().isThrownBy(() -> environment.setActiveProfiles((String) null)); } @Test void setActiveProfiles_withEmptyProfile() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.setActiveProfiles("")); + assertThatIllegalArgumentException().isThrownBy(() -> environment.setActiveProfiles("")); } @Test void setActiveProfiles_withNotOperator() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.setActiveProfiles("p1", "!p2")); + assertThatIllegalArgumentException().isThrownBy(() -> environment.setActiveProfiles("p1", "!p2")); } @Test void setDefaultProfiles_withNullProfileArray() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.setDefaultProfiles((String[]) null)); + assertThatIllegalArgumentException().isThrownBy(() -> environment.setDefaultProfiles((String[]) null)); } @Test void setDefaultProfiles_withNullProfile() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.setDefaultProfiles((String) null)); + assertThatIllegalArgumentException().isThrownBy(() -> environment.setDefaultProfiles((String) null)); } @Test void setDefaultProfiles_withEmptyProfile() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.setDefaultProfiles("")); + assertThatIllegalArgumentException().isThrownBy(() -> environment.setDefaultProfiles("")); } @Test void setDefaultProfiles_withNotOperator() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.setDefaultProfiles("d1", "!d2")); + assertThatIllegalArgumentException().isThrownBy(() -> environment.setDefaultProfiles("d1", "!d2")); } @Test @@ -212,18 +205,17 @@ void reservedDefaultProfile() { assertThat(environment.getDefaultProfiles()).isEqualTo(new String[]{"d0"}); environment.setDefaultProfiles("d1", "d2"); assertThat(environment.getDefaultProfiles()).isEqualTo(new String[]{"d1","d2"}); - System.getProperties().remove(DEFAULT_PROFILES_PROPERTY_NAME); + System.clearProperty(DEFAULT_PROFILES_PROPERTY_NAME); } @Test void defaultProfileWithCircularPlaceholder() { - System.setProperty(DEFAULT_PROFILES_PROPERTY_NAME, "${spring.profiles.default}"); try { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.getDefaultProfiles()); + System.setProperty(DEFAULT_PROFILES_PROPERTY_NAME, "${spring.profiles.default}"); + assertThatIllegalArgumentException().isThrownBy(() -> environment.getDefaultProfiles()); } finally { - System.getProperties().remove(DEFAULT_PROFILES_PROPERTY_NAME); + System.clearProperty(DEFAULT_PROFILES_PROPERTY_NAME); } } @@ -232,28 +224,28 @@ void getActiveProfiles_systemPropertiesEmpty() { assertThat(environment.getActiveProfiles().length).isEqualTo(0); System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, ""); assertThat(environment.getActiveProfiles().length).isEqualTo(0); - System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME); + System.clearProperty(ACTIVE_PROFILES_PROPERTY_NAME); } @Test void getActiveProfiles_fromSystemProperties() { System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, "foo"); assertThat(Arrays.asList(environment.getActiveProfiles())).contains("foo"); - System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME); + System.clearProperty(ACTIVE_PROFILES_PROPERTY_NAME); } @Test void getActiveProfiles_fromSystemProperties_withMultipleProfiles() { System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, "foo,bar"); assertThat(environment.getActiveProfiles()).contains("foo", "bar"); - System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME); + System.clearProperty(ACTIVE_PROFILES_PROPERTY_NAME); } @Test void getActiveProfiles_fromSystemProperties_withMulitpleProfiles_withWhitespace() { System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, " bar , baz "); // notice whitespace assertThat(environment.getActiveProfiles()).contains("bar", "baz"); - System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME); + System.clearProperty(ACTIVE_PROFILES_PROPERTY_NAME); } @Test @@ -283,20 +275,17 @@ void acceptsProfiles_withEmptyArgumentList() { @Test void acceptsProfiles_withNullArgumentList() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.acceptsProfiles((String[]) null)); + assertThatIllegalArgumentException().isThrownBy(() -> environment.acceptsProfiles((String[]) null)); } @Test void acceptsProfiles_withNullArgument() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.acceptsProfiles((String) null)); + assertThatIllegalArgumentException().isThrownBy(() -> environment.acceptsProfiles((String) null)); } @Test void acceptsProfiles_withEmptyArgument() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.acceptsProfiles("")); + assertThatIllegalArgumentException().isThrownBy(() -> environment.acceptsProfiles("")); } @Test @@ -338,8 +327,7 @@ void acceptsProfiles_withNotOperator() { @Test void acceptsProfiles_withInvalidNotOperator() { - assertThatIllegalArgumentException().isThrownBy(() -> - environment.acceptsProfiles("p1", "!")); + assertThatIllegalArgumentException().isThrownBy(() -> environment.acceptsProfiles("p1", "!")); } @Test @@ -431,35 +419,39 @@ public void checkPermission(Permission perm) { // allow everything else } }; - System.setSecurityManager(securityManager); - { - Map systemProperties = environment.getSystemProperties(); - assertThat(systemProperties).isNotNull(); - assertThat(systemProperties).isInstanceOf(ReadOnlySystemAttributesMap.class); - assertThat((String)systemProperties.get(ALLOWED_PROPERTY_NAME)).isEqualTo(ALLOWED_PROPERTY_VALUE); - assertThat(systemProperties.get(DISALLOWED_PROPERTY_NAME)).isNull(); - - // nothing we can do here in terms of warning the user that there was - // actually a (non-string) value available. By this point, we only - // have access to calling System.getProperty(), which itself returns null - // if the value is non-string. So we're stuck with returning a potentially - // misleading null. - assertThat(systemProperties.get(STRING_PROPERTY_NAME)).isNull(); - - // in the case of a non-string *key*, however, we can do better. Alert - // the user that under these very special conditions (non-object key + - // SecurityManager that disallows access to system properties), they - // cannot do what they're attempting. - assertThatIllegalArgumentException().as("searching with non-string key against ReadOnlySystemAttributesMap").isThrownBy(() -> - systemProperties.get(NON_STRING_PROPERTY_NAME)); + try { + System.setSecurityManager(securityManager); + + { + Map systemProperties = environment.getSystemProperties(); + assertThat(systemProperties).isNotNull(); + assertThat(systemProperties).isInstanceOf(ReadOnlySystemAttributesMap.class); + assertThat((String)systemProperties.get(ALLOWED_PROPERTY_NAME)).isEqualTo(ALLOWED_PROPERTY_VALUE); + assertThat(systemProperties.get(DISALLOWED_PROPERTY_NAME)).isNull(); + + // nothing we can do here in terms of warning the user that there was + // actually a (non-string) value available. By this point, we only + // have access to calling System.getProperty(), which itself returns null + // if the value is non-string. So we're stuck with returning a potentially + // misleading null. + assertThat(systemProperties.get(STRING_PROPERTY_NAME)).isNull(); + + // in the case of a non-string *key*, however, we can do better. Alert + // the user that under these very special conditions (non-object key + + // SecurityManager that disallows access to system properties), they + // cannot do what they're attempting. + assertThatIllegalArgumentException().as("searching with non-string key against ReadOnlySystemAttributesMap").isThrownBy(() -> + systemProperties.get(NON_STRING_PROPERTY_NAME)); + } + } + finally { + System.setSecurityManager(oldSecurityManager); + System.clearProperty(ALLOWED_PROPERTY_NAME); + System.clearProperty(DISALLOWED_PROPERTY_NAME); + System.getProperties().remove(STRING_PROPERTY_NAME); + System.getProperties().remove(NON_STRING_PROPERTY_NAME); } - - System.setSecurityManager(oldSecurityManager); - System.clearProperty(ALLOWED_PROPERTY_NAME); - System.clearProperty(DISALLOWED_PROPERTY_NAME); - System.getProperties().remove(STRING_PROPERTY_NAME); - System.getProperties().remove(NON_STRING_PROPERTY_NAME); } @Test @@ -484,21 +476,25 @@ public void checkPermission(Permission perm) { //see https://download.oracle.com/javase/1.5.0/docs/api/java/lang/System.html#getenv(java.lang.String) if (("getenv."+DISALLOWED_PROPERTY_NAME).equals(perm.getName())) { throw new AccessControlException( - String.format("Accessing the system environment variable [%s] is disallowed", DISALLOWED_PROPERTY_NAME)); + String.format("Accessing the system environment variable [%s] is disallowed", DISALLOWED_PROPERTY_NAME)); } } }; - System.setSecurityManager(securityManager); - { - Map systemEnvironment = environment.getSystemEnvironment(); - assertThat(systemEnvironment).isNotNull(); - assertThat(systemEnvironment).isInstanceOf(ReadOnlySystemAttributesMap.class); - assertThat(systemEnvironment.get(ALLOWED_PROPERTY_NAME)).isEqualTo(ALLOWED_PROPERTY_VALUE); - assertThat(systemEnvironment.get(DISALLOWED_PROPERTY_NAME)).isNull(); + try { + System.setSecurityManager(securityManager); + { + Map systemEnvironment = environment.getSystemEnvironment(); + assertThat(systemEnvironment).isNotNull(); + assertThat(systemEnvironment).isInstanceOf(ReadOnlySystemAttributesMap.class); + assertThat(systemEnvironment.get(ALLOWED_PROPERTY_NAME)).isEqualTo(ALLOWED_PROPERTY_VALUE); + assertThat(systemEnvironment.get(DISALLOWED_PROPERTY_NAME)).isNull(); + } + } + finally { + System.setSecurityManager(oldSecurityManager); } - System.setSecurityManager(oldSecurityManager); EnvironmentTestUtils.getModifiableSystemEnvironment().remove(ALLOWED_PROPERTY_NAME); EnvironmentTestUtils.getModifiableSystemEnvironment().remove(DISALLOWED_PROPERTY_NAME); } From ede2a1d4b26ada78250389c0dda908212713dbad Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Mon, 24 Feb 2020 11:42:45 +0900 Subject: [PATCH 0462/2315] Remove unnecessary semicolon in some enum classes --- .../springframework/context/annotation/ScopedProxyMode.java | 4 ++-- .../org/springframework/jmx/support/RegistrationPolicy.java | 4 ++-- .../org/springframework/messaging/simp/SimpMessageType.java | 4 ++-- .../springframework/orm/jpa/hibernate/beans/BeanSource.java | 4 ++-- .../springframework/web/reactive/socket/WebSocketMessage.java | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ScopedProxyMode.java b/spring-context/src/main/java/org/springframework/context/annotation/ScopedProxyMode.java index b2c424118078..08e7fd8e32a1 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ScopedProxyMode.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ScopedProxyMode.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2020 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. @@ -53,6 +53,6 @@ public enum ScopedProxyMode { /** * Create a class-based proxy (uses CGLIB). */ - TARGET_CLASS; + TARGET_CLASS } diff --git a/spring-context/src/main/java/org/springframework/jmx/support/RegistrationPolicy.java b/spring-context/src/main/java/org/springframework/jmx/support/RegistrationPolicy.java index aba4a5d3c0e0..4c0da82e3a02 100644 --- a/spring-context/src/main/java/org/springframework/jmx/support/RegistrationPolicy.java +++ b/spring-context/src/main/java/org/springframework/jmx/support/RegistrationPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2020 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. @@ -42,6 +42,6 @@ public enum RegistrationPolicy { * Registration should replace the affected MBean when attempting to register an MBean * under a name that already exists. */ - REPLACE_EXISTING; + REPLACE_EXISTING } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageType.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageType.java index 58618785ae72..ad55f9b23849 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageType.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageType.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2020 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,6 +41,6 @@ public enum SimpMessageType { DISCONNECT_ACK, - OTHER; + OTHER } diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/beans/BeanSource.java b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/beans/BeanSource.java index 7d1446722a57..b70367bd158e 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/beans/BeanSource.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/beans/BeanSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -18,5 +18,5 @@ public enum BeanSource { SPRING, - FALLBACK; + FALLBACK } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/WebSocketMessage.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/WebSocketMessage.java index 3982797681fa..9d939de0d9ec 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/WebSocketMessage.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/WebSocketMessage.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -159,7 +159,7 @@ public enum Type { /** * WebSocket pong. */ - PONG; + PONG } } From 1de2e0a4a7fe8c306d9cc8d4bdac8c18ba27d4e3 Mon Sep 17 00:00:00 2001 From: Qimiao Chen Date: Mon, 24 Feb 2020 22:00:11 +0800 Subject: [PATCH 0463/2315] Fix formatting in webflux-webclient.adoc Closes gh-24578 --- src/docs/asciidoc/web/webflux-webclient.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/asciidoc/web/webflux-webclient.adoc b/src/docs/asciidoc/web/webflux-webclient.adoc index 2121f23c7e1a..922a50976e11 100644 --- a/src/docs/asciidoc/web/webflux-webclient.adoc +++ b/src/docs/asciidoc/web/webflux-webclient.adoc @@ -496,7 +496,7 @@ Note that (unlike `retrieve()`), with `exchange()`, there are no automatic error [CAUTION] ==== -Unlike `retrieve()`, when using `exchange(), it is the responsibility of the application +Unlike `retrieve()`, when using `exchange()`, it is the responsibility of the application to consume any response content regardless of the scenario (success, error, unexpected data, etc). Not doing so can cause a memory leak. The Javadoc for `ClientResponse` lists all the available options for consuming the body. Generally prefer using `retrieve()` From 7778508e69f5bb09e58779fd4cdb347bdebe13bb Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 24 Feb 2020 15:37:42 +0100 Subject: [PATCH 0464/2315] Fix typos in ResolvableTypeTests See gh-24529 Co-authored-by: Qimiao Chen --- .../org/springframework/core/ResolvableTypeTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java index c59423a77130..ba58532c74f2 100644 --- a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java +++ b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -308,7 +308,7 @@ void classType() throws Exception { } @Test - void paramaterizedType() throws Exception { + void parameterizedType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("parameterizedType")); assertThat(type.getType()).isInstanceOf(ParameterizedType.class); } @@ -1620,7 +1620,7 @@ public ResolvableTypeAssert(ResolvableType actual) { public ResolvableTypeAssert isAssignableFrom(ResolvableType... types) { for (ResolvableType type : types) { if (!actual.isAssignableFrom(type)) { - throw new AssertionError("Expecting " + decribe(actual) + " to be assignable from " + decribe(type)); + throw new AssertionError("Expecting " + describe(actual) + " to be assignable from " + describe(type)); } } return this; @@ -1629,13 +1629,13 @@ public ResolvableTypeAssert isAssignableFrom(ResolvableType... types) { public ResolvableTypeAssert isNotAssignableFrom(ResolvableType... types) { for (ResolvableType type : types) { if (actual.isAssignableFrom(type)) { - throw new AssertionError("Expecting " + decribe(actual) + " to not be assignable from " + decribe(type)); + throw new AssertionError("Expecting " + describe(actual) + " to not be assignable from " + describe(type)); } } return this; } - private String decribe(ResolvableType type) { + private String describe(ResolvableType type) { if (type == ResolvableType.NONE) { return "NONE"; } From 96de4b3cee37615849e1ff2584ca7a08945f7ee6 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 24 Feb 2020 17:08:00 +0000 Subject: [PATCH 0465/2315] Upgrade to Reactor Dysprosium-SR5 Closes gh-24355 --- build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 853d7d88b616..68525a423073 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ configure(allprojects) { project -> imports { mavenBom "com.fasterxml.jackson:jackson-bom:2.10.2" mavenBom "io.netty:netty-bom:4.1.45.Final" - mavenBom "io.projectreactor:reactor-bom:Dysprosium-BUILD-SNAPSHOT" + mavenBom "io.projectreactor:reactor-bom:Dysprosium-SR5" mavenBom "io.rsocket:rsocket-bom:1.0.0-RC6" mavenBom "org.eclipse.jetty:jetty-bom:9.4.26.v20200117" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.61" @@ -280,7 +280,6 @@ configure(allprojects) { project -> repositories { mavenCentral() maven { url "https://repo.spring.io/libs-spring-framework-build" } - maven { url "https://repo.spring.io/snapshot" } // Reactor Dysprosium snapshots } } configurations.all { From f1680e5cee40b7694a4fdcc805e309097a0776fc Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 24 Feb 2020 18:12:54 +0100 Subject: [PATCH 0466/2315] Configure quiet period for shutting down Reactor resources This commit adds two new properties to the `ReactorResourceFactory`. This allows to configure the quiet and timeout periods when shutting down Reactor resources. While we'll retain Reactor Netty's default for production use, this option is useful for tests and developement environments when developers want to avoid long waiting times when shutting down resources. Fixes gh-24538 --- .../reactive/ReactorResourceFactory.java | 32 ++++++++++++++++-- .../reactive/ReactorResourceFactoryTests.java | 33 +++++++++++++++---- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java index 46d1f57c602d..39f1b582bb03 100644 --- a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java +++ b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java @@ -16,6 +16,7 @@ package org.springframework.http.client.reactive; +import java.time.Duration; import java.util.function.Consumer; import java.util.function.Supplier; @@ -61,6 +62,10 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean private boolean manageLoopResources = false; + private Duration shutdownQuietPeriod = Duration.ofSeconds(LoopResources.DEFAULT_SHUTDOWN_QUIET_PERIOD); + + private Duration shutdownTimeout = Duration.ofSeconds(LoopResources.DEFAULT_SHUTDOWN_TIMEOUT); + /** * Whether to use global Reactor Netty resources via {@link HttpResources}. @@ -83,6 +88,29 @@ public boolean isUseGlobalResources() { return this.useGlobalResources; } + /** + * Configure the amount of time we'll wait before shutting down resources. If a task is + * submitted during the {@code quietPeriod}, it is guaranteed to be accepted and the + * {@code quietPeriod} will start over. + * @since 5.2.4 + * @see #setShutdownTimeout(Duration) + */ + public void setShutdownQuietPeriod(Duration shutdownQuietPeriod) { + Assert.notNull(shutdownQuietPeriod, "shutdownQuietPeriod should not be null"); + this.shutdownQuietPeriod = shutdownQuietPeriod; + } + + /** + * Configure the maximum amount of time to wait until the disposal of the underlying + * resources regardless if a task was submitted during the {@code shutdownQuietPeriod}. + * @since 5.2.4 + * @see #setShutdownTimeout(Duration) + */ + public void setShutdownTimeout(Duration shutdownTimeout) { + Assert.notNull(shutdownTimeout, "shutdownQuietPeriod should not be null"); + this.shutdownTimeout = shutdownTimeout; + } + /** * Add a Consumer for configuring the global Reactor Netty resources on * startup. When this option is used, {@link #setUseGlobalResources} is also @@ -182,7 +210,7 @@ public void afterPropertiesSet() { @Override public void destroy() { if (this.useGlobalResources) { - HttpResources.disposeLoopsAndConnectionsLater().block(); + HttpResources.disposeLoopsAndConnectionsLater(this.shutdownQuietPeriod, this.shutdownTimeout).block(); } else { try { @@ -198,7 +226,7 @@ public void destroy() { try { LoopResources resources = this.loopResources; if (resources != null && this.manageLoopResources) { - resources.disposeLater().block(); + resources.disposeLater(this.shutdownQuietPeriod, this.shutdownTimeout).block(); } } catch (Throwable ex) { diff --git a/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java index 8e3284e2c7bc..0389a08444d0 100644 --- a/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -15,6 +15,7 @@ */ package org.springframework.http.client.reactive; +import java.time.Duration; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.jupiter.api.Test; @@ -23,6 +24,7 @@ import reactor.netty.resources.LoopResources; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -41,7 +43,7 @@ public class ReactorResourceFactoryTests { @Test - public void globalResources() throws Exception { + void globalResources() throws Exception { this.resourceFactory.setUseGlobalResources(true); this.resourceFactory.afterPropertiesSet(); @@ -57,7 +59,7 @@ public void globalResources() throws Exception { } @Test - public void globalResourcesWithConsumer() throws Exception { + void globalResourcesWithConsumer() throws Exception { AtomicBoolean invoked = new AtomicBoolean(false); @@ -69,7 +71,7 @@ public void globalResourcesWithConsumer() throws Exception { } @Test - public void localResources() throws Exception { + void localResources() throws Exception { this.resourceFactory.setUseGlobalResources(false); this.resourceFactory.afterPropertiesSet(); @@ -91,7 +93,7 @@ public void localResources() throws Exception { } @Test - public void localResourcesViaSupplier() throws Exception { + void localResourcesViaSupplier() throws Exception { this.resourceFactory.setUseGlobalResources(false); this.resourceFactory.setConnectionProviderSupplier(() -> this.connectionProvider); @@ -110,12 +112,29 @@ public void localResourcesViaSupplier() throws Exception { // Managed (destroy disposes).. verify(this.connectionProvider).disposeLater(); - verify(this.loopResources).disposeLater(); + verify(this.loopResources).disposeLater(eq(Duration.ofSeconds(LoopResources.DEFAULT_SHUTDOWN_QUIET_PERIOD)), eq(Duration.ofSeconds(LoopResources.DEFAULT_SHUTDOWN_TIMEOUT))); verifyNoMoreInteractions(this.connectionProvider, this.loopResources); } @Test - public void externalResources() throws Exception { + void customShutdownDurations() throws Exception { + Duration quietPeriod = Duration.ofMillis(500); + Duration shutdownTimeout = Duration.ofSeconds(1); + this.resourceFactory.setUseGlobalResources(false); + this.resourceFactory.setConnectionProviderSupplier(() -> this.connectionProvider); + this.resourceFactory.setLoopResourcesSupplier(() -> this.loopResources); + this.resourceFactory.setShutdownQuietPeriod(quietPeriod); + this.resourceFactory.setShutdownTimeout(shutdownTimeout); + this.resourceFactory.afterPropertiesSet(); + this.resourceFactory.destroy(); + + verify(this.connectionProvider).disposeLater(); + verify(this.loopResources).disposeLater(eq(quietPeriod), eq(shutdownTimeout)); + verifyNoMoreInteractions(this.connectionProvider, this.loopResources); + } + + @Test + void externalResources() throws Exception { this.resourceFactory.setUseGlobalResources(false); this.resourceFactory.setConnectionProvider(this.connectionProvider); From f048f27d80e1042ba6c4ba9336f99e0b73fc7c9c Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 24 Feb 2020 18:15:17 +0100 Subject: [PATCH 0467/2315] Configure Reactor Netty quiet shutdown period in tests See gh-24538 --- .../function/client/WebClientDataBufferAllocatingTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java index 555c3f518023..5dd289cba61a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -63,6 +63,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes @BeforeAll void setUpReactorResourceFactory() { + this.factory.setShutdownQuietPeriod(Duration.ofMillis(100)); this.factory.afterPropertiesSet(); } From 2ae91404d1424bfc16b2dca62e4c6f8f3e9174f6 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 24 Feb 2020 17:00:06 +0000 Subject: [PATCH 0468/2315] BlockHoundIntegration for spring-core --- build.gradle | 2 + spring-core/spring-core.gradle | 2 + .../core/ReactiveAdapterRegistry.java | 33 +++++- ...ockhound.integration.BlockHoundIntegration | 15 +++ .../SpringCoreBlockHoundIntegrationTests.java | 111 ++++++++++++++++++ 5 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 spring-core/src/main/resources/META-INF/services/reactor.blockhound.integration.BlockHoundIntegration create mode 100644 spring-core/src/test/java/org/springframework/core/SpringCoreBlockHoundIntegrationTests.java diff --git a/build.gradle b/build.gradle index 68525a423073..75002c01430b 100644 --- a/build.gradle +++ b/build.gradle @@ -64,6 +64,8 @@ configure(allprojects) { project -> dependency "io.reactivex:rxjava-reactive-streams:1.2.1" dependency "io.reactivex.rxjava2:rxjava:2.2.17" + dependency "io.projectreactor.tools:blockhound:1.0.2.RELEASE" + dependency "com.caucho:hessian:4.0.62" dependency "com.fasterxml:aalto-xml:1.2.2" dependency("com.fasterxml.woodstox:woodstox-core:6.0.3") { diff --git a/spring-core/spring-core.gradle b/spring-core/spring-core.gradle index 94327d342e32..d88536a3fe43 100644 --- a/spring-core/spring-core.gradle +++ b/spring-core/spring-core.gradle @@ -43,6 +43,7 @@ dependencies { compile(files(objenesisRepackJar)) compile(project(":spring-jcl")) compileOnly(project(":kotlin-coroutines")) + compileOnly("io.projectreactor.tools:blockhound") optional("net.sf.jopt-simple:jopt-simple") optional("org.aspectj:aspectjweaver") optional("org.jetbrains.kotlin:kotlin-reflect") @@ -60,6 +61,7 @@ dependencies { testCompile("javax.xml.bind:jaxb-api") testCompile("com.fasterxml.woodstox:woodstox-core") testCompile(project(":kotlin-coroutines")) + testCompile("io.projectreactor.tools:blockhound") testFixturesImplementation("com.google.code.findbugs:jsr305") testFixturesImplementation("io.projectreactor:reactor-test") testFixturesImplementation("org.assertj:assertj-core") diff --git a/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java b/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java index 48c7512e628e..9b237c9a094c 100644 --- a/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java +++ b/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -29,12 +29,15 @@ import kotlinx.coroutines.CompletableDeferredKt; import kotlinx.coroutines.Deferred; import org.reactivestreams.Publisher; +import reactor.blockhound.BlockHound; +import reactor.blockhound.integration.BlockHoundIntegration; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import rx.RxReactiveStreams; import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; +import org.springframework.util.ConcurrentReferenceHashMap; import org.springframework.util.ReflectionUtils; /** @@ -354,4 +357,32 @@ void registerAdapters(ReactiveAdapterRegistry registry) { ); } } + + + /** + * {@code BlockHoundIntegration} for spring-core classes. + *

    Whitelists the following: + *

      + *
    • Reading class info via {@link LocalVariableTableParameterNameDiscoverer}. + *
    • Locking within {@link ConcurrentReferenceHashMap}. + *
    + * @since 5.2.4 + */ + public static class SpringCoreBlockHoundIntegration implements BlockHoundIntegration { + + @Override + public void applyTo(BlockHound.Builder builder) { + + // Avoid hard references potentially anywhere in spring-core (no need for structural dependency) + + builder.allowBlockingCallsInside( + "org.springframework.core.LocalVariableTableParameterNameDiscoverer", "inspectClass"); + + String className = "org.springframework.util.ConcurrentReferenceHashMap$Segment"; + builder.allowBlockingCallsInside(className, "doTask"); + builder.allowBlockingCallsInside(className, "clear"); + builder.allowBlockingCallsInside(className, "restructure"); + } + } + } diff --git a/spring-core/src/main/resources/META-INF/services/reactor.blockhound.integration.BlockHoundIntegration b/spring-core/src/main/resources/META-INF/services/reactor.blockhound.integration.BlockHoundIntegration new file mode 100644 index 000000000000..5a35c69baca4 --- /dev/null +++ b/spring-core/src/main/resources/META-INF/services/reactor.blockhound.integration.BlockHoundIntegration @@ -0,0 +1,15 @@ +# Copyright 2002-2020 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +org.springframework.core.ReactiveAdapterRegistry$SpringCoreBlockHoundIntegration \ No newline at end of file diff --git a/spring-core/src/test/java/org/springframework/core/SpringCoreBlockHoundIntegrationTests.java b/spring-core/src/test/java/org/springframework/core/SpringCoreBlockHoundIntegrationTests.java new file mode 100644 index 000000000000..2d8648335ca0 --- /dev/null +++ b/spring-core/src/test/java/org/springframework/core/SpringCoreBlockHoundIntegrationTests.java @@ -0,0 +1,111 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.core; + +import java.lang.reflect.Method; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import reactor.blockhound.BlockHound; +import reactor.core.scheduler.Schedulers; + +import org.springframework.tests.sample.objects.TestObject; +import org.springframework.util.ConcurrentReferenceHashMap; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +/** + * Tests to verify the spring-core BlockHound integration rules. + * + * @author Rossen Stoyanchev + * @since 5.2.4 + */ +public class SpringCoreBlockHoundIntegrationTests { + + + @BeforeAll + static void setUp() { + BlockHound.install(); + } + + + @Test + void blockHoundIsInstalled() { + assertThatThrownBy(() -> testNonBlockingTask(() -> Thread.sleep(10))) + .hasMessageContaining("Blocking call!"); + } + + @Test + void localVariableTableParameterNameDiscoverer() { + testNonBlockingTask(() -> { + Method setName = TestObject.class.getMethod("setName", String.class); + String[] names = new LocalVariableTableParameterNameDiscoverer().getParameterNames(setName); + assertThat(names).isEqualTo(new String[] {"name"}); + }); + } + + @Test + void concurrentReferenceHashMap() { + int size = 10000; + Map map = new ConcurrentReferenceHashMap<>(size); + + CompletableFuture future1 = new CompletableFuture<>(); + testNonBlockingTask(() -> { + for (int i = 0; i < size / 2; i++) { + map.put("a" + i, "bar"); + } + }, future1); + + CompletableFuture future2 = new CompletableFuture<>(); + testNonBlockingTask(() -> { + for (int i = 0; i < size / 2; i++) { + map.put("b" + i, "bar"); + } + }, future2); + + CompletableFuture.allOf(future1, future2).join(); + assertThat(map).hasSize(size); + } + + private void testNonBlockingTask(NonBlockingTask task) { + CompletableFuture future = new CompletableFuture<>(); + testNonBlockingTask(task, future); + future.join(); + } + + private void testNonBlockingTask(NonBlockingTask task, CompletableFuture future) { + Schedulers.parallel().schedule(() -> { + try { + task.run(); + future.complete(null); + } + catch (Throwable ex) { + future.completeExceptionally(ex); + } + }); + } + + + @FunctionalInterface + private interface NonBlockingTask { + + void run() throws Exception; + } + +} From 2afe5802c0debc1c60e49b3379c55148a78ab2c2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 24 Feb 2020 19:08:13 +0100 Subject: [PATCH 0469/2315] Clarify setCacheMillis/setCacheSeconds vs java.util.ResourceBundle Closes gh-24563 --- .../support/AbstractResourceBasedMessageSource.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java index ee0eb6cde85a..da969bf98a2a 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -200,8 +200,9 @@ protected Locale getDefaultLocale() { /** * Set the number of seconds to cache loaded properties files. *