mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Compare commits
50 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4343423f1c | |||
| cfefcee788 | |||
| 5fb58e51e5 | |||
| 67c4b4182f | |||
| 6b3052200a | |||
| cf5b86369d | |||
| 7067461d71 | |||
| 34cb5df859 | |||
| 01231fe923 | |||
| 7665424ea8 | |||
| f63a106c85 | |||
| caaf48d4ec | |||
| e52fc2176d | |||
| e8e7fbba94 | |||
| bd1f34e174 | |||
| a490723f02 | |||
| df263d01b9 | |||
| 2a80b64d40 | |||
| e24043ab90 | |||
| 4078b73cec | |||
| dca155e438 | |||
| edabde8a11 | |||
| 8087eb69bf | |||
| e41d865193 | |||
| d68bb4eecd | |||
| 730ad4436f | |||
| 23ab9ca8ca | |||
| 51d263bd06 | |||
| 518dc6df65 | |||
| 59c6b7e445 | |||
| 3e75ec73ab | |||
| 709a41fd43 | |||
| 90072d06fb | |||
| 54bdab4553 | |||
| 75e1811470 | |||
| 18781e58ac | |||
| ed4e2289cd | |||
| ccf95413ed | |||
| fdd6e50721 | |||
| c04fa858fc | |||
| c3ce4f0f90 | |||
| e1200f34e7 | |||
| 999376f9f9 | |||
| c942d789c3 | |||
| 03668f9c10 | |||
| 3e14cdbc69 | |||
| f04e9a8366 | |||
| c1606c5a5e | |||
| 95fac2589f | |||
| 41c8bb4fe1 |
+10
-10
@@ -29,7 +29,7 @@ configure(allprojects) { project ->
|
||||
imports {
|
||||
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.6"
|
||||
mavenBom "io.netty:netty-bom:4.1.72.Final"
|
||||
mavenBom "io.projectreactor:reactor-bom:2020.0.14"
|
||||
mavenBom "io.projectreactor:reactor-bom:2020.0.15"
|
||||
mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR11"
|
||||
mavenBom "io.rsocket:rsocket-bom:1.1.1"
|
||||
mavenBom "org.eclipse.jetty:jetty-bom:9.4.44.v20210927"
|
||||
@@ -39,7 +39,7 @@ configure(allprojects) { project ->
|
||||
mavenBom "org.junit:junit-bom:5.8.2"
|
||||
}
|
||||
dependencies {
|
||||
dependencySet(group: 'org.apache.logging.log4j', version: '2.16.0') {
|
||||
dependencySet(group: 'org.apache.logging.log4j', version: '2.17.1') {
|
||||
entry 'log4j-api'
|
||||
entry 'log4j-core'
|
||||
entry 'log4j-jul'
|
||||
@@ -94,7 +94,7 @@ configure(allprojects) { project ->
|
||||
dependency "org.ogce:xpp3:1.1.6"
|
||||
dependency "org.yaml:snakeyaml:1.30"
|
||||
|
||||
dependency "com.h2database:h2:1.4.200"
|
||||
dependency "com.h2database:h2:2.0.206"
|
||||
dependency "com.github.ben-manes.caffeine:caffeine:2.9.3"
|
||||
dependency "com.github.librepdf:openpdf:1.3.26"
|
||||
dependency "com.rometools:rome:1.16.0"
|
||||
@@ -123,8 +123,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.32.Final"
|
||||
dependency "org.hibernate:hibernate-validator:6.2.0.Final"
|
||||
dependency "org.hibernate:hibernate-core:5.4.33.Final"
|
||||
dependency "org.hibernate:hibernate-validator:6.2.1.Final"
|
||||
dependency "org.webjars:webjars-locator-core:0.48"
|
||||
dependency "org.webjars:underscorejs:1.8.3"
|
||||
|
||||
@@ -191,14 +191,14 @@ configure(allprojects) { project ->
|
||||
dependency "org.junit.support:testng-engine:1.0.1"
|
||||
dependency "org.hamcrest:hamcrest:2.1"
|
||||
dependency "org.awaitility:awaitility:3.1.6"
|
||||
dependency "org.assertj:assertj-core:3.21.0"
|
||||
dependencySet(group: 'org.xmlunit', version: '2.8.3') {
|
||||
dependency "org.assertj:assertj-core:3.22.0"
|
||||
dependencySet(group: 'org.xmlunit', version: '2.8.4') {
|
||||
entry 'xmlunit-assertj'
|
||||
entry('xmlunit-matchers') {
|
||||
exclude group: "org.hamcrest", name: "hamcrest-core"
|
||||
}
|
||||
}
|
||||
dependencySet(group: 'org.mockito', version: '4.1.0') {
|
||||
dependencySet(group: 'org.mockito', version: '4.2.0') {
|
||||
entry('mockito-core') {
|
||||
exclude group: "org.hamcrest", name: "hamcrest-core"
|
||||
}
|
||||
@@ -206,10 +206,10 @@ configure(allprojects) { project ->
|
||||
}
|
||||
dependency "io.mockk:mockk:1.12.1"
|
||||
|
||||
dependency("net.sourceforge.htmlunit:htmlunit:2.55.0") {
|
||||
dependency("net.sourceforge.htmlunit:htmlunit:2.56.0") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.seleniumhq.selenium:htmlunit-driver:2.55.0") {
|
||||
dependency("org.seleniumhq.selenium:htmlunit-driver:2.56.0") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.seleniumhq.selenium:selenium-java:3.141.59") {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
version=5.3.14-SNAPSHOT
|
||||
version=5.3.15
|
||||
org.gradle.jvmargs=-Xmx1536M
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,7 +74,7 @@ class ScheduledAndTransactionalAnnotationIntegrationTests {
|
||||
|
||||
MyRepository repository = ctx.getBean(MyRepository.class);
|
||||
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
|
||||
assertThat(AopUtils.isCglibProxy(repository)).isEqualTo(true);
|
||||
assertThat(AopUtils.isCglibProxy(repository)).isTrue();
|
||||
assertThat(repository.getInvocationCount()).isGreaterThan(0);
|
||||
assertThat(txManager.commits).isGreaterThan(0);
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -322,7 +322,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
||||
int b = 12;
|
||||
int c = 25;
|
||||
String d = "d";
|
||||
StringBuffer e = new StringBuffer("stringbuf");
|
||||
StringBuilder e = new StringBuilder("stringbuf");
|
||||
String expectedResult = a + b+ c + d + e;
|
||||
assertThat(mva.mungeArgs(a, b, c, d, e)).isEqualTo(expectedResult);
|
||||
}
|
||||
@@ -728,12 +728,12 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
||||
@Aspect
|
||||
static class ManyValuedArgs {
|
||||
|
||||
String mungeArgs(String a, int b, int c, String d, StringBuffer e) {
|
||||
String mungeArgs(String a, int b, int c, String d, StringBuilder e) {
|
||||
return a + b + c + d + e;
|
||||
}
|
||||
|
||||
@Around(value="execution(String mungeArgs(..)) && args(a, b, c, d, e)", argNames="b,c,d,e,a")
|
||||
String reverseAdvice(ProceedingJoinPoint pjp, int b, int c, String d, StringBuffer e, String a) throws Throwable {
|
||||
String reverseAdvice(ProceedingJoinPoint pjp, int b, int c, String d, StringBuilder e, String a) throws Throwable {
|
||||
assertThat(pjp.proceed()).isEqualTo(a + b+ c+ d+ e);
|
||||
return a + b + c + d + e;
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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 @@ package org.springframework.aop.testfixture.advice;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Abstract superclass for counting advices etc.
|
||||
@@ -31,7 +32,7 @@ import java.util.HashMap;
|
||||
public class MethodCounter implements Serializable {
|
||||
|
||||
/** Method name --> count, does not understand overloading */
|
||||
private HashMap<String, Integer> map = new HashMap<>();
|
||||
private Map<String, Integer> map = new HashMap<>();
|
||||
|
||||
private int allCount;
|
||||
|
||||
|
||||
+9
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author 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,6 +103,14 @@ public abstract class AbstractBeanDefinitionReader implements BeanDefinitionRead
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the bean factory to register the bean definitions with.
|
||||
* <p>The factory is exposed through the BeanDefinitionRegistry interface,
|
||||
* encapsulating the methods that are relevant for bean definition handling.
|
||||
* @deprecated as of Spring Framework 5.3.15 in favor of {@link #getRegistry()},
|
||||
* to be removed in Spring Framework 6.0
|
||||
*/
|
||||
@Deprecated
|
||||
public final BeanDefinitionRegistry getBeanFactory() {
|
||||
return this.registry;
|
||||
}
|
||||
|
||||
+17
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2021 the original author 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,15 +22,15 @@ import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Simple interface for bean definition readers.
|
||||
* Specifies load methods with Resource and String location parameters.
|
||||
* Simple interface for bean definition readers that specifies load methods with
|
||||
* {@link Resource} and {@link String} location parameters.
|
||||
*
|
||||
* <p>Concrete bean definition readers can of course add additional
|
||||
* load and register methods for bean definitions, specific to
|
||||
* their bean definition format.
|
||||
*
|
||||
* <p>Note that a bean definition reader does not have to implement
|
||||
* this interface. It only serves as suggestion for bean definition
|
||||
* this interface. It only serves as a suggestion for bean definition
|
||||
* readers that want to follow standard naming conventions.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
@@ -41,14 +41,14 @@ public interface BeanDefinitionReader {
|
||||
|
||||
/**
|
||||
* Return the bean factory to register the bean definitions with.
|
||||
* <p>The factory is exposed through the BeanDefinitionRegistry interface,
|
||||
* <p>The factory is exposed through the {@link BeanDefinitionRegistry} interface,
|
||||
* encapsulating the methods that are relevant for bean definition handling.
|
||||
*/
|
||||
BeanDefinitionRegistry getRegistry();
|
||||
|
||||
/**
|
||||
* Return the resource loader to use for resource locations.
|
||||
* Can be checked for the <b>ResourcePatternResolver</b> interface and cast
|
||||
* Return the {@link ResourceLoader} to use for resource locations.
|
||||
* <p>Can be checked for the {@code ResourcePatternResolver} interface and cast
|
||||
* accordingly, for loading multiple resources for a given resource pattern.
|
||||
* <p>A {@code null} return value suggests that absolute resource loading
|
||||
* is not available for this bean definition reader.
|
||||
@@ -56,10 +56,10 @@ public interface BeanDefinitionReader {
|
||||
* from within a bean definition resource, for example via the "import"
|
||||
* tag in XML bean definitions. It is recommended, however, to apply
|
||||
* such imports relative to the defining resource; only explicit full
|
||||
* resource locations will trigger absolute resource loading.
|
||||
* resource locations will trigger absolute path based resource loading.
|
||||
* <p>There is also a {@code loadBeanDefinitions(String)} method available,
|
||||
* for loading bean definitions from a resource location (or location pattern).
|
||||
* This is a convenience to avoid explicit ResourceLoader handling.
|
||||
* This is a convenience to avoid explicit {@code ResourceLoader} handling.
|
||||
* @see #loadBeanDefinitions(String)
|
||||
* @see org.springframework.core.io.support.ResourcePatternResolver
|
||||
*/
|
||||
@@ -70,13 +70,13 @@ public interface BeanDefinitionReader {
|
||||
* Return the class loader to use for bean classes.
|
||||
* <p>{@code null} suggests to not load bean classes eagerly
|
||||
* but rather to just register bean definitions with class names,
|
||||
* with the corresponding Classes to be resolved later (or never).
|
||||
* with the corresponding classes to be resolved later (or never).
|
||||
*/
|
||||
@Nullable
|
||||
ClassLoader getBeanClassLoader();
|
||||
|
||||
/**
|
||||
* Return the BeanNameGenerator to use for anonymous beans
|
||||
* Return the {@link BeanNameGenerator} to use for anonymous beans
|
||||
* (without explicit bean name specified).
|
||||
*/
|
||||
BeanNameGenerator getBeanNameGenerator();
|
||||
@@ -101,9 +101,10 @@ public interface BeanDefinitionReader {
|
||||
/**
|
||||
* Load bean definitions from the specified resource location.
|
||||
* <p>The location can also be a location pattern, provided that the
|
||||
* ResourceLoader of this bean definition reader is a ResourcePatternResolver.
|
||||
* @param location the resource location, to be loaded with the ResourceLoader
|
||||
* (or ResourcePatternResolver) of this bean definition reader
|
||||
* {@link ResourceLoader} of this bean definition reader is a
|
||||
* {@code ResourcePatternResolver}.
|
||||
* @param location the resource location, to be loaded with the {@code ResourceLoader}
|
||||
* (or {@code ResourcePatternResolver}) of this bean definition reader
|
||||
* @return the number of bean definitions found
|
||||
* @throws BeanDefinitionStoreException in case of loading or parsing errors
|
||||
* @see #getResourceLoader()
|
||||
@@ -114,8 +115,8 @@ public interface BeanDefinitionReader {
|
||||
|
||||
/**
|
||||
* Load bean definitions from the specified resource locations.
|
||||
* @param locations the resource locations, to be loaded with the ResourceLoader
|
||||
* (or ResourcePatternResolver) of this bean definition reader
|
||||
* @param locations the resource locations, to be loaded with the {@code ResourceLoader}
|
||||
* (or {@code ResourcePatternResolver}) of this bean definition reader
|
||||
* @return the number of bean definitions found
|
||||
* @throws BeanDefinitionStoreException in case of loading or parsing errors
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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 BeanWrapperEnumTests {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnum", null);
|
||||
assertThat(gb.getCustomEnum()).isEqualTo(null);
|
||||
assertThat(gb.getCustomEnum()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,7 +54,7 @@ public class BeanWrapperEnumTests {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnum", "");
|
||||
assertThat(gb.getCustomEnum()).isEqualTo(null);
|
||||
assertThat(gb.getCustomEnum()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -433,7 +433,7 @@ class DefaultListableBeanFactoryTests {
|
||||
assertThat(lbf.isTypeMatch("x1", Object.class)).isTrue();
|
||||
assertThat(lbf.isTypeMatch("&x1", Object.class)).isFalse();
|
||||
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
|
||||
assertThat(lbf.getType("&x1")).isEqualTo(null);
|
||||
assertThat(lbf.getType("&x1")).isNull();
|
||||
assertThat(TestBeanFactory.initialized).isFalse();
|
||||
|
||||
lbf.registerAlias("x1", "x2");
|
||||
@@ -2622,8 +2622,8 @@ class DefaultListableBeanFactoryTests {
|
||||
void containsBeanReturnsTrueEvenForAbstractBeanDefinition() {
|
||||
lbf.registerBeanDefinition("abs", BeanDefinitionBuilder
|
||||
.rootBeanDefinition(TestBean.class).setAbstract(true).getBeanDefinition());
|
||||
assertThat(lbf.containsBean("abs")).isEqualTo(true);
|
||||
assertThat(lbf.containsBean("bogus")).isEqualTo(false);
|
||||
assertThat(lbf.containsBean("abs")).isTrue();
|
||||
assertThat(lbf.containsBean("bogus")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -111,7 +111,7 @@ public class PropertyResourceConfigurerTests {
|
||||
|
||||
assertThat(tb1.getAge()).isEqualTo(99);
|
||||
assertThat(tb2.getAge()).isEqualTo(99);
|
||||
assertThat(tb1.getName()).isEqualTo(null);
|
||||
assertThat(tb1.getName()).isNull();
|
||||
assertThat(tb2.getName()).isEqualTo("test");
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ public class PropertyResourceConfigurerTests {
|
||||
TestBean tb2 = (TestBean) factory.getBean("tb2");
|
||||
assertThat(tb1.getAge()).isEqualTo(99);
|
||||
assertThat(tb2.getAge()).isEqualTo(99);
|
||||
assertThat(tb1.getName()).isEqualTo(null);
|
||||
assertThat(tb1.getName()).isNull();
|
||||
assertThat(tb2.getName()).isEqualTo("test");
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ public class PropertyResourceConfigurerTests {
|
||||
TestBean inner1 = (TestBean) tb2.getSomeMap().get("key3");
|
||||
TestBean inner2 = (TestBean) tb2.getSomeMap().get("mykey4");
|
||||
assertThat(inner1.getAge()).isEqualTo(0);
|
||||
assertThat(inner1.getName()).isEqualTo(null);
|
||||
assertThat(inner1.getName()).isNull();
|
||||
assertThat(inner1.getCountry()).isEqualTo(System.getProperty("os.name"));
|
||||
assertThat(inner2.getAge()).isEqualTo(98);
|
||||
assertThat(inner2.getName()).isEqualTo("namemyvarmyvar${");
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -449,7 +449,7 @@ public class CallbacksSecurityTests {
|
||||
public Object run() {
|
||||
// sanity check
|
||||
assertThat(getCurrentSubjectName()).isEqualTo("user1");
|
||||
assertThat(NonPrivilegedBean.destroyed).isEqualTo(false);
|
||||
assertThat(NonPrivilegedBean.destroyed).isFalse();
|
||||
|
||||
beanFactory.getBean("trusted-spring-callbacks");
|
||||
beanFactory.getBean("trusted-custom-init-destroy");
|
||||
@@ -465,7 +465,7 @@ public class CallbacksSecurityTests {
|
||||
beanFactory.getBean("trusted-working-property-injection");
|
||||
|
||||
beanFactory.destroySingletons();
|
||||
assertThat(NonPrivilegedBean.destroyed).isEqualTo(true);
|
||||
assertThat(NonPrivilegedBean.destroyed).isTrue();
|
||||
return null;
|
||||
}
|
||||
}, provider.getAccessControlContext());
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,17 +100,17 @@ public class FactoryMethodTests {
|
||||
|
||||
FactoryMethods fm = (FactoryMethods) xbf.getBean("fullWithNull");
|
||||
assertThat(fm.getNum()).isEqualTo(27);
|
||||
assertThat(fm.getName()).isEqualTo(null);
|
||||
assertThat(fm.getName()).isNull();
|
||||
assertThat(fm.getTestBean().getName()).isEqualTo("Juergen");
|
||||
|
||||
fm = (FactoryMethods) xbf.getBean("fullWithGenericNull");
|
||||
assertThat(fm.getNum()).isEqualTo(27);
|
||||
assertThat(fm.getName()).isEqualTo(null);
|
||||
assertThat(fm.getName()).isNull();
|
||||
assertThat(fm.getTestBean().getName()).isEqualTo("Juergen");
|
||||
|
||||
fm = (FactoryMethods) xbf.getBean("fullWithNamedNull");
|
||||
assertThat(fm.getNum()).isEqualTo(27);
|
||||
assertThat(fm.getName()).isEqualTo(null);
|
||||
assertThat(fm.getName()).isNull();
|
||||
assertThat(fm.getTestBean().getName()).isEqualTo("Juergen");
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -342,7 +342,7 @@ public class UtilNamespaceHandlerTests {
|
||||
public void testLoadProperties() {
|
||||
Properties props = (Properties) this.beanFactory.getBean("myProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo(null);
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isNull();
|
||||
Properties props2 = (Properties) this.beanFactory.getBean("myProperties");
|
||||
assertThat(props == props2).isTrue();
|
||||
}
|
||||
@@ -351,17 +351,17 @@ public class UtilNamespaceHandlerTests {
|
||||
public void testScopedProperties() {
|
||||
Properties props = (Properties) this.beanFactory.getBean("myScopedProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo(null);
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isNull();
|
||||
Properties props2 = (Properties) this.beanFactory.getBean("myScopedProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo(null);
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isNull();
|
||||
assertThat(props != props2).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalProperties() {
|
||||
Properties props = (Properties) this.beanFactory.getBean("myLocalProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo(null);
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isNull();
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo("bar2");
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -283,7 +283,7 @@ public class XmlBeanCollectionTests {
|
||||
Iterator it = hasMap.getSet().iterator();
|
||||
assertThat(it.next()).isEqualTo("bar");
|
||||
assertThat(it.next()).isEqualTo(jenny);
|
||||
assertThat(it.next()).isEqualTo(null);
|
||||
assertThat(it.next()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,7 +181,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
assertThat(beanNames.contains("aliasWithoutId3")).isFalse();
|
||||
|
||||
TestBean tb4 = (TestBean) getBeanFactory().getBean(TestBean.class.getName() + "#0");
|
||||
assertThat(tb4.getName()).isEqualTo(null);
|
||||
assertThat(tb4.getName()).isNull();
|
||||
|
||||
Map drs = getListableBeanFactory().getBeansOfType(DummyReferencer.class, false, false);
|
||||
assertThat(drs.size()).isEqualTo(5);
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -106,7 +106,7 @@ class CaffeineCacheTests extends AbstractValueAdaptingCacheTests<CaffeineCache>
|
||||
Cache.ValueWrapper wrapper = cache.putIfAbsent(key, "anotherValue");
|
||||
// A value is set but is 'null'
|
||||
assertThat(wrapper).isNotNull();
|
||||
assertThat(wrapper.get()).isEqualTo(null);
|
||||
assertThat(wrapper.get()).isNull();
|
||||
// not changed
|
||||
assertThat(cache.get(key).get()).isEqualTo(value);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -196,7 +196,7 @@ class CommonsPool2TargetSourceTests {
|
||||
void testSetWhenExhaustedAction() {
|
||||
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
|
||||
targetSource.setBlockWhenExhausted(true);
|
||||
assertThat(targetSource.isBlockWhenExhausted()).isEqualTo(true);
|
||||
assertThat(targetSource.isBlockWhenExhausted()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+8
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -876,7 +876,7 @@ class XmlBeanFactoryTests {
|
||||
// should have been autowired
|
||||
assertThat(rod1.getSpouse1()).isEqualTo(kerry);
|
||||
assertThat(rod1.getAge()).isEqualTo(0);
|
||||
assertThat(rod1.getName()).isEqualTo(null);
|
||||
assertThat(rod1.getName()).isNull();
|
||||
|
||||
ConstructorDependenciesBean rod2 = (ConstructorDependenciesBean) xbf.getBean("rod2");
|
||||
TestBean kerry1 = (TestBean) xbf.getBean("kerry1");
|
||||
@@ -885,7 +885,7 @@ class XmlBeanFactoryTests {
|
||||
assertThat(rod2.getSpouse1()).isEqualTo(kerry2);
|
||||
assertThat(rod2.getSpouse2()).isEqualTo(kerry1);
|
||||
assertThat(rod2.getAge()).isEqualTo(0);
|
||||
assertThat(rod2.getName()).isEqualTo(null);
|
||||
assertThat(rod2.getName()).isNull();
|
||||
|
||||
ConstructorDependenciesBean rod = (ConstructorDependenciesBean) xbf.getBean("rod3");
|
||||
IndexedTestBean other = (IndexedTestBean) xbf.getBean("other");
|
||||
@@ -894,7 +894,7 @@ class XmlBeanFactoryTests {
|
||||
assertThat(rod.getSpouse2()).isEqualTo(kerry);
|
||||
assertThat(rod.getOther()).isEqualTo(other);
|
||||
assertThat(rod.getAge()).isEqualTo(0);
|
||||
assertThat(rod.getName()).isEqualTo(null);
|
||||
assertThat(rod.getName()).isNull();
|
||||
|
||||
xbf.getBean("rod4", ConstructorDependenciesBean.class);
|
||||
// should have been autowired
|
||||
@@ -902,7 +902,7 @@ class XmlBeanFactoryTests {
|
||||
assertThat(rod.getSpouse2()).isEqualTo(kerry);
|
||||
assertThat(rod.getOther()).isEqualTo(other);
|
||||
assertThat(rod.getAge()).isEqualTo(0);
|
||||
assertThat(rod.getName()).isEqualTo(null);
|
||||
assertThat(rod.getName()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -929,7 +929,7 @@ class XmlBeanFactoryTests {
|
||||
assertThat(rod6.getSpouse2()).isEqualTo(kerry1);
|
||||
assertThat(rod6.getOther()).isEqualTo(other);
|
||||
assertThat(rod6.getAge()).isEqualTo(0);
|
||||
assertThat(rod6.getName()).isEqualTo(null);
|
||||
assertThat(rod6.getName()).isNull();
|
||||
|
||||
xbf.destroySingletons();
|
||||
assertThat(rod6.destroyed).isTrue();
|
||||
@@ -967,7 +967,7 @@ class XmlBeanFactoryTests {
|
||||
assertThat(rod9c.getAge()).isEqualTo(97);
|
||||
|
||||
ConstructorDependenciesBean rod10 = (ConstructorDependenciesBean) xbf.getBean("rod10");
|
||||
assertThat(rod10.getName()).isEqualTo(null);
|
||||
assertThat(rod10.getName()).isNull();
|
||||
|
||||
ConstructorDependenciesBean rod11 = (ConstructorDependenciesBean) xbf.getBean("rod11");
|
||||
assertThat(rod11.getSpouse1()).isEqualTo(kerry2);
|
||||
@@ -1331,7 +1331,7 @@ class XmlBeanFactoryTests {
|
||||
|
||||
OverrideOneMethodSubclass ooms = (OverrideOneMethodSubclass) xbf.getBean("replaceVoidMethod");
|
||||
DoSomethingReplacer dos = (DoSomethingReplacer) xbf.getBean("doSomethingReplacer");
|
||||
assertThat(dos.lastArg).isEqualTo(null);
|
||||
assertThat(dos.lastArg).isNull();
|
||||
String s1 = "";
|
||||
String s2 = "foo bar black sheep";
|
||||
ooms.doSomething(s1);
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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 class PrimitiveBeanLookupAndAutowiringTests {
|
||||
public void primitiveLookupByName() {
|
||||
ApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
|
||||
boolean b = ctx.getBean("b", boolean.class);
|
||||
assertThat(b).isEqualTo(true);
|
||||
assertThat(b).isTrue();
|
||||
int i = ctx.getBean("i", int.class);
|
||||
assertThat(i).isEqualTo(42);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class PrimitiveBeanLookupAndAutowiringTests {
|
||||
public void primitiveLookupByType() {
|
||||
ApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
|
||||
boolean b = ctx.getBean(boolean.class);
|
||||
assertThat(b).isEqualTo(true);
|
||||
assertThat(b).isTrue();
|
||||
int i = ctx.getBean(int.class);
|
||||
assertThat(i).isEqualTo(42);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class PrimitiveBeanLookupAndAutowiringTests {
|
||||
public void primitiveAutowiredInjection() {
|
||||
ApplicationContext ctx =
|
||||
new AnnotationConfigApplicationContext(Config.class, AutowiredComponent.class);
|
||||
assertThat(ctx.getBean(AutowiredComponent.class).b).isEqualTo(true);
|
||||
assertThat(ctx.getBean(AutowiredComponent.class).b).isTrue();
|
||||
assertThat(ctx.getBean(AutowiredComponent.class).i).isEqualTo(42);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class PrimitiveBeanLookupAndAutowiringTests {
|
||||
public void primitiveResourceInjection() {
|
||||
ApplicationContext ctx =
|
||||
new AnnotationConfigApplicationContext(Config.class, ResourceComponent.class);
|
||||
assertThat(ctx.getBean(ResourceComponent.class).b).isEqualTo(true);
|
||||
assertThat(ctx.getBean(ResourceComponent.class).b).isTrue();
|
||||
assertThat(ctx.getBean(ResourceComponent.class).i).isEqualTo(42);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -43,7 +44,7 @@ public class CachedExpressionEvaluatorTests {
|
||||
Method method = ReflectionUtils.findMethod(getClass(), "toString");
|
||||
Expression expression = expressionEvaluator.getTestExpression("true", method, getClass());
|
||||
hasParsedExpression("true");
|
||||
assertThat(expression.getValue()).isEqualTo(true);
|
||||
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertThat(expressionEvaluator.testCache.size()).as("Expression should be in cache").isEqualTo(1);
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link MethodBasedEvaluationContext}.
|
||||
@@ -47,9 +48,9 @@ public class MethodBasedEvaluationContextTests {
|
||||
assertThat(context.lookupVariable("p0")).isEqualTo("test");
|
||||
assertThat(context.lookupVariable("foo")).isEqualTo("test");
|
||||
|
||||
assertThat(context.lookupVariable("a1")).isEqualTo(true);
|
||||
assertThat(context.lookupVariable("p1")).isEqualTo(true);
|
||||
assertThat(context.lookupVariable("flag")).isEqualTo(true);
|
||||
assertThat(context.lookupVariable("a1")).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertThat(context.lookupVariable("p1")).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertThat(context.lookupVariable("flag")).asInstanceOf(BOOLEAN).isTrue();
|
||||
|
||||
assertThat(context.lookupVariable("a2")).isNull();
|
||||
assertThat(context.lookupVariable("p2")).isNull();
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -345,7 +345,7 @@ public class PropertySourcesPlaceholderConfigurerTests {
|
||||
.addPropertyValue("jedi", "${jedi:false}")
|
||||
.getBeanDefinition());
|
||||
ppc.postProcessBeanFactory(bf);
|
||||
assertThat(bf.getBean(TestBean.class).isJedi()).isEqualTo(true);
|
||||
assertThat(bf.getBean(TestBean.class).isJedi()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -281,7 +281,7 @@ public class FormattingConversionServiceTests {
|
||||
@Test
|
||||
public void printNullDefault() {
|
||||
assertThat(formattingService
|
||||
.convert(null, TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(String.class))).isEqualTo(null);
|
||||
.convert(null, TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(String.class))).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,7 +42,7 @@ public class JndiLocatorDelegateTests {
|
||||
builderField.set(null, null);
|
||||
|
||||
try {
|
||||
assertThat(JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()).isEqualTo(false);
|
||||
assertThat(JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()).isFalse();
|
||||
}
|
||||
finally {
|
||||
builderField.set(null, oldBuilder);
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,7 +57,7 @@ public class ExecutorBeanDefinitionParserTests {
|
||||
assertThat(getMaxPoolSize(executor)).isEqualTo(Integer.MAX_VALUE);
|
||||
assertThat(getQueueCapacity(executor)).isEqualTo(Integer.MAX_VALUE);
|
||||
assertThat(getKeepAliveSeconds(executor)).isEqualTo(60);
|
||||
assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(false);
|
||||
assertThat(getAllowCoreThreadTimeOut(executor)).isFalse();
|
||||
|
||||
FutureTask<String> task = new FutureTask<>(new Callable<String>() {
|
||||
@Override
|
||||
@@ -96,7 +96,7 @@ public class ExecutorBeanDefinitionParserTests {
|
||||
assertThat(getCorePoolSize(executor)).isEqualTo(9);
|
||||
assertThat(getMaxPoolSize(executor)).isEqualTo(9);
|
||||
assertThat(getKeepAliveSeconds(executor)).isEqualTo(37);
|
||||
assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(true);
|
||||
assertThat(getAllowCoreThreadTimeOut(executor)).isTrue();
|
||||
assertThat(getQueueCapacity(executor)).isEqualTo(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ExecutorBeanDefinitionParserTests {
|
||||
assertThat(getCorePoolSize(executor)).isEqualTo(123);
|
||||
assertThat(getMaxPoolSize(executor)).isEqualTo(123);
|
||||
assertThat(getKeepAliveSeconds(executor)).isEqualTo(60);
|
||||
assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(false);
|
||||
assertThat(getAllowCoreThreadTimeOut(executor)).isFalse();
|
||||
assertThat(getQueueCapacity(executor)).isEqualTo(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ExecutorBeanDefinitionParserTests {
|
||||
Object executor = this.context.getBean("propertyPlaceholderWithRange");
|
||||
assertThat(getCorePoolSize(executor)).isEqualTo(5);
|
||||
assertThat(getMaxPoolSize(executor)).isEqualTo(25);
|
||||
assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(false);
|
||||
assertThat(getAllowCoreThreadTimeOut(executor)).isFalse();
|
||||
assertThat(getQueueCapacity(executor)).isEqualTo(10);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class ExecutorBeanDefinitionParserTests {
|
||||
Object executor = this.context.getBean("propertyPlaceholderWithRangeAndCoreThreadTimeout");
|
||||
assertThat(getCorePoolSize(executor)).isEqualTo(99);
|
||||
assertThat(getMaxPoolSize(executor)).isEqualTo(99);
|
||||
assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(true);
|
||||
assertThat(getAllowCoreThreadTimeOut(executor)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -1242,7 +1242,7 @@ class DataBinderTests {
|
||||
assertThat(errors.getFieldError("name").getCodes()[2]).isEqualTo("NOT_ROD.java.lang.String");
|
||||
assertThat(errors.getFieldError("name").getCodes()[3]).isEqualTo("NOT_ROD");
|
||||
assertThat((errors.getFieldErrors("name").get(0)).getField()).isEqualTo("name");
|
||||
assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isEqualTo(null);
|
||||
assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isNull();
|
||||
|
||||
assertThat(errors.hasFieldErrors("spouse.age")).isTrue();
|
||||
assertThat(errors.getFieldErrorCount("spouse.age")).isEqualTo(1);
|
||||
@@ -1314,7 +1314,7 @@ class DataBinderTests {
|
||||
assertThat(errors.getFieldError("name").getCodes()[2]).isEqualTo("validation.NOT_ROD.java.lang.String");
|
||||
assertThat(errors.getFieldError("name").getCodes()[3]).isEqualTo("validation.NOT_ROD");
|
||||
assertThat((errors.getFieldErrors("name").get(0)).getField()).isEqualTo("name");
|
||||
assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isEqualTo(null);
|
||||
assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isNull();
|
||||
|
||||
assertThat(errors.hasFieldErrors("spouse.age")).isTrue();
|
||||
assertThat(errors.getFieldErrorCount("spouse.age")).isEqualTo(1);
|
||||
@@ -1339,7 +1339,7 @@ class DataBinderTests {
|
||||
assertThat(errors.getFieldErrorCount("spouse")).isEqualTo(1);
|
||||
assertThat(errors.getFieldError("spouse").getCode()).isEqualTo("SPOUSE_NOT_AVAILABLE");
|
||||
assertThat((errors.getFieldErrors("spouse").get(0)).getObjectName()).isEqualTo("tb");
|
||||
assertThat((errors.getFieldErrors("spouse").get(0)).getRejectedValue()).isEqualTo(null);
|
||||
assertThat((errors.getFieldErrors("spouse").get(0)).getRejectedValue()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,8 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
|
||||
}
|
||||
return NO_DEBUG_INFO_MAP;
|
||||
}
|
||||
// We cannot use try-with-resources here for the InputStream, since we have
|
||||
// custom handling of the close() method in a finally-block.
|
||||
try {
|
||||
ClassReader classReader = new ClassReader(is);
|
||||
Map<Executable, String[]> map = new ConcurrentHashMap<>(32);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,11 +48,11 @@ import org.springframework.util.StringUtils;
|
||||
* {@link #getGeneric(int...) generic parameters} along with the ability to ultimately
|
||||
* {@link #resolve() resolve} to a {@link java.lang.Class}.
|
||||
*
|
||||
* <p>{@code ResolvableTypes} may be obtained from {@link #forField(Field) fields},
|
||||
* {@link #forMethodParameter(Method, int) method parameters},
|
||||
* {@link #forMethodReturnType(Method) method returns} or
|
||||
* {@link #forClass(Class) classes}. Most methods on this class will themselves return
|
||||
* {@link ResolvableType ResolvableTypes}, allowing easy navigation. For example:
|
||||
* <p>A {@code ResolvableType} may be obtained from a {@linkplain #forField(Field) field},
|
||||
* a {@linkplain #forMethodParameter(Method, int) method parameter},
|
||||
* a {@linkplain #forMethodReturnType(Method) method return type}, or a
|
||||
* {@linkplain #forClass(Class) class}. Most methods on this class will themselves return
|
||||
* a {@code ResolvableType}, allowing for easy navigation. For example:
|
||||
* <pre class="code">
|
||||
* private HashMap<Integer, List<String>> myMap;
|
||||
*
|
||||
@@ -182,7 +182,7 @@ public class ResolvableType implements Serializable {
|
||||
|
||||
/**
|
||||
* Private constructor used to create a new {@link ResolvableType} on a {@link Class} basis.
|
||||
* Avoids all {@code instanceof} checks in order to create a straight {@link Class} wrapper.
|
||||
* <p>Avoids all {@code instanceof} checks in order to create a straight {@link Class} wrapper.
|
||||
* @since 4.2
|
||||
*/
|
||||
private ResolvableType(@Nullable Class<?> clazz) {
|
||||
@@ -406,7 +406,7 @@ public class ResolvableType implements Serializable {
|
||||
|
||||
/**
|
||||
* Convenience method to return this type as a resolvable {@link Collection} type.
|
||||
* Returns {@link #NONE} if this type does not implement or extend
|
||||
* <p>Returns {@link #NONE} if this type does not implement or extend
|
||||
* {@link Collection}.
|
||||
* @see #as(Class)
|
||||
* @see #asMap()
|
||||
@@ -417,7 +417,7 @@ public class ResolvableType implements Serializable {
|
||||
|
||||
/**
|
||||
* Convenience method to return this type as a resolvable {@link Map} type.
|
||||
* Returns {@link #NONE} if this type does not implement or extend
|
||||
* <p>Returns {@link #NONE} if this type does not implement or extend
|
||||
* {@link Map}.
|
||||
* @see #as(Class)
|
||||
* @see #asCollection()
|
||||
@@ -458,7 +458,7 @@ public class ResolvableType implements Serializable {
|
||||
|
||||
/**
|
||||
* Return a {@link ResolvableType} representing the direct supertype of this type.
|
||||
* If no supertype is available this method returns {@link #NONE}.
|
||||
* <p>If no supertype is available this method returns {@link #NONE}.
|
||||
* <p>Note: The resulting {@link ResolvableType} instance may not be {@link Serializable}.
|
||||
* @see #getInterfaces()
|
||||
*/
|
||||
@@ -608,7 +608,7 @@ public class ResolvableType implements Serializable {
|
||||
|
||||
/**
|
||||
* Return a {@link ResolvableType} for the specified nesting level.
|
||||
* See {@link #getNested(int, Map)} for details.
|
||||
* <p>See {@link #getNested(int, Map)} for details.
|
||||
* @param nestingLevel the nesting level
|
||||
* @return the {@link ResolvableType} type, or {@code #NONE}
|
||||
*/
|
||||
@@ -999,7 +999,7 @@ public class ResolvableType implements Serializable {
|
||||
/**
|
||||
* Return a {@link ResolvableType} for the specified {@link Class},
|
||||
* using the full generic type information for assignability checks.
|
||||
* For example: {@code ResolvableType.forClass(MyArrayList.class)}.
|
||||
* <p>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)
|
||||
* @return a {@link ResolvableType} for the specified class
|
||||
@@ -1014,7 +1014,7 @@ public class ResolvableType implements Serializable {
|
||||
* Return a {@link ResolvableType} for the specified {@link Class},
|
||||
* doing assignability checks against the raw class only (analogous to
|
||||
* {@link Class#isAssignableFrom}, which this serves as a wrapper for.
|
||||
* For example: {@code ResolvableType.forRawClass(List.class)}.
|
||||
* <p>For example: {@code ResolvableType.forRawClass(List.class)}.
|
||||
* @param clazz the class to introspect ({@code null} is semantically
|
||||
* equivalent to {@code Object.class} for typical use cases here)
|
||||
* @return a {@link ResolvableType} for the specified class
|
||||
@@ -1043,7 +1043,7 @@ public class ResolvableType implements Serializable {
|
||||
/**
|
||||
* Return a {@link ResolvableType} for the specified base type
|
||||
* (interface or base class) with a given implementation class.
|
||||
* For example: {@code ResolvableType.forClass(List.class, MyArrayList.class)}.
|
||||
* <p>For example: {@code ResolvableType.forClass(List.class, MyArrayList.class)}.
|
||||
* @param baseType the base type (must not be {@code null})
|
||||
* @param implementationClass the implementation class
|
||||
* @return a {@link ResolvableType} for the specified base type backed by the
|
||||
@@ -1085,7 +1085,7 @@ public class ResolvableType implements Serializable {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
Assert.notNull(generics, "Generics array must not be null");
|
||||
TypeVariable<?>[] variables = clazz.getTypeParameters();
|
||||
Assert.isTrue(variables.length == generics.length, "Mismatched number of generics specified");
|
||||
Assert.isTrue(variables.length == generics.length, () -> "Mismatched number of generics specified for " + clazz.toGenericString());
|
||||
|
||||
Type[] arguments = new Type[generics.length];
|
||||
for (int i = 0; i < generics.length; i++) {
|
||||
@@ -1238,7 +1238,7 @@ public class ResolvableType implements Serializable {
|
||||
|
||||
/**
|
||||
* Return a {@link ResolvableType} for the specified {@link Method} return type.
|
||||
* Use this variant when the class that declares the method includes generic
|
||||
* <p>Use this variant when the class that declares the method includes generic
|
||||
* parameter variables that are satisfied by the implementation class.
|
||||
* @param method the source for the method return type
|
||||
* @param implementationClass the implementation class
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,8 +71,8 @@ class GenericTypeResolverTests {
|
||||
void methodReturnTypes() {
|
||||
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class)).isEqualTo(Integer.class);
|
||||
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class)).isEqualTo(String.class);
|
||||
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class)).isEqualTo(null);
|
||||
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class)).isEqualTo(null);
|
||||
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class)).isNull();
|
||||
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -370,9 +370,9 @@ class ReactiveAdapterRegistryTests {
|
||||
|
||||
@Test
|
||||
void deferred() {
|
||||
assertThat(getAdapter(CompletableFuture.class).getDescriptor().isDeferred()).isEqualTo(false);
|
||||
assertThat(getAdapter(Deferred.class).getDescriptor().isDeferred()).isEqualTo(true);
|
||||
assertThat(getAdapter(kotlinx.coroutines.flow.Flow.class).getDescriptor().isDeferred()).isEqualTo(true);
|
||||
assertThat(getAdapter(CompletableFuture.class).getDescriptor().isDeferred()).isFalse();
|
||||
assertThat(getAdapter(Deferred.class).getDescriptor().isDeferred()).isTrue();
|
||||
assertThat(getAdapter(kotlinx.coroutines.flow.Flow.class).getDescriptor().isDeferred()).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,19 +83,19 @@ class ResolvableTypeTests {
|
||||
assertThat(none.asMap()).isEqualTo(ResolvableType.NONE);
|
||||
assertThat(none.getComponentType()).isEqualTo(ResolvableType.NONE);
|
||||
assertThat(none.getGeneric(0)).isEqualTo(ResolvableType.NONE);
|
||||
assertThat(none.getGenerics().length).isEqualTo(0);
|
||||
assertThat(none.getInterfaces().length).isEqualTo(0);
|
||||
assertThat(none.getGenerics()).isEmpty();
|
||||
assertThat(none.getInterfaces()).isEmpty();
|
||||
assertThat(none.getSuperType()).isEqualTo(ResolvableType.NONE);
|
||||
assertThat(none.getType()).isEqualTo(ResolvableType.EmptyType.INSTANCE);
|
||||
assertThat(none.hasGenerics()).isEqualTo(false);
|
||||
assertThat(none.isArray()).isEqualTo(false);
|
||||
assertThat(none.hasGenerics()).isFalse();
|
||||
assertThat(none.isArray()).isFalse();
|
||||
assertThat(none.resolve()).isNull();
|
||||
assertThat(none.resolve(String.class)).isEqualTo(String.class);
|
||||
assertThat(none.resolveGeneric(0)).isNull();
|
||||
assertThat(none.resolveGenerics().length).isEqualTo(0);
|
||||
assertThat(none.resolveGenerics()).isEmpty();
|
||||
assertThat(none.toString()).isEqualTo("?");
|
||||
assertThat(none.hasUnresolvableGenerics()).isEqualTo(false);
|
||||
assertThat(none.isAssignableFrom(ResolvableType.forClass(Object.class))).isEqualTo(false);
|
||||
assertThat(none.hasUnresolvableGenerics()).isFalse();
|
||||
assertThat(none.isAssignableFrom(ResolvableType.forClass(Object.class))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,9 +148,9 @@ class ResolvableTypeTests {
|
||||
|
||||
@Test
|
||||
void forInstanceMustNotBeNull() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ResolvableType.forInstance(null))
|
||||
.withMessageContaining("Instance must not be null");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ResolvableType.forInstance(null))
|
||||
.withMessage("Instance must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -201,9 +201,9 @@ class ResolvableTypeTests {
|
||||
|
||||
@Test
|
||||
void forFieldMustNotBeNull() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ResolvableType.forField(null))
|
||||
.withMessageContaining("Field must not be null");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ResolvableType.forField(null))
|
||||
.withMessage("Field must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -215,9 +215,9 @@ class ResolvableTypeTests {
|
||||
|
||||
@Test
|
||||
void forConstructorParameterMustNotBeNull() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ResolvableType.forConstructorParameter(null, 0))
|
||||
.withMessageContaining("Constructor must not be null");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ResolvableType.forConstructorParameter(null, 0))
|
||||
.withMessage("Constructor must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -229,9 +229,9 @@ class ResolvableTypeTests {
|
||||
|
||||
@Test
|
||||
void forMethodParameterByIndexMustNotBeNull() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ResolvableType.forMethodParameter(null, 0))
|
||||
.withMessageContaining("Method must not be null");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ResolvableType.forMethodParameter(null, 0))
|
||||
.withMessage("Method must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -269,9 +269,9 @@ class ResolvableTypeTests {
|
||||
|
||||
@Test
|
||||
void forMethodParameterMustNotBeNull() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ResolvableType.forMethodParameter(null))
|
||||
.withMessageContaining("MethodParameter must not be null");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ResolvableType.forMethodParameter(null))
|
||||
.withMessage("MethodParameter must not be null");
|
||||
}
|
||||
|
||||
@Test // SPR-16210
|
||||
@@ -296,9 +296,9 @@ class ResolvableTypeTests {
|
||||
|
||||
@Test
|
||||
void forMethodReturnMustNotBeNull() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ResolvableType.forMethodReturnType(null))
|
||||
.withMessageContaining("Method must not be null");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ResolvableType.forMethodReturnType(null))
|
||||
.withMessage("Method must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -317,7 +317,7 @@ class ResolvableTypeTests {
|
||||
void arrayClassType() throws Exception {
|
||||
ResolvableType type = ResolvableType.forField(Fields.class.getField("arrayClassType"));
|
||||
assertThat(type.getType()).isInstanceOf(Class.class);
|
||||
assertThat(((Class) type.getType()).isArray()).isEqualTo(true);
|
||||
assertThat(((Class) type.getType()).isArray()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -343,7 +343,7 @@ class ResolvableTypeTests {
|
||||
void getComponentTypeForClassArray() throws Exception {
|
||||
Field field = Fields.class.getField("arrayClassType");
|
||||
ResolvableType type = ResolvableType.forField(field);
|
||||
assertThat(type.isArray()).isEqualTo(true);
|
||||
assertThat(type.isArray()).isTrue();
|
||||
assertThat(type.getComponentType().getType())
|
||||
.isEqualTo(((Class) field.getGenericType()).getComponentType());
|
||||
}
|
||||
@@ -351,7 +351,7 @@ class ResolvableTypeTests {
|
||||
@Test
|
||||
void getComponentTypeForGenericArrayType() throws Exception {
|
||||
ResolvableType type = ResolvableType.forField(Fields.class.getField("genericArrayType"));
|
||||
assertThat(type.isArray()).isEqualTo(true);
|
||||
assertThat(type.isArray()).isTrue();
|
||||
assertThat(type.getComponentType().getType()).isEqualTo(
|
||||
((GenericArrayType) type.getType()).getGenericComponentType());
|
||||
}
|
||||
@@ -359,7 +359,7 @@ class ResolvableTypeTests {
|
||||
@Test
|
||||
void getComponentTypeForVariableThatResolvesToGenericArray() throws Exception {
|
||||
ResolvableType type = ResolvableType.forClass(ListOfGenericArray.class).asCollection().getGeneric();
|
||||
assertThat(type.isArray()).isEqualTo(true);
|
||||
assertThat(type.isArray()).isTrue();
|
||||
assertThat(type.getType()).isInstanceOf(TypeVariable.class);
|
||||
assertThat(type.getComponentType().getType().toString()).isEqualTo(
|
||||
"java.util.List<java.lang.String>");
|
||||
@@ -368,7 +368,7 @@ class ResolvableTypeTests {
|
||||
@Test
|
||||
void getComponentTypeForNonArray() throws Exception {
|
||||
ResolvableType type = ResolvableType.forClass(String.class);
|
||||
assertThat(type.isArray()).isEqualTo(false);
|
||||
assertThat(type.isArray()).isFalse();
|
||||
assertThat(type.getComponentType()).isEqualTo(ResolvableType.NONE);
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ class ResolvableTypeTests {
|
||||
@Test
|
||||
void getInterfaces() throws Exception {
|
||||
ResolvableType type = ResolvableType.forClass(ExtendsList.class);
|
||||
assertThat(type.getInterfaces().length).isEqualTo(0);
|
||||
assertThat(type.getInterfaces()).isEmpty();
|
||||
SortedSet<String> interfaces = new TreeSet<>();
|
||||
for (ResolvableType interfaceType : type.getSuperType().getInterfaces()) {
|
||||
interfaces.add(interfaceType.toString());
|
||||
@@ -529,8 +529,8 @@ class ResolvableTypeTests {
|
||||
@Test
|
||||
void hasGenerics() throws Exception {
|
||||
ResolvableType type = ResolvableType.forClass(ExtendsList.class);
|
||||
assertThat(type.hasGenerics()).isEqualTo(false);
|
||||
assertThat(type.asCollection().hasGenerics()).isEqualTo(true);
|
||||
assertThat(type.hasGenerics()).isFalse();
|
||||
assertThat(type.asCollection().hasGenerics()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -553,7 +553,7 @@ class ResolvableTypeTests {
|
||||
void noGetGenerics() throws Exception {
|
||||
ResolvableType type = ResolvableType.forClass(ExtendsList.class);
|
||||
ResolvableType[] generics = type.getGenerics();
|
||||
assertThat(generics.length).isEqualTo(0);
|
||||
assertThat(generics).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -602,7 +602,7 @@ class ResolvableTypeTests {
|
||||
ResolvableType type = ResolvableType.forField(Fields.class.getField("stringArrayList"));
|
||||
ResolvableType generic = type.asCollection().getGeneric();
|
||||
assertThat(generic.getType().toString()).isEqualTo("E");
|
||||
assertThat(generic.isArray()).isEqualTo(true);
|
||||
assertThat(generic.isArray()).isTrue();
|
||||
assertThat(generic.resolve()).isEqualTo(String[].class);
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ class ResolvableTypeTests {
|
||||
void resolveVariableGenericArray() throws Exception {
|
||||
ResolvableType type = ResolvableType.forField(Fields.class.getField("variableTypeGenericArray"), TypedFields.class);
|
||||
assertThat(type.getType().toString()).isEqualTo("T[]");
|
||||
assertThat(type.isArray()).isEqualTo(true);
|
||||
assertThat(type.isArray()).isTrue();
|
||||
assertThat(type.resolve()).isEqualTo(String[].class);
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ class ResolvableTypeTests {
|
||||
void resolveVariableGenericArrayUnknown() throws Exception {
|
||||
ResolvableType type = ResolvableType.forField(Fields.class.getField("variableTypeGenericArray"));
|
||||
assertThat(type.getType().toString()).isEqualTo("T[]");
|
||||
assertThat(type.isArray()).isEqualTo(true);
|
||||
assertThat(type.isArray()).isTrue();
|
||||
assertThat(type.resolve()).isNull();
|
||||
}
|
||||
|
||||
@@ -626,7 +626,7 @@ class ResolvableTypeTests {
|
||||
void resolveVariableGenericArrayUnknownWithFallback() throws Exception {
|
||||
ResolvableType type = ResolvableType.forField(Fields.class.getField("variableTypeGenericArray"));
|
||||
assertThat(type.getType().toString()).isEqualTo("T[]");
|
||||
assertThat(type.isArray()).isEqualTo(true);
|
||||
assertThat(type.isArray()).isTrue();
|
||||
assertThat(type.toClass()).isEqualTo(Object.class);
|
||||
}
|
||||
|
||||
@@ -965,16 +965,16 @@ class ResolvableTypeTests {
|
||||
|
||||
@Test
|
||||
void isAssignableFromMustNotBeNull() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ResolvableType.forClass(Object.class).isAssignableFrom((ResolvableType) null))
|
||||
.withMessageContaining("Type must not be null");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ResolvableType.forClass(Object.class).isAssignableFrom((ResolvableType) null))
|
||||
.withMessage("ResolvableType must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void isAssignableFromForNone() throws Exception {
|
||||
ResolvableType objectType = ResolvableType.forClass(Object.class);
|
||||
assertThat(objectType.isAssignableFrom(ResolvableType.NONE)).isEqualTo(false);
|
||||
assertThat(ResolvableType.NONE.isAssignableFrom(objectType)).isEqualTo(false);
|
||||
assertThat(objectType.isAssignableFrom(ResolvableType.NONE)).isFalse();
|
||||
assertThat(ResolvableType.NONE.isAssignableFrom(objectType)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1221,9 +1221,10 @@ class ResolvableTypeTests {
|
||||
|
||||
@Test
|
||||
void forClassWithMismatchedGenerics() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ResolvableType.forClassWithGenerics(Map.class, Integer.class))
|
||||
.withMessageContaining("Mismatched number of generics specified");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ResolvableType.forClassWithGenerics(Map.class, Integer.class))
|
||||
.withMessageContaining("Mismatched number of generics specified for")
|
||||
.withMessageContaining("java.util.Map<K,V>");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1262,19 +1263,19 @@ class ResolvableTypeTests {
|
||||
@Test
|
||||
void hasUnresolvableGenerics() throws Exception {
|
||||
ResolvableType type = ResolvableType.forField(Fields.class.getField("stringList"));
|
||||
assertThat(type.hasUnresolvableGenerics()).isEqualTo(false);
|
||||
assertThat(type.hasUnresolvableGenerics()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasUnresolvableGenericsBasedOnOwnGenerics() throws Exception {
|
||||
ResolvableType type = ResolvableType.forClass(List.class);
|
||||
assertThat(type.hasUnresolvableGenerics()).isEqualTo(true);
|
||||
assertThat(type.hasUnresolvableGenerics()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasUnresolvableGenericsWhenSelfNotResolvable() throws Exception {
|
||||
ResolvableType type = ResolvableType.forClass(List.class).getGeneric();
|
||||
assertThat(type.hasUnresolvableGenerics()).isEqualTo(false);
|
||||
assertThat(type.hasUnresolvableGenerics()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1283,7 +1284,7 @@ class ResolvableTypeTests {
|
||||
for (ResolvableType generic : type.getGenerics()) {
|
||||
assertThat(generic.resolve()).isNotNull();
|
||||
}
|
||||
assertThat(type.hasUnresolvableGenerics()).isEqualTo(true);
|
||||
assertThat(type.hasUnresolvableGenerics()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1292,7 +1293,7 @@ class ResolvableTypeTests {
|
||||
for (ResolvableType generic : type.getGenerics()) {
|
||||
assertThat(generic.resolve()).isNotNull();
|
||||
}
|
||||
assertThat(type.hasUnresolvableGenerics()).isEqualTo(true);
|
||||
assertThat(type.hasUnresolvableGenerics()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,8 +60,8 @@ class AnnotationAttributesTests {
|
||||
|
||||
assertThat(attributes.getString("name")).isEqualTo("dave");
|
||||
assertThat(attributes.getStringArray("names")).isEqualTo(new String[] {"dave", "frank", "hal"});
|
||||
assertThat(attributes.getBoolean("bool1")).isEqualTo(true);
|
||||
assertThat(attributes.getBoolean("bool2")).isEqualTo(false);
|
||||
assertThat(attributes.getBoolean("bool1")).isTrue();
|
||||
assertThat(attributes.getBoolean("bool2")).isFalse();
|
||||
assertThat(attributes.<Color>getEnum("color")).isEqualTo(Color.RED);
|
||||
assertThat(attributes.getClass("class").equals(Integer.class)).isTrue();
|
||||
assertThat(attributes.getClassArray("classes")).isEqualTo(new Class<?>[] {Number.class, Short.class, Integer.class});
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -257,7 +257,7 @@ class MissingMergedAnnotationTests {
|
||||
|
||||
@Test
|
||||
void synthesizeThrowsNoSuchElementException() {
|
||||
assertThatNoSuchElementException().isThrownBy(() -> this.missing.synthesize());
|
||||
assertThatNoSuchElementException().isThrownBy(this.missing::synthesize);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+20
-20
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,7 +79,7 @@ class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
void stringToCharacterEmptyString() {
|
||||
assertThat(conversionService.convert("", Character.class)).isEqualTo(null);
|
||||
assertThat(conversionService.convert("", Character.class)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,29 +95,29 @@ class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
void stringToBooleanTrue() {
|
||||
assertThat(conversionService.convert("true", Boolean.class)).isEqualTo(true);
|
||||
assertThat(conversionService.convert("on", Boolean.class)).isEqualTo(true);
|
||||
assertThat(conversionService.convert("yes", Boolean.class)).isEqualTo(true);
|
||||
assertThat(conversionService.convert("1", Boolean.class)).isEqualTo(true);
|
||||
assertThat(conversionService.convert("TRUE", Boolean.class)).isEqualTo(true);
|
||||
assertThat(conversionService.convert("ON", Boolean.class)).isEqualTo(true);
|
||||
assertThat(conversionService.convert("YES", Boolean.class)).isEqualTo(true);
|
||||
assertThat(conversionService.convert("true", Boolean.class)).isTrue();
|
||||
assertThat(conversionService.convert("on", Boolean.class)).isTrue();
|
||||
assertThat(conversionService.convert("yes", Boolean.class)).isTrue();
|
||||
assertThat(conversionService.convert("1", Boolean.class)).isTrue();
|
||||
assertThat(conversionService.convert("TRUE", Boolean.class)).isTrue();
|
||||
assertThat(conversionService.convert("ON", Boolean.class)).isTrue();
|
||||
assertThat(conversionService.convert("YES", Boolean.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void stringToBooleanFalse() {
|
||||
assertThat(conversionService.convert("false", Boolean.class)).isEqualTo(false);
|
||||
assertThat(conversionService.convert("off", Boolean.class)).isEqualTo(false);
|
||||
assertThat(conversionService.convert("no", Boolean.class)).isEqualTo(false);
|
||||
assertThat(conversionService.convert("0", Boolean.class)).isEqualTo(false);
|
||||
assertThat(conversionService.convert("FALSE", Boolean.class)).isEqualTo(false);
|
||||
assertThat(conversionService.convert("OFF", Boolean.class)).isEqualTo(false);
|
||||
assertThat(conversionService.convert("NO", Boolean.class)).isEqualTo(false);
|
||||
assertThat(conversionService.convert("false", Boolean.class)).isFalse();
|
||||
assertThat(conversionService.convert("off", Boolean.class)).isFalse();
|
||||
assertThat(conversionService.convert("no", Boolean.class)).isFalse();
|
||||
assertThat(conversionService.convert("0", Boolean.class)).isFalse();
|
||||
assertThat(conversionService.convert("FALSE", Boolean.class)).isFalse();
|
||||
assertThat(conversionService.convert("OFF", Boolean.class)).isFalse();
|
||||
assertThat(conversionService.convert("NO", Boolean.class)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void stringToBooleanEmptyString() {
|
||||
assertThat(conversionService.convert("", Boolean.class)).isEqualTo(null);
|
||||
assertThat(conversionService.convert("", Boolean.class)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -219,7 +219,7 @@ class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
void stringToNumberEmptyString() {
|
||||
assertThat(conversionService.convert("", Number.class)).isEqualTo(null);
|
||||
assertThat(conversionService.convert("", Number.class)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -234,7 +234,7 @@ class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
void stringToEnumEmptyString() {
|
||||
assertThat(conversionService.convert("", Foo.class)).isEqualTo(null);
|
||||
assertThat(conversionService.convert("", Foo.class)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -254,7 +254,7 @@ class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
void integerToEnumNull() {
|
||||
assertThat(conversionService.convert(null, Foo.class)).isEqualTo(null);
|
||||
assertThat(conversionService.convert(null, Foo.class)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -109,7 +109,7 @@ class GenericConversionServiceTests {
|
||||
|
||||
@Test
|
||||
void convertNullSource() {
|
||||
assertThat(conversionService.convert(null, Integer.class)).isEqualTo(null);
|
||||
assertThat(conversionService.convert(null, Integer.class)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -190,12 +190,7 @@ class GenericConversionServiceTests {
|
||||
|
||||
@Test
|
||||
void convertSuperSourceType() {
|
||||
conversionService.addConverter(new Converter<CharSequence, Integer>() {
|
||||
@Override
|
||||
public Integer convert(CharSequence source) {
|
||||
return Integer.valueOf(source.toString());
|
||||
}
|
||||
});
|
||||
conversionService.addConverter(CharSequence.class, Integer.class, source -> Integer.valueOf(source.toString()));
|
||||
Integer result = conversionService.convert("3", Integer.class);
|
||||
assertThat((int) result).isEqualTo((int) Integer.valueOf(3));
|
||||
}
|
||||
|
||||
+24
-57
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,16 +26,18 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.convert.ConversionFailedException;
|
||||
import org.springframework.core.convert.ConverterNotFoundException;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
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.assertj.core.api.InstanceOfAssertFactories.list;
|
||||
import static org.assertj.core.api.InstanceOfAssertFactories.stream;
|
||||
|
||||
/**
|
||||
* Tests for {@link StreamConverter}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Sam Brannen
|
||||
* @since 4.2
|
||||
*/
|
||||
class StreamConverterTests {
|
||||
@@ -57,60 +59,41 @@ class StreamConverterTests {
|
||||
@Test
|
||||
void convertFromStreamToList() throws NoSuchFieldException {
|
||||
this.conversionService.addConverter(Number.class, String.class, new ObjectToStringConverter());
|
||||
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
|
||||
Stream<Integer> stream = Stream.of(1, 2, 3);
|
||||
TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("listOfStrings"));
|
||||
Object result = this.conversionService.convert(stream, listOfStrings);
|
||||
|
||||
assertThat(result).as("Converted object must not be null").isNotNull();
|
||||
boolean condition = result instanceof List;
|
||||
assertThat(condition).as("Converted object must be a list").isTrue();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> content = (List<String>) result;
|
||||
assertThat(content.get(0)).isEqualTo("1");
|
||||
assertThat(content.get(1)).isEqualTo("2");
|
||||
assertThat(content.get(2)).isEqualTo("3");
|
||||
assertThat(content.size()).as("Wrong number of elements").isEqualTo(3);
|
||||
assertThat(result).asInstanceOf(list(String.class)).containsExactly("1", "2", "3");
|
||||
}
|
||||
|
||||
@Test
|
||||
void convertFromStreamToArray() throws NoSuchFieldException {
|
||||
this.conversionService.addConverterFactory(new NumberToNumberConverterFactory());
|
||||
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
|
||||
Stream<Integer> stream = Stream.of(1, 2, 3);
|
||||
TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs"));
|
||||
Object result = this.conversionService.convert(stream, arrayOfLongs);
|
||||
|
||||
assertThat(result).as("Converted object must not be null").isNotNull();
|
||||
assertThat(result.getClass().isArray()).as("Converted object must be an array").isTrue();
|
||||
Long[] content = (Long[]) result;
|
||||
assertThat(content[0]).isEqualTo(Long.valueOf(1L));
|
||||
assertThat(content[1]).isEqualTo(Long.valueOf(2L));
|
||||
assertThat(content[2]).isEqualTo(Long.valueOf(3L));
|
||||
assertThat(content.length).as("Wrong number of elements").isEqualTo(3);
|
||||
assertThat(content).containsExactly(1L, 2L, 3L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void convertFromStreamToRawList() throws NoSuchFieldException {
|
||||
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
|
||||
Stream<Integer> stream = Stream.of(1, 2, 3);
|
||||
TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("rawList"));
|
||||
Object result = this.conversionService.convert(stream, listOfStrings);
|
||||
|
||||
assertThat(result).as("Converted object must not be null").isNotNull();
|
||||
boolean condition = result instanceof List;
|
||||
assertThat(condition).as("Converted object must be a list").isTrue();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> content = (List<Object>) result;
|
||||
assertThat(content.get(0)).isEqualTo(1);
|
||||
assertThat(content.get(1)).isEqualTo(2);
|
||||
assertThat(content.get(2)).isEqualTo(3);
|
||||
assertThat(content.size()).as("Wrong number of elements").isEqualTo(3);
|
||||
assertThat(result).asInstanceOf(list(Object.class)).containsExactly(1, 2, 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void convertFromStreamToArrayNoConverter() throws NoSuchFieldException {
|
||||
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
|
||||
Stream<Integer> stream = Stream.of(1, 2, 3);
|
||||
TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs"));
|
||||
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() ->
|
||||
this.conversionService.convert(stream, arrayOfLongs))
|
||||
assertThatExceptionOfType(ConversionFailedException.class)
|
||||
.isThrownBy(() -> this.conversionService.convert(stream, arrayOfLongs))
|
||||
.withCauseInstanceOf(ConverterNotFoundException.class);
|
||||
}
|
||||
|
||||
@@ -118,13 +101,11 @@ class StreamConverterTests {
|
||||
@SuppressWarnings("resource")
|
||||
void convertFromListToStream() throws NoSuchFieldException {
|
||||
this.conversionService.addConverterFactory(new StringToNumberConverterFactory());
|
||||
List<String> stream = Arrays.asList("1", "2", "3");
|
||||
List<String> list = Arrays.asList("1", "2", "3");
|
||||
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("streamOfIntegers"));
|
||||
Object result = this.conversionService.convert(stream, streamOfInteger);
|
||||
Object result = this.conversionService.convert(list, streamOfInteger);
|
||||
|
||||
assertThat(result).as("Converted object must not be null").isNotNull();
|
||||
boolean condition = result instanceof Stream;
|
||||
assertThat(condition).as("Converted object must be a stream").isTrue();
|
||||
assertThat(result).as("Converted object must be a stream").isInstanceOf(Stream.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Stream<Integer> content = (Stream<Integer>) result;
|
||||
assertThat(content.mapToInt(x -> x).sum()).isEqualTo(6);
|
||||
@@ -133,39 +114,25 @@ class StreamConverterTests {
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void convertFromArrayToStream() throws NoSuchFieldException {
|
||||
Integer[] stream = new Integer[] {1, 0, 1};
|
||||
this.conversionService.addConverter(new Converter<Integer, Boolean>() {
|
||||
@Override
|
||||
public Boolean convert(Integer source) {
|
||||
return source == 1;
|
||||
}
|
||||
});
|
||||
Integer[] array = new Integer[] {1, 0, 1};
|
||||
this.conversionService.addConverter(Integer.class, Boolean.class, source -> source == 1);
|
||||
TypeDescriptor streamOfBoolean = new TypeDescriptor(Types.class.getField("streamOfBooleans"));
|
||||
Object result = this.conversionService.convert(stream, streamOfBoolean);
|
||||
Object result = this.conversionService.convert(array, streamOfBoolean);
|
||||
|
||||
assertThat(result).as("Converted object must not be null").isNotNull();
|
||||
boolean condition = result instanceof Stream;
|
||||
assertThat(condition).as("Converted object must be a stream").isTrue();
|
||||
@SuppressWarnings("unchecked")
|
||||
Stream<Boolean> content = (Stream<Boolean>) result;
|
||||
assertThat(content.filter(x -> x).count()).isEqualTo(2);
|
||||
assertThat(result).asInstanceOf(stream(Boolean.class)).filteredOn(x -> x).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void convertFromListToRawStream() throws NoSuchFieldException {
|
||||
List<String> stream = Arrays.asList("1", "2", "3");
|
||||
List<String> list = Arrays.asList("1", "2", "3");
|
||||
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("rawStream"));
|
||||
Object result = this.conversionService.convert(stream, streamOfInteger);
|
||||
Object result = this.conversionService.convert(list, streamOfInteger);
|
||||
|
||||
assertThat(result).as("Converted object must not be null").isNotNull();
|
||||
boolean condition = result instanceof Stream;
|
||||
assertThat(condition).as("Converted object must be a stream").isTrue();
|
||||
assertThat(result).as("Converted object must be a stream").isInstanceOf(Stream.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Stream<Object> content = (Stream<Object>) result;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
content.forEach(sb::append);
|
||||
assertThat(sb.toString()).isEqualTo("123");
|
||||
assertThat(content).containsExactly("1", "2", "3");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author 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,8 +47,8 @@ class ProfilesTests {
|
||||
|
||||
@Test
|
||||
void ofWhenEmptyThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
Profiles.of())
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(Profiles::of)
|
||||
.withMessageContaining("Must specify at least one profile");
|
||||
}
|
||||
|
||||
@@ -354,8 +354,8 @@ class ProfilesTests {
|
||||
|
||||
|
||||
private static void assertMalformed(Supplier<Profiles> supplier) {
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
supplier::get)
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(supplier::get)
|
||||
.withMessageContaining("Malformed");
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,7 +79,7 @@ class PropertySourceTests {
|
||||
PropertySource<?> ps1 = new MapPropertySource("ps1", map1);
|
||||
ps1.getSource();
|
||||
List<PropertySource<?>> propertySources = new ArrayList<>();
|
||||
assertThat(propertySources.add(ps1)).isEqualTo(true);
|
||||
assertThat(propertySources.add(ps1)).isTrue();
|
||||
assertThat(propertySources.contains(ps1)).isTrue();
|
||||
assertThat(propertySources.contains(PropertySource.named("ps1"))).isTrue();
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -212,7 +212,7 @@ public class StandardEnvironmentTests {
|
||||
void defaultProfileWithCircularPlaceholder() {
|
||||
try {
|
||||
System.setProperty(DEFAULT_PROFILES_PROPERTY_NAME, "${spring.profiles.default}");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> environment.getDefaultProfiles());
|
||||
assertThatIllegalArgumentException().isThrownBy(environment::getDefaultProfiles);
|
||||
}
|
||||
finally {
|
||||
System.clearProperty(DEFAULT_PROFILES_PROPERTY_NAME);
|
||||
|
||||
Vendored
+31
-31
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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 @@ class SystemEnvironmentPropertySourceTests {
|
||||
|
||||
@Test
|
||||
void none() {
|
||||
assertThat(ps.containsProperty("a.key")).isEqualTo(false);
|
||||
assertThat(ps.containsProperty("a.key")).isFalse();
|
||||
assertThat(ps.getProperty("a.key")).isNull();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class SystemEnvironmentPropertySourceTests {
|
||||
void normalWithoutPeriod() {
|
||||
envMap.put("akey", "avalue");
|
||||
|
||||
assertThat(ps.containsProperty("akey")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("akey")).isTrue();
|
||||
assertThat(ps.getProperty("akey")).isEqualTo("avalue");
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class SystemEnvironmentPropertySourceTests {
|
||||
void normalWithPeriod() {
|
||||
envMap.put("a.key", "a.value");
|
||||
|
||||
assertThat(ps.containsProperty("a.key")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("a.key")).isTrue();
|
||||
assertThat(ps.getProperty("a.key")).isEqualTo("a.value");
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ class SystemEnvironmentPropertySourceTests {
|
||||
void withUnderscore() {
|
||||
envMap.put("a_key", "a_value");
|
||||
|
||||
assertThat(ps.containsProperty("a_key")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("a.key")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("a_key")).isTrue();
|
||||
assertThat(ps.containsProperty("a.key")).isTrue();
|
||||
|
||||
assertThat(ps.getProperty("a_key")).isEqualTo("a_value");
|
||||
assertThat( ps.getProperty("a.key")).isEqualTo("a_value");
|
||||
@@ -97,30 +97,30 @@ class SystemEnvironmentPropertySourceTests {
|
||||
envMap.put("A_DOT.KEY", "a_dot_value");
|
||||
envMap.put("A_HYPHEN-KEY", "a_hyphen_value");
|
||||
|
||||
assertThat(ps.containsProperty("A_KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A.KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A-KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("a_key")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("a.key")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("a-key")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A_LONG_KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A.LONG.KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A-LONG-KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A.LONG-KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A-LONG.KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A_long_KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A.long.KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A-long-KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A.long-KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A-long.KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A_DOT.KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A-DOT.KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A_dot.KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A-dot.KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A_HYPHEN-KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A.HYPHEN-KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A_hyphen-KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A.hyphen-KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A_KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A.KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A-KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("a_key")).isTrue();
|
||||
assertThat(ps.containsProperty("a.key")).isTrue();
|
||||
assertThat(ps.containsProperty("a-key")).isTrue();
|
||||
assertThat(ps.containsProperty("A_LONG_KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A.LONG.KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A-LONG-KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A.LONG-KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A-LONG.KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A_long_KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A.long.KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A-long-KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A.long-KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A-long.KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A_DOT.KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A-DOT.KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A_dot.KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A-dot.KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A_HYPHEN-KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A.HYPHEN-KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A_hyphen-KEY")).isTrue();
|
||||
assertThat(ps.containsProperty("A.hyphen-KEY")).isTrue();
|
||||
|
||||
assertThat(ps.getProperty("A_KEY")).isEqualTo("a_value");
|
||||
assertThat(ps.getProperty("A.KEY")).isEqualTo("a_value");
|
||||
@@ -170,7 +170,7 @@ class SystemEnvironmentPropertySourceTests {
|
||||
}
|
||||
};
|
||||
|
||||
assertThat(ps.containsProperty("A_KEY")).isEqualTo(true);
|
||||
assertThat(ps.containsProperty("A_KEY")).isTrue();
|
||||
assertThat(ps.getProperty("A_KEY")).isEqualTo("a_value");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,37 +124,37 @@ class PathResourceTests {
|
||||
@Test
|
||||
void fileExists() {
|
||||
PathResource resource = new PathResource(TEST_FILE);
|
||||
assertThat(resource.exists()).isEqualTo(true);
|
||||
assertThat(resource.exists()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void dirExists() {
|
||||
PathResource resource = new PathResource(TEST_DIR);
|
||||
assertThat(resource.exists()).isEqualTo(true);
|
||||
assertThat(resource.exists()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void fileDoesNotExist() {
|
||||
PathResource resource = new PathResource(NON_EXISTING_FILE);
|
||||
assertThat(resource.exists()).isEqualTo(false);
|
||||
assertThat(resource.exists()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void fileIsReadable() {
|
||||
PathResource resource = new PathResource(TEST_FILE);
|
||||
assertThat(resource.isReadable()).isEqualTo(true);
|
||||
assertThat(resource.isReadable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotExistIsNotReadable() {
|
||||
PathResource resource = new PathResource(NON_EXISTING_FILE);
|
||||
assertThat(resource.isReadable()).isEqualTo(false);
|
||||
assertThat(resource.isReadable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void directoryIsNotReadable() {
|
||||
PathResource resource = new PathResource(TEST_DIR);
|
||||
assertThat(resource.isReadable()).isEqualTo(false);
|
||||
assertThat(resource.isReadable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -256,13 +256,13 @@ class PathResourceTests {
|
||||
@Test
|
||||
void fileIsWritable() {
|
||||
PathResource resource = new PathResource(TEST_FILE);
|
||||
assertThat(resource.isWritable()).isEqualTo(true);
|
||||
assertThat(resource.isWritable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void directoryIsNotWritable() {
|
||||
PathResource resource = new PathResource(TEST_DIR);
|
||||
assertThat(resource.isWritable()).isEqualTo(false);
|
||||
assertThat(resource.isWritable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -80,7 +80,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||
super.bufferFactory = bufferFactory;
|
||||
|
||||
Flux<DataBuffer> flux = DataBufferUtils.readInputStream(
|
||||
() -> this.resource.getInputStream(), super.bufferFactory, 3);
|
||||
this.resource::getInputStream, super.bufferFactory, 3);
|
||||
|
||||
verifyReadData(flux);
|
||||
}
|
||||
|
||||
+2
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author 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.core.task;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.util.ConcurrencyThrottleSupport;
|
||||
@@ -61,12 +59,7 @@ class SimpleAsyncTaskExecutorTests {
|
||||
@Test
|
||||
void threadFactoryOverridesDefaults() throws Exception {
|
||||
final Object monitor = new Object();
|
||||
SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor(new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
return new Thread(r, "test");
|
||||
}
|
||||
});
|
||||
SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor(runnable -> new Thread(runnable, "test"));
|
||||
ThreadNameHarvester task = new ThreadNameHarvester(monitor);
|
||||
executeAndWait(executor, task, monitor);
|
||||
assertThat(task.getThreadName()).isEqualTo("test");
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -115,7 +115,7 @@ class AnnotationMetadataTests {
|
||||
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.isAnnotated(IsAnnotatedAnnotation.class.getName())).isFalse();
|
||||
assertThat(metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName())).isNull();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,8 +28,8 @@ class PatternMatchUtilsTests {
|
||||
|
||||
@Test
|
||||
void trivial() {
|
||||
assertThat(PatternMatchUtils.simpleMatch((String) null, "")).isEqualTo(false);
|
||||
assertThat(PatternMatchUtils.simpleMatch("1", null)).isEqualTo(false);
|
||||
assertThat(PatternMatchUtils.simpleMatch((String) null, "")).isFalse();
|
||||
assertThat(PatternMatchUtils.simpleMatch("1", null)).isFalse();
|
||||
doTest("*", "123", true);
|
||||
doTest("123", "123", true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,18 +37,18 @@ class StringUtilsTests {
|
||||
@Test
|
||||
void hasTextBlank() {
|
||||
String blank = " ";
|
||||
assertThat(StringUtils.hasText(blank)).isEqualTo(false);
|
||||
assertThat(StringUtils.hasText(blank)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasTextNullEmpty() {
|
||||
assertThat(StringUtils.hasText(null)).isEqualTo(false);
|
||||
assertThat(StringUtils.hasText("")).isEqualTo(false);
|
||||
assertThat(StringUtils.hasText(null)).isFalse();
|
||||
assertThat(StringUtils.hasText("")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasTextValid() {
|
||||
assertThat(StringUtils.hasText("t")).isEqualTo(true);
|
||||
assertThat(StringUtils.hasText("t")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,7 +68,7 @@ class StringUtilsTests {
|
||||
|
||||
@Test
|
||||
void trimWhitespace() {
|
||||
assertThat(StringUtils.trimWhitespace(null)).isEqualTo(null);
|
||||
assertThat(StringUtils.trimWhitespace(null)).isNull();
|
||||
assertThat(StringUtils.trimWhitespace("")).isEqualTo("");
|
||||
assertThat(StringUtils.trimWhitespace(" ")).isEqualTo("");
|
||||
assertThat(StringUtils.trimWhitespace("\t")).isEqualTo("");
|
||||
@@ -83,7 +83,7 @@ class StringUtilsTests {
|
||||
|
||||
@Test
|
||||
void trimAllWhitespace() {
|
||||
assertThat(StringUtils.trimAllWhitespace(null)).isEqualTo(null);
|
||||
assertThat(StringUtils.trimAllWhitespace(null)).isNull();
|
||||
assertThat(StringUtils.trimAllWhitespace("")).isEqualTo("");
|
||||
assertThat(StringUtils.trimAllWhitespace(" ")).isEqualTo("");
|
||||
assertThat(StringUtils.trimAllWhitespace("\t")).isEqualTo("");
|
||||
@@ -98,7 +98,7 @@ class StringUtilsTests {
|
||||
|
||||
@Test
|
||||
void trimLeadingWhitespace() {
|
||||
assertThat(StringUtils.trimLeadingWhitespace(null)).isEqualTo(null);
|
||||
assertThat(StringUtils.trimLeadingWhitespace(null)).isNull();
|
||||
assertThat(StringUtils.trimLeadingWhitespace("")).isEqualTo("");
|
||||
assertThat(StringUtils.trimLeadingWhitespace(" ")).isEqualTo("");
|
||||
assertThat(StringUtils.trimLeadingWhitespace("\t")).isEqualTo("");
|
||||
@@ -113,7 +113,7 @@ class StringUtilsTests {
|
||||
|
||||
@Test
|
||||
void trimTrailingWhitespace() {
|
||||
assertThat(StringUtils.trimTrailingWhitespace(null)).isEqualTo(null);
|
||||
assertThat(StringUtils.trimTrailingWhitespace(null)).isNull();
|
||||
assertThat(StringUtils.trimTrailingWhitespace("")).isEqualTo("");
|
||||
assertThat(StringUtils.trimTrailingWhitespace(" ")).isEqualTo("");
|
||||
assertThat(StringUtils.trimTrailingWhitespace("\t")).isEqualTo("");
|
||||
@@ -128,7 +128,7 @@ class StringUtilsTests {
|
||||
|
||||
@Test
|
||||
void trimLeadingCharacter() {
|
||||
assertThat(StringUtils.trimLeadingCharacter(null, ' ')).isEqualTo(null);
|
||||
assertThat(StringUtils.trimLeadingCharacter(null, ' ')).isNull();
|
||||
assertThat(StringUtils.trimLeadingCharacter("", ' ')).isEqualTo("");
|
||||
assertThat(StringUtils.trimLeadingCharacter(" ", ' ')).isEqualTo("");
|
||||
assertThat(StringUtils.trimLeadingCharacter("\t", ' ')).isEqualTo("\t");
|
||||
@@ -141,7 +141,7 @@ class StringUtilsTests {
|
||||
|
||||
@Test
|
||||
void trimTrailingCharacter() {
|
||||
assertThat(StringUtils.trimTrailingCharacter(null, ' ')).isEqualTo(null);
|
||||
assertThat(StringUtils.trimTrailingCharacter(null, ' ')).isNull();
|
||||
assertThat(StringUtils.trimTrailingCharacter("", ' ')).isEqualTo("");
|
||||
assertThat(StringUtils.trimTrailingCharacter(" ", ' ')).isEqualTo("");
|
||||
assertThat(StringUtils.trimTrailingCharacter("\t", ' ')).isEqualTo("\t");
|
||||
@@ -152,6 +152,14 @@ class StringUtilsTests {
|
||||
assertThat(StringUtils.trimTrailingCharacter(" a b c ", ' ')).isEqualTo(" a b c");
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesCharacter() {
|
||||
assertThat(StringUtils.matchesCharacter(null, '/')).isFalse();
|
||||
assertThat(StringUtils.matchesCharacter("/a", '/')).isFalse();
|
||||
assertThat(StringUtils.matchesCharacter("a", '/')).isFalse();
|
||||
assertThat(StringUtils.matchesCharacter("/", '/')).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void startsWithIgnoreCase() {
|
||||
String prefix = "fOo";
|
||||
@@ -332,7 +340,7 @@ class StringUtilsTests {
|
||||
|
||||
@Test
|
||||
void getFilename() {
|
||||
assertThat(StringUtils.getFilename(null)).isEqualTo(null);
|
||||
assertThat(StringUtils.getFilename(null)).isNull();
|
||||
assertThat(StringUtils.getFilename("")).isEqualTo("");
|
||||
assertThat(StringUtils.getFilename("myfile")).isEqualTo("myfile");
|
||||
assertThat(StringUtils.getFilename("mypath/myfile")).isEqualTo("myfile");
|
||||
@@ -344,11 +352,11 @@ class StringUtilsTests {
|
||||
|
||||
@Test
|
||||
void getFilenameExtension() {
|
||||
assertThat(StringUtils.getFilenameExtension(null)).isEqualTo(null);
|
||||
assertThat(StringUtils.getFilenameExtension("")).isEqualTo(null);
|
||||
assertThat(StringUtils.getFilenameExtension("myfile")).isEqualTo(null);
|
||||
assertThat(StringUtils.getFilenameExtension("myPath/myfile")).isEqualTo(null);
|
||||
assertThat(StringUtils.getFilenameExtension("/home/user/.m2/settings/myfile")).isEqualTo(null);
|
||||
assertThat(StringUtils.getFilenameExtension(null)).isNull();
|
||||
assertThat(StringUtils.getFilenameExtension("")).isNull();
|
||||
assertThat(StringUtils.getFilenameExtension("myfile")).isNull();
|
||||
assertThat(StringUtils.getFilenameExtension("myPath/myfile")).isNull();
|
||||
assertThat(StringUtils.getFilenameExtension("/home/user/.m2/settings/myfile")).isNull();
|
||||
assertThat(StringUtils.getFilenameExtension("myfile.")).isEqualTo("");
|
||||
assertThat(StringUtils.getFilenameExtension("myPath/myfile.")).isEqualTo("");
|
||||
assertThat(StringUtils.getFilenameExtension("myfile.txt")).isEqualTo("txt");
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -332,8 +332,7 @@ class SettableListenableFutureTests {
|
||||
void cancelStateThrowsExceptionWhenCallingGet() throws ExecutionException, InterruptedException {
|
||||
settableListenableFuture.cancel(true);
|
||||
|
||||
assertThatExceptionOfType(CancellationException.class).isThrownBy(() ->
|
||||
settableListenableFuture.get());
|
||||
assertThatExceptionOfType(CancellationException.class).isThrownBy(settableListenableFuture::get);
|
||||
|
||||
assertThat(settableListenableFuture.isCancelled()).isTrue();
|
||||
assertThat(settableListenableFuture.isDone()).isTrue();
|
||||
|
||||
+4
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -179,12 +179,9 @@ abstract class AbstractStaxXMLReaderTests {
|
||||
ContentHandler contentHandler = mock(ContentHandler.class);
|
||||
willAnswer(new CopyCharsAnswer()).given(contentHandler).characters(any(char[].class), anyInt(), anyInt());
|
||||
willAnswer(new CopyCharsAnswer()).given(contentHandler).ignorableWhitespace(any(char[].class), anyInt(), anyInt());
|
||||
willAnswer(new Answer<Object>() {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
invocation.getArguments()[3] = new AttributesImpl((Attributes) invocation.getArguments()[3]);
|
||||
return null;
|
||||
}
|
||||
willAnswer(invocation -> {
|
||||
invocation.getArguments()[3] = new AttributesImpl((Attributes) invocation.getArguments()[3]);
|
||||
return null;
|
||||
}).given(contentHandler).startElement(anyString(), anyString(), anyString(), any(Attributes.class));
|
||||
return contentHandler;
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,7 @@ public class ExpressionStateTests extends AbstractExpressionTests {
|
||||
|
||||
state.setLocalVariable("foo", null);
|
||||
value = state.lookupLocalVariable("foo");
|
||||
assertThat(value).isEqualTo(null);
|
||||
assertThat(value).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,7 +101,7 @@ public class ExpressionStateTests extends AbstractExpressionTests {
|
||||
@Test
|
||||
public void testLocalVariableNestedScopes() {
|
||||
ExpressionState state = getState();
|
||||
assertThat(state.lookupLocalVariable("foo")).isEqualTo(null);
|
||||
assertThat(state.lookupLocalVariable("foo")).isNull();
|
||||
|
||||
state.setLocalVariable("foo",12);
|
||||
assertThat(state.lookupLocalVariable("foo")).isEqualTo(12);
|
||||
@@ -134,7 +134,7 @@ public class ExpressionStateTests extends AbstractExpressionTests {
|
||||
|
||||
|
||||
((StandardEvaluationContext) state.getEvaluationContext()).setRootObject(null);
|
||||
assertThat(state.getRootContextObject().getValue()).isEqualTo(null);
|
||||
assertThat(state.getRootContextObject().getValue()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -150,7 +150,7 @@ class IndexingTests {
|
||||
assertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("java.util.Map<java.lang.Integer, java.lang.Integer>");
|
||||
assertThat(expression.getValue(this)).isEqualTo(property);
|
||||
expression = parser.parseExpression("parameterizedMap['9']");
|
||||
assertThat(expression.getValue(this)).isEqualTo(null);
|
||||
assertThat(expression.getValue(this)).isNull();
|
||||
expression.setValue(this, "37");
|
||||
assertThat(expression.getValue(this)).isEqualTo(37);
|
||||
}
|
||||
|
||||
+48
-49
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,22 +52,22 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
|
||||
@Test
|
||||
public void testSimpleAccess01() {
|
||||
void simpleAccess01() {
|
||||
evaluate("name", "Nikola Tesla", String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleAccess02() {
|
||||
void simpleAccess02() {
|
||||
evaluate("placeOfBirth.city", "SmilJan", String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleAccess03() {
|
||||
void simpleAccess03() {
|
||||
evaluate("stringArrayOfThreeItems.length", "3", Integer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonExistentPropertiesAndMethods() {
|
||||
void nonExistentPropertiesAndMethods() {
|
||||
// madeup does not exist as a property
|
||||
evaluateAndCheckError("madeup", SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE, 0);
|
||||
|
||||
@@ -80,21 +80,21 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
* supplied resolver might be able to - so null shouldn't crash the reflection resolver.
|
||||
*/
|
||||
@Test
|
||||
public void testAccessingOnNullObject() {
|
||||
SpelExpression expr = (SpelExpression)parser.parseExpression("madeup");
|
||||
void accessingOnNullObject() {
|
||||
SpelExpression expr = (SpelExpression) parser.parseExpression("madeup");
|
||||
EvaluationContext context = new StandardEvaluationContext(null);
|
||||
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
|
||||
expr.getValue(context))
|
||||
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL));
|
||||
assertThatExceptionOfType(SpelEvaluationException.class)
|
||||
.isThrownBy(() -> expr.getValue(context))
|
||||
.extracting(SpelEvaluationException::getMessageCode).isEqualTo(SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL);
|
||||
assertThat(expr.isWritable(context)).isFalse();
|
||||
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
|
||||
expr.setValue(context, "abc"))
|
||||
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL));
|
||||
assertThatExceptionOfType(SpelEvaluationException.class)
|
||||
.isThrownBy(() -> expr.setValue(context, "abc"))
|
||||
.extracting(SpelEvaluationException::getMessageCode).isEqualTo(SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
}
|
||||
|
||||
@Test
|
||||
// Adding a new property accessor just for a particular type
|
||||
public void testAddingSpecificPropertyAccessor() {
|
||||
void addingSpecificPropertyAccessor() {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext ctx = new StandardEvaluationContext();
|
||||
|
||||
@@ -125,35 +125,34 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddingRemovingAccessors() {
|
||||
void addingAndRemovingAccessors() {
|
||||
StandardEvaluationContext ctx = new StandardEvaluationContext();
|
||||
|
||||
// reflective property accessor is the only one by default
|
||||
List<PropertyAccessor> propertyAccessors = ctx.getPropertyAccessors();
|
||||
assertThat(propertyAccessors.size()).isEqualTo(1);
|
||||
assertThat(ctx.getPropertyAccessors()).hasSize(1);
|
||||
|
||||
StringyPropertyAccessor spa = new StringyPropertyAccessor();
|
||||
ctx.addPropertyAccessor(spa);
|
||||
assertThat(ctx.getPropertyAccessors().size()).isEqualTo(2);
|
||||
assertThat(ctx.getPropertyAccessors()).hasSize(2);
|
||||
|
||||
List<PropertyAccessor> copy = new ArrayList<>(ctx.getPropertyAccessors());
|
||||
assertThat(ctx.removePropertyAccessor(spa)).isTrue();
|
||||
assertThat(ctx.removePropertyAccessor(spa)).isFalse();
|
||||
assertThat(ctx.getPropertyAccessors().size()).isEqualTo(1);
|
||||
assertThat(ctx.getPropertyAccessors()).hasSize(1);
|
||||
|
||||
ctx.setPropertyAccessors(copy);
|
||||
assertThat(ctx.getPropertyAccessors().size()).isEqualTo(2);
|
||||
assertThat(ctx.getPropertyAccessors()).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAccessingPropertyOfClass() {
|
||||
void accessingPropertyOfClass() {
|
||||
Expression expression = parser.parseExpression("name");
|
||||
Object value = expression.getValue(new StandardEvaluationContext(String.class));
|
||||
assertThat(value).isEqualTo("java.lang.String");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldAlwaysUsePropertyAccessorFromEvaluationContext() {
|
||||
void shouldAlwaysUsePropertyAccessorFromEvaluationContext() {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
Expression expression = parser.parseExpression("name");
|
||||
|
||||
@@ -167,19 +166,19 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void standardGetClassAccess() {
|
||||
void standardGetClassAccess() {
|
||||
assertThat(parser.parseExpression("'a'.class.name").getValue()).isEqualTo(String.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noGetClassAccess() {
|
||||
void noGetClassAccess() {
|
||||
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
|
||||
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
|
||||
parser.parseExpression("'a'.class.name").getValue(context));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyReadOnly() {
|
||||
void propertyReadOnly() {
|
||||
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
|
||||
|
||||
Expression expr = parser.parseExpression("name");
|
||||
@@ -193,7 +192,7 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyReadOnlyWithRecordStyle() {
|
||||
void propertyReadOnlyWithRecordStyle() {
|
||||
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
|
||||
|
||||
Expression expr = parser.parseExpression("name");
|
||||
@@ -207,7 +206,7 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyReadWrite() {
|
||||
void propertyReadWrite() {
|
||||
EvaluationContext context = SimpleEvaluationContext.forReadWriteDataBinding().build();
|
||||
|
||||
Expression expr = parser.parseExpression("name");
|
||||
@@ -226,27 +225,27 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyReadWriteWithRootObject() {
|
||||
Person target = new Person("p1");
|
||||
EvaluationContext context = SimpleEvaluationContext.forReadWriteDataBinding().withRootObject(target).build();
|
||||
assertThat(context.getRootObject().getValue()).isSameAs(target);
|
||||
void propertyReadWriteWithRootObject() {
|
||||
Person rootObject = new Person("p1");
|
||||
EvaluationContext context = SimpleEvaluationContext.forReadWriteDataBinding().withRootObject(rootObject).build();
|
||||
assertThat(context.getRootObject().getValue()).isSameAs(rootObject);
|
||||
|
||||
Expression expr = parser.parseExpression("name");
|
||||
assertThat(expr.getValue(context, target)).isEqualTo("p1");
|
||||
target.setName("p2");
|
||||
assertThat(expr.getValue(context, target)).isEqualTo("p2");
|
||||
assertThat(expr.getValue(context)).isEqualTo("p1");
|
||||
rootObject.setName("p2");
|
||||
assertThat(expr.getValue(context)).isEqualTo("p2");
|
||||
|
||||
parser.parseExpression("name='p3'").getValue(context, target);
|
||||
assertThat(target.getName()).isEqualTo("p3");
|
||||
assertThat(expr.getValue(context, target)).isEqualTo("p3");
|
||||
parser.parseExpression("name='p3'").getValue(context, rootObject);
|
||||
assertThat(rootObject.getName()).isEqualTo("p3");
|
||||
assertThat(expr.getValue(context)).isEqualTo("p3");
|
||||
|
||||
expr.setValue(context, target, "p4");
|
||||
assertThat(target.getName()).isEqualTo("p4");
|
||||
assertThat(expr.getValue(context, target)).isEqualTo("p4");
|
||||
expr.setValue(context, "p4");
|
||||
assertThat(rootObject.getName()).isEqualTo("p4");
|
||||
assertThat(expr.getValue(context)).isEqualTo("p4");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyAccessWithoutMethodResolver() {
|
||||
void propertyAccessWithoutMethodResolver() {
|
||||
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
|
||||
Person target = new Person("p1");
|
||||
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
|
||||
@@ -254,20 +253,20 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyAccessWithInstanceMethodResolver() {
|
||||
void propertyAccessWithInstanceMethodResolver() {
|
||||
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().withInstanceMethods().build();
|
||||
Person target = new Person("p1");
|
||||
assertThat(parser.parseExpression("name.substring(1)").getValue(context, target)).isEqualTo("1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyAccessWithInstanceMethodResolverAndTypedRootObject() {
|
||||
Person target = new Person("p1");
|
||||
void propertyAccessWithInstanceMethodResolverAndTypedRootObject() {
|
||||
Person rootObject = new Person("p1");
|
||||
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().
|
||||
withInstanceMethods().withTypedRootObject(target, TypeDescriptor.valueOf(Object.class)).build();
|
||||
withInstanceMethods().withTypedRootObject(rootObject, TypeDescriptor.valueOf(Object.class)).build();
|
||||
|
||||
assertThat(parser.parseExpression("name.substring(1)").getValue(context, target)).isEqualTo("1");
|
||||
assertThat(context.getRootObject().getValue()).isSameAs(target);
|
||||
assertThat(parser.parseExpression("name.substring(1)").getValue(context)).isEqualTo("1");
|
||||
assertThat(context.getRootObject().getValue()).isSameAs(rootObject);
|
||||
assertThat(context.getRootObject().getTypeDescriptor().getType()).isSameAs(Object.class);
|
||||
}
|
||||
|
||||
@@ -277,7 +276,7 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
Expression expression = parser.parseExpression("stringArrayOfThreeItems[3]");
|
||||
assertThatExceptionOfType(SpelEvaluationException.class)
|
||||
.isThrownBy(() -> expression.getValue(context, new Inventor()))
|
||||
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.ARRAY_INDEX_OUT_OF_BOUNDS));
|
||||
.extracting(SpelEvaluationException::getMessageCode).isEqualTo(SpelMessage.ARRAY_INDEX_OUT_OF_BOUNDS);
|
||||
}
|
||||
|
||||
|
||||
@@ -335,7 +334,7 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
|
||||
private final Map<String, Object> values;
|
||||
|
||||
public ConfigurablePropertyAccessor(Map<String, Object> values) {
|
||||
ConfigurablePropertyAccessor(Map<String, Object> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
|
||||
+20
-19
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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.expression.spel.testdata.PersonInOtherPackage;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.within;
|
||||
import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
|
||||
|
||||
/**
|
||||
* Checks SpelCompiler behavior. This should cover compilation all compiled node types.
|
||||
@@ -198,9 +199,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
@Test
|
||||
void operatorInstanceOf() {
|
||||
expression = parse("'xyz' instanceof T(String)");
|
||||
assertThat(expression.getValue()).isEqualTo(true);
|
||||
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(true);
|
||||
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
|
||||
|
||||
expression = parse("'xyz' instanceof T(Integer)");
|
||||
assertThat(expression.getValue()).isEqualTo(false);
|
||||
@@ -209,21 +210,21 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
expression = parse("#root instanceof T(java.util.List)");
|
||||
assertThat(expression.getValue(list)).isEqualTo(true);
|
||||
assertThat(expression.getValue(list)).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(list)).isEqualTo(true);
|
||||
assertThat(expression.getValue(list)).asInstanceOf(BOOLEAN).isTrue();
|
||||
|
||||
List<String>[] arrayOfLists = new List[] {new ArrayList<String>()};
|
||||
expression = parse("#root instanceof T(java.util.List[])");
|
||||
assertThat(expression.getValue(arrayOfLists)).isEqualTo(true);
|
||||
assertThat(expression.getValue(arrayOfLists)).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(arrayOfLists)).isEqualTo(true);
|
||||
assertThat(expression.getValue(arrayOfLists)).asInstanceOf(BOOLEAN).isTrue();
|
||||
|
||||
int[] intArray = new int[] {1,2,3};
|
||||
expression = parse("#root instanceof T(int[])");
|
||||
assertThat(expression.getValue(intArray)).isEqualTo(true);
|
||||
assertThat(expression.getValue(intArray)).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(intArray)).isEqualTo(true);
|
||||
assertThat(expression.getValue(intArray)).asInstanceOf(BOOLEAN).isTrue();
|
||||
|
||||
String root = null;
|
||||
expression = parse("#root instanceof T(Integer)");
|
||||
@@ -239,18 +240,18 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
root = "howdy!";
|
||||
expression = parse("#root instanceof T(java.lang.Object)");
|
||||
assertThat(expression.getValue(root)).isEqualTo(true);
|
||||
assertThat(expression.getValue(root)).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(root)).isEqualTo(true);
|
||||
assertThat(expression.getValue(root)).asInstanceOf(BOOLEAN).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void operatorInstanceOf_SPR14250() throws Exception {
|
||||
// primitive left operand - should get boxed, return true
|
||||
expression = parse("3 instanceof T(Integer)");
|
||||
assertThat(expression.getValue()).isEqualTo(true);
|
||||
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(true);
|
||||
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
|
||||
|
||||
// primitive left operand - should get boxed, return false
|
||||
expression = parse("3 instanceof T(String)");
|
||||
@@ -266,9 +267,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
// double slot left operand - should get boxed, return true
|
||||
expression = parse("3.0d instanceof T(Double)");
|
||||
assertThat(expression.getValue()).isEqualTo(true);
|
||||
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(true);
|
||||
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
|
||||
|
||||
// Only when the right hand operand is a direct type reference
|
||||
// will it be compilable.
|
||||
@@ -646,9 +647,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertThat(expression.getValue()).isEqualTo(false);
|
||||
|
||||
expression = parse("!false");
|
||||
assertThat(expression.getValue()).isEqualTo(true);
|
||||
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(true);
|
||||
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
|
||||
|
||||
boolean b = true;
|
||||
expression = parse("!#root");
|
||||
@@ -658,9 +659,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
b = false;
|
||||
expression = parse("!#root");
|
||||
assertThat(expression.getValue(b)).isEqualTo(true);
|
||||
assertThat(expression.getValue(b)).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(b)).isEqualTo(true);
|
||||
assertThat(expression.getValue(b)).asInstanceOf(BOOLEAN).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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 org.springframework.expression.spel.SpelParserConfiguration;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
|
||||
|
||||
/**
|
||||
* Tests for the {@link SpelCompiler}.
|
||||
@@ -69,10 +70,10 @@ class SpelCompilerTests {
|
||||
context.setVariable("user", new User());
|
||||
expression = parser.parseExpression("#root.isEditable(#user)");
|
||||
assertThat(SpelCompiler.compile(expression)).isFalse();
|
||||
assertThat(expression.getValue(context)).isEqualTo(true);
|
||||
assertThat(expression.getValue(context)).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertThat(SpelCompiler.compile(expression)).isTrue();
|
||||
SpelCompilationCoverageTests.assertIsCompiled(expression);
|
||||
assertThat(expression.getValue(context)).isEqualTo(true);
|
||||
assertThat(expression.getValue(context)).asInstanceOf(BOOLEAN).isTrue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,6 +23,7 @@ import javax.sql.DataSource;
|
||||
* of a given H2 sequence.
|
||||
*
|
||||
* @author Thomas Risberg
|
||||
* @author Henning Pöttker
|
||||
* @since 2.5
|
||||
*/
|
||||
public class H2SequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer {
|
||||
@@ -47,7 +48,7 @@ public class H2SequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncre
|
||||
|
||||
@Override
|
||||
protected String getSequenceQuery() {
|
||||
return "select " + getIncrementerName() + ".nextval from dual";
|
||||
return "values next value for " + getIncrementerName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author 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.jdbc.support.incrementer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.h2.engine.Mode.ModeEnum;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link H2SequenceMaxValueIncrementer}.
|
||||
*
|
||||
* @author Henning Pöttker
|
||||
* @author Sam Brannen
|
||||
* @since 5.3.15
|
||||
*/
|
||||
class H2SequenceMaxValueIncrementerTests {
|
||||
|
||||
/**
|
||||
* Tests that the incrementer works when using the JDBC connection URL used
|
||||
* in the {@code H2EmbeddedDatabaseConfigurer} which is used transparently
|
||||
* when using Spring's {@link EmbeddedDatabaseBuilder}.
|
||||
*
|
||||
* <p>In other words, this tests compatibility with the default H2
|
||||
* <em>compatibility mode</em>.
|
||||
*/
|
||||
@Test
|
||||
void incrementsSequenceUsingH2EmbeddedDatabaseConfigurer() {
|
||||
EmbeddedDatabase database = new EmbeddedDatabaseBuilder()
|
||||
.setType(EmbeddedDatabaseType.H2)
|
||||
.generateUniqueName(true)
|
||||
.addScript("classpath:/org/springframework/jdbc/support/incrementer/schema.sql")
|
||||
.build();
|
||||
|
||||
assertIncrements(database);
|
||||
|
||||
database.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the incrementer works when using all supported H2 <em>compatibility modes</em>.
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@EnumSource(ModeEnum.class)
|
||||
void incrementsSequenceWithExplicitH2CompatibilityMode(ModeEnum mode) {
|
||||
String connectionUrl = String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false;MODE=%s", UUID.randomUUID().toString(), mode);
|
||||
DataSource dataSource = new SimpleDriverDataSource(new org.h2.Driver(), connectionUrl, "sa", "");
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
jdbcTemplate.execute("CREATE SEQUENCE SEQ");
|
||||
|
||||
assertIncrements(dataSource);
|
||||
|
||||
jdbcTemplate.execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
private void assertIncrements(DataSource dataSource) {
|
||||
assertThat(new JdbcTemplate(dataSource).queryForObject("values next value for SEQ", int.class)).isEqualTo(1);
|
||||
|
||||
H2SequenceMaxValueIncrementer incrementer = new H2SequenceMaxValueIncrementer(dataSource, "SEQ");
|
||||
assertThat(incrementer.nextIntValue()).isEqualTo(2);
|
||||
assertThat(incrementer.nextStringValue()).isEqualTo("3");
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
CREATE TABLE users (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
|
||||
first_name VARCHAR(50) NOT NULL,
|
||||
last_name VARCHAR(50) NOT NULL
|
||||
)
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
DROP TABLE users IF EXISTS;
|
||||
|
||||
CREATE TABLE users (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
|
||||
first_name VARCHAR(50) NOT NULL,
|
||||
last_name VARCHAR(50) NOT NULL
|
||||
);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
CREATE SEQUENCE SEQ;
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -189,7 +189,7 @@ abstract class AbstractJmsAnnotationDrivenTests {
|
||||
simpleFactory.getListenerContainer("first").getEndpoint();
|
||||
assertThat(first.getId()).isEqualTo("first");
|
||||
assertThat(first.getDestination()).isEqualTo("myQueue");
|
||||
assertThat(first.getConcurrency()).isEqualTo(null);
|
||||
assertThat(first.getConcurrency()).isNull();
|
||||
|
||||
MethodJmsListenerEndpoint second = (MethodJmsListenerEndpoint)
|
||||
simpleFactory.getListenerContainer("second").getEndpoint();
|
||||
|
||||
+8
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -179,14 +179,14 @@ public class JmsListenerContainerFactoryTests {
|
||||
assertThat(container.getConnectionFactory()).isEqualTo(this.connectionFactory);
|
||||
assertThat(container.getDestinationResolver()).isEqualTo(this.destinationResolver);
|
||||
assertThat(container.getMessageConverter()).isEqualTo(this.messageConverter);
|
||||
assertThat(container.isSessionTransacted()).isEqualTo(true);
|
||||
assertThat(container.isSessionTransacted()).isTrue();
|
||||
assertThat(container.getSessionAcknowledgeMode()).isEqualTo(Session.DUPS_OK_ACKNOWLEDGE);
|
||||
assertThat(container.isPubSubDomain()).isEqualTo(true);
|
||||
assertThat(container.isReplyPubSubDomain()).isEqualTo(true);
|
||||
assertThat(container.isPubSubDomain()).isTrue();
|
||||
assertThat(container.isReplyPubSubDomain()).isTrue();
|
||||
assertThat(container.getReplyQosSettings()).isEqualTo(new QosSettings(1, 7, 5000));
|
||||
assertThat(container.isSubscriptionDurable()).isEqualTo(true);
|
||||
assertThat(container.isSubscriptionDurable()).isTrue();
|
||||
assertThat(container.getClientId()).isEqualTo("client-1234");
|
||||
assertThat(container.isAutoStartup()).isEqualTo(false);
|
||||
assertThat(container.isAutoStartup()).isFalse();
|
||||
}
|
||||
|
||||
private void setDefaultJcaConfig(DefaultJcaListenerContainerFactory factory) {
|
||||
@@ -206,9 +206,9 @@ public class JmsListenerContainerFactoryTests {
|
||||
JmsActivationSpecConfig config = container.getActivationSpecConfig();
|
||||
assertThat(config).isNotNull();
|
||||
assertThat(config.getAcknowledgeMode()).isEqualTo(Session.DUPS_OK_ACKNOWLEDGE);
|
||||
assertThat(config.isPubSubDomain()).isEqualTo(true);
|
||||
assertThat(config.isPubSubDomain()).isTrue();
|
||||
assertThat(container.getReplyQosSettings()).isEqualTo(new QosSettings(1, 7, 5000));
|
||||
assertThat(config.isSubscriptionDurable()).isEqualTo(true);
|
||||
assertThat(config.isSubscriptionDurable()).isTrue();
|
||||
assertThat(config.getClientId()).isEqualTo("client-1234");
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,8 +145,8 @@ public class JmsNamespaceHandlerTests {
|
||||
assertThat(container.getConnectionFactory()).as("explicit connection factory not set").isEqualTo(context.getBean(EXPLICIT_CONNECTION_FACTORY));
|
||||
assertThat(container.getDestinationResolver()).as("explicit destination resolver not set").isEqualTo(context.getBean("testDestinationResolver"));
|
||||
assertThat(container.getMessageConverter()).as("explicit message converter not set").isEqualTo(context.getBean("testMessageConverter"));
|
||||
assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isEqualTo(true);
|
||||
assertThat(container.isSubscriptionDurable()).as("Wrong durable flag").isEqualTo(true);
|
||||
assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isTrue();
|
||||
assertThat(container.isSubscriptionDurable()).as("Wrong durable flag").isTrue();
|
||||
assertThat(container.getCacheLevel()).as("wrong cache").isEqualTo(DefaultMessageListenerContainer.CACHE_CONNECTION);
|
||||
assertThat(container.getConcurrentConsumers()).as("wrong concurrency").isEqualTo(3);
|
||||
assertThat(container.getMaxConcurrentConsumers()).as("wrong concurrency").isEqualTo(5);
|
||||
@@ -166,7 +166,7 @@ public class JmsNamespaceHandlerTests {
|
||||
factory.createListenerContainer(createDummyEndpoint());
|
||||
assertThat(container.getResourceAdapter()).as("explicit resource adapter not set").isEqualTo(context.getBean("testResourceAdapter"));
|
||||
assertThat(container.getActivationSpecConfig().getMessageConverter()).as("explicit message converter not set").isEqualTo(context.getBean("testMessageConverter"));
|
||||
assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isEqualTo(true);
|
||||
assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isTrue();
|
||||
assertThat(container.getActivationSpecConfig().getMaxConcurrency()).as("wrong concurrency").isEqualTo(5);
|
||||
assertThat(container.getActivationSpecConfig().getPrefetchSize()).as("Wrong prefetch").isEqualTo(50);
|
||||
assertThat(container.getPhase()).as("Wrong phase").isEqualTo(77);
|
||||
@@ -248,20 +248,20 @@ public class JmsNamespaceHandlerTests {
|
||||
.getBean("listener1", DefaultMessageListenerContainer.class);
|
||||
DefaultMessageListenerContainer listener2 = this.context
|
||||
.getBean("listener2", DefaultMessageListenerContainer.class);
|
||||
assertThat(listener1.isPubSubDomain()).as("Wrong destination type on listener1").isEqualTo(true);
|
||||
assertThat(listener2.isPubSubDomain()).as("Wrong destination type on listener2").isEqualTo(true);
|
||||
assertThat(listener1.isReplyPubSubDomain()).as("Wrong response destination type on listener1").isEqualTo(false);
|
||||
assertThat(listener2.isReplyPubSubDomain()).as("Wrong response destination type on listener2").isEqualTo(false);
|
||||
assertThat(listener1.isPubSubDomain()).as("Wrong destination type on listener1").isTrue();
|
||||
assertThat(listener2.isPubSubDomain()).as("Wrong destination type on listener2").isTrue();
|
||||
assertThat(listener1.isReplyPubSubDomain()).as("Wrong response destination type on listener1").isFalse();
|
||||
assertThat(listener2.isReplyPubSubDomain()).as("Wrong response destination type on listener2").isFalse();
|
||||
|
||||
// JCA
|
||||
JmsMessageEndpointManager listener3 = this.context
|
||||
.getBean("listener3", JmsMessageEndpointManager.class);
|
||||
JmsMessageEndpointManager listener4 = this.context
|
||||
.getBean("listener4", JmsMessageEndpointManager.class);
|
||||
assertThat(listener3.isPubSubDomain()).as("Wrong destination type on listener3").isEqualTo(true);
|
||||
assertThat(listener4.isPubSubDomain()).as("Wrong destination type on listener4").isEqualTo(true);
|
||||
assertThat(listener3.isReplyPubSubDomain()).as("Wrong response destination type on listener3").isEqualTo(false);
|
||||
assertThat(listener4.isReplyPubSubDomain()).as("Wrong response destination type on listener4").isEqualTo(false);
|
||||
assertThat(listener3.isPubSubDomain()).as("Wrong destination type on listener3").isTrue();
|
||||
assertThat(listener4.isPubSubDomain()).as("Wrong destination type on listener4").isTrue();
|
||||
assertThat(listener3.isReplyPubSubDomain()).as("Wrong response destination type on listener3").isFalse();
|
||||
assertThat(listener4.isReplyPubSubDomain()).as("Wrong response destination type on listener4").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,6 +65,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
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.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -570,7 +571,7 @@ class MethodJmsListenerEndpointTests {
|
||||
this.invocations.put("resolveJmsMessageHeaderAccessor", true);
|
||||
assertThat(headers).as("MessageHeaders not injected").isNotNull();
|
||||
assertThat(headers.getPriority()).as("Missing JMS message priority header").isEqualTo(Integer.valueOf(9));
|
||||
assertThat(headers.getHeader("customBoolean")).as("Missing custom header").isEqualTo(true);
|
||||
assertThat(headers.getHeader("customBoolean")).as("Missing custom header").asInstanceOf(BOOLEAN).isTrue();
|
||||
}
|
||||
|
||||
public void resolveObjectPayload(MyBean bean) {
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,11 +52,11 @@ public class DefaultMessageListenerContainerTests {
|
||||
DefaultMessageListenerContainer container = createContainer(createFailingContainerFactory());
|
||||
container.setBackOff(backOff);
|
||||
container.start();
|
||||
assertThat(container.isRunning()).isEqualTo(true);
|
||||
assertThat(container.isRunning()).isTrue();
|
||||
|
||||
container.refreshConnectionUntilSuccessful();
|
||||
|
||||
assertThat(container.isRunning()).isEqualTo(false);
|
||||
assertThat(container.isRunning()).isFalse();
|
||||
verify(backOff).start();
|
||||
verify(execution).nextBackOff();
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class DefaultMessageListenerContainerTests {
|
||||
container.start();
|
||||
container.refreshConnectionUntilSuccessful();
|
||||
|
||||
assertThat(container.isRunning()).isEqualTo(false);
|
||||
assertThat(container.isRunning()).isFalse();
|
||||
verify(backOff).start();
|
||||
verify(execution, times(2)).nextBackOff();
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class DefaultMessageListenerContainerTests {
|
||||
container.start();
|
||||
container.refreshConnectionUntilSuccessful();
|
||||
|
||||
assertThat(container.isRunning()).isEqualTo(true);
|
||||
assertThat(container.isRunning()).isTrue();
|
||||
verify(backOff).start();
|
||||
verify(execution, times(1)).nextBackOff(); // only on attempt as the second one lead to a recovery
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,8 +34,8 @@ public class JmsMessageEndpointManagerTests {
|
||||
JmsActivationSpecConfig config = new JmsActivationSpecConfig();
|
||||
config.setPubSubDomain(false);
|
||||
endpoint.setActivationSpecConfig(config);
|
||||
assertThat(endpoint.isPubSubDomain()).isEqualTo(false);
|
||||
assertThat(endpoint.isReplyPubSubDomain()).isEqualTo(false);
|
||||
assertThat(endpoint.isPubSubDomain()).isFalse();
|
||||
assertThat(endpoint.isReplyPubSubDomain()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -44,8 +44,8 @@ public class JmsMessageEndpointManagerTests {
|
||||
JmsActivationSpecConfig config = new JmsActivationSpecConfig();
|
||||
config.setPubSubDomain(true);
|
||||
endpoint.setActivationSpecConfig(config);
|
||||
assertThat(endpoint.isPubSubDomain()).isEqualTo(true);
|
||||
assertThat(endpoint.isReplyPubSubDomain()).isEqualTo(true);
|
||||
assertThat(endpoint.isPubSubDomain()).isTrue();
|
||||
assertThat(endpoint.isReplyPubSubDomain()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,8 +55,8 @@ public class JmsMessageEndpointManagerTests {
|
||||
config.setPubSubDomain(true);
|
||||
config.setReplyPubSubDomain(false);
|
||||
endpoint.setActivationSpecConfig(config);
|
||||
assertThat(endpoint.isPubSubDomain()).isEqualTo(true);
|
||||
assertThat(endpoint.isReplyPubSubDomain()).isEqualTo(false);
|
||||
assertThat(endpoint.isPubSubDomain()).isTrue();
|
||||
assertThat(endpoint.isReplyPubSubDomain()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,7 +65,7 @@ public class JmsMessageHeaderAccessorTests {
|
||||
assertThat(headerAccessor.getMessageId()).isEqualTo("abcd-1234");
|
||||
assertThat(headerAccessor.getPriority()).isEqualTo(Integer.valueOf(9));
|
||||
assertThat(headerAccessor.getReplyTo()).isEqualTo(replyTo);
|
||||
assertThat(headerAccessor.getRedelivered()).isEqualTo(true);
|
||||
assertThat(headerAccessor.getRedelivered()).isTrue();
|
||||
assertThat(headerAccessor.getType()).isEqualTo("type");
|
||||
assertThat(headerAccessor.getTimestamp()).isEqualTo(4567);
|
||||
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,11 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the list of configured resolvers.
|
||||
* Clear the list of configured resolvers and the resolver cache.
|
||||
*/
|
||||
public void clear() {
|
||||
this.argumentResolvers.clear();
|
||||
this.argumentResolverCache.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,10 +86,11 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the list of configured resolvers.
|
||||
* Clear the list of configured resolvers and the resolver cache.
|
||||
*/
|
||||
public void clear() {
|
||||
this.argumentResolvers.clear();
|
||||
this.argumentResolverCache.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -422,7 +422,7 @@ public class MessageBrokerConfigurationTests {
|
||||
|
||||
DefaultUserDestinationResolver resolver = context.getBean(DefaultUserDestinationResolver.class);
|
||||
assertThat(resolver).isNotNull();
|
||||
assertThat(resolver.isRemoveLeadingSlash()).isEqualTo(false);
|
||||
assertThat(resolver.isRemoveLeadingSlash()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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 class ExecutorSubscribableChannelTests {
|
||||
|
||||
@Test
|
||||
public void subscribeTwice() {
|
||||
assertThat(this.channel.subscribe(this.handler)).isEqualTo(true);
|
||||
assertThat(this.channel.subscribe(this.handler)).isEqualTo(false);
|
||||
assertThat(this.channel.subscribe(this.handler)).isTrue();
|
||||
assertThat(this.channel.subscribe(this.handler)).isFalse();
|
||||
this.channel.send(this.message);
|
||||
verify(this.handler, times(1)).handleMessage(this.message);
|
||||
}
|
||||
@@ -107,8 +107,8 @@ public class ExecutorSubscribableChannelTests {
|
||||
@Test
|
||||
public void unsubscribeTwice() {
|
||||
this.channel.subscribe(this.handler);
|
||||
assertThat(this.channel.unsubscribe(this.handler)).isEqualTo(true);
|
||||
assertThat(this.channel.unsubscribe(this.handler)).isEqualTo(false);
|
||||
assertThat(this.channel.unsubscribe(this.handler)).isTrue();
|
||||
assertThat(this.channel.unsubscribe(this.handler)).isFalse();
|
||||
this.channel.send(this.message);
|
||||
verify(this.handler, never()).handleMessage(this.message);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -322,8 +322,8 @@ class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshaller> {
|
||||
verify(unmarshaller).unmarshal(sourceCaptor.capture());
|
||||
|
||||
SAXSource result = sourceCaptor.getValue();
|
||||
assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isEqualTo(true);
|
||||
assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isEqualTo(false);
|
||||
assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isTrue();
|
||||
assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isFalse();
|
||||
|
||||
// 2. external-general-entities and dtd support enabled
|
||||
|
||||
@@ -335,8 +335,8 @@ class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshaller> {
|
||||
verify(unmarshaller).unmarshal(sourceCaptor.capture());
|
||||
|
||||
result = sourceCaptor.getValue();
|
||||
assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isEqualTo(false);
|
||||
assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isEqualTo(true);
|
||||
assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isFalse();
|
||||
assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isTrue();
|
||||
}
|
||||
|
||||
@Test // SPR-10806
|
||||
@@ -356,8 +356,8 @@ class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshaller> {
|
||||
verify(unmarshaller).unmarshal(sourceCaptor.capture());
|
||||
|
||||
SAXSource result = sourceCaptor.getValue();
|
||||
assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isEqualTo(true);
|
||||
assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isEqualTo(false);
|
||||
assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isTrue();
|
||||
assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isFalse();
|
||||
|
||||
// 2. external-general-entities and dtd support enabled
|
||||
|
||||
@@ -369,8 +369,8 @@ class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshaller> {
|
||||
verify(unmarshaller).unmarshal(sourceCaptor.capture());
|
||||
|
||||
result = sourceCaptor.getValue();
|
||||
assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isEqualTo(false);
|
||||
assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isEqualTo(true);
|
||||
assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isFalse();
|
||||
assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isTrue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ dependencies {
|
||||
testImplementation(testFixtures(project(":spring-context")))
|
||||
testImplementation("io.projectreactor:reactor-test")
|
||||
testImplementation("io.r2dbc:r2dbc-h2")
|
||||
testImplementation("com.h2database:h2:1.4.200") {
|
||||
because("r2dbc-h2 does not yet support H2 2.0")
|
||||
}
|
||||
testImplementation("io.r2dbc:r2dbc-spi-test:0.8.1.RELEASE") {
|
||||
exclude group: "org.springframework", module: "spring-jdbc"
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
DROP TABLE users IF EXISTS;
|
||||
|
||||
CREATE TABLE users (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
|
||||
first_name VARCHAR(50) NOT NULL,
|
||||
last_name VARCHAR(50) NOT NULL
|
||||
);
|
||||
|
||||
+6
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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.test.web.servlet.result;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
@@ -27,6 +28,7 @@ import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
@@ -249,7 +251,9 @@ public class PrintingResultHandler implements ResultHandler {
|
||||
this.printer.printValue("Error message", response.getErrorMessage());
|
||||
this.printer.printValue("Headers", getResponseHeaders(response));
|
||||
this.printer.printValue("Content type", response.getContentType());
|
||||
this.printer.printValue("Body", response.getContentAsString());
|
||||
String body = (MediaType.APPLICATION_JSON_VALUE.equals(response.getContentType()) ?
|
||||
response.getContentAsString(StandardCharsets.UTF_8) : response.getContentAsString());
|
||||
this.printer.printValue("Body", body);
|
||||
this.printer.printValue("Forwarded URL", response.getForwardedUrl());
|
||||
this.printer.printValue("Redirected URL", response.getRedirectedUrl());
|
||||
printCookies(response.getCookies());
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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 class EventPublishingTestExecutionListenerIntegrationTests {
|
||||
|
||||
testContextManager.beforeTestMethod(testInstance, method);
|
||||
|
||||
assertThat(countDownLatch.await(2, TimeUnit.SECONDS)).isEqualTo(true);
|
||||
assertThat(countDownLatch.await(2, TimeUnit.SECONDS)).isTrue();
|
||||
|
||||
verify(listener, only()).beforeTestMethod(testContext);
|
||||
assertThat(TrackingAsyncUncaughtExceptionHandler.asyncException.getMessage())
|
||||
|
||||
+12
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,10 +54,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DirtiesContextWithContextHierarchyTests {
|
||||
|
||||
@Autowired
|
||||
private StringBuffer foo;
|
||||
private StringBuilder foo;
|
||||
|
||||
@Autowired
|
||||
private StringBuffer baz;
|
||||
private StringBuilder baz;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
@@ -74,7 +74,7 @@ class DirtiesContextWithContextHierarchyTests {
|
||||
@Order(1)
|
||||
void verifyOriginalStateAndDirtyContexts() {
|
||||
assertOriginalState();
|
||||
reverseStringBuffers();
|
||||
reverseStringBuilders();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,7 +90,7 @@ class DirtiesContextWithContextHierarchyTests {
|
||||
@DirtiesContext(hierarchyMode = HierarchyMode.CURRENT_LEVEL)
|
||||
void verifyOriginalStateWasReinstatedAndDirtyContextsAndTriggerCurrentLevelCacheClearing() {
|
||||
assertOriginalState();
|
||||
reverseStringBuffers();
|
||||
reverseStringBuilders();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,7 +100,7 @@ class DirtiesContextWithContextHierarchyTests {
|
||||
assertCleanChildContext();
|
||||
}
|
||||
|
||||
private void reverseStringBuffers() {
|
||||
private void reverseStringBuilders() {
|
||||
foo.reverse();
|
||||
baz.reverse();
|
||||
}
|
||||
@@ -131,13 +131,13 @@ class DirtiesContextWithContextHierarchyTests {
|
||||
static class ParentConfig {
|
||||
|
||||
@Bean
|
||||
StringBuffer foo() {
|
||||
return new StringBuffer("foo");
|
||||
StringBuilder foo() {
|
||||
return new StringBuilder("foo");
|
||||
}
|
||||
|
||||
@Bean
|
||||
StringBuffer baz() {
|
||||
return new StringBuffer("baz-parent");
|
||||
StringBuilder baz() {
|
||||
return new StringBuilder("baz-parent");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ class DirtiesContextWithContextHierarchyTests {
|
||||
static class ChildConfig {
|
||||
|
||||
@Bean
|
||||
StringBuffer baz() {
|
||||
return new StringBuffer("baz-child");
|
||||
StringBuilder baz() {
|
||||
return new StringBuilder("baz-child");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -175,7 +175,7 @@ class RegisterExtensionSpringExtensionTests {
|
||||
@Test
|
||||
void valueParameterFromDefaultValueForPropertyPlaceholder(@Value("${bogus:false}") Boolean defaultValue) {
|
||||
assertThat(defaultValue).as("Default value should have been injected via @Value by Spring").isNotNull();
|
||||
assertThat(defaultValue).as("default value").isEqualTo(false);
|
||||
assertThat(defaultValue).as("default value").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -169,7 +169,7 @@ class SpringExtensionTests {
|
||||
@Test
|
||||
void valueParameterFromDefaultValueForPropertyPlaceholder(@Value("${bogus:false}") Boolean defaultValue) {
|
||||
assertThat(defaultValue).as("Default value should have been injected via @Value by Spring").isNotNull();
|
||||
assertThat(defaultValue).as("default value").isEqualTo(false);
|
||||
assertThat(defaultValue).as("default value").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -155,7 +155,7 @@ class ReflectionTestUtilsTests {
|
||||
assertThat(person.getName()).as("name (protected field)").isEqualTo("Tom");
|
||||
assertThat(person.getAge()).as("age (private field)").isEqualTo(42);
|
||||
assertThat(person.getEyeColor()).as("eye color (package private field)").isEqualTo("blue");
|
||||
assertThat(person.likesPets()).as("'likes pets' flag (package private boolean field)").isEqualTo(true);
|
||||
assertThat(person.likesPets()).as("'likes pets' flag (package private boolean field)").isTrue();
|
||||
assertThat(person.getFavoriteNumber()).as("'favorite number' (package field)").isEqualTo(PI);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ class ReflectionTestUtilsTests {
|
||||
assertThat(target.getName()).as("name (protected field)").isEqualTo("Tom");
|
||||
assertThat(target.getAge()).as("age (private field)").isEqualTo(42);
|
||||
assertThat(target.getEyeColor()).as("eye color (package private field)").isEqualTo("blue");
|
||||
assertThat(target.likesPets()).as("'likes pets' flag (package private boolean field)").isEqualTo(true);
|
||||
assertThat(target.likesPets()).as("'likes pets' flag (package private boolean field)").isTrue();
|
||||
assertThat(target.getFavoriteNumber()).as("'favorite number' (package field)").isEqualTo(PI);
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ class ReflectionTestUtilsTests {
|
||||
assertThat(person.getName()).as("name (private method)").isEqualTo("Jerry");
|
||||
assertThat(person.getAge()).as("age (protected method)").isEqualTo(33);
|
||||
assertThat(person.getEyeColor()).as("eye color (package private method)").isEqualTo("green");
|
||||
assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isEqualTo(false);
|
||||
assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isFalse();
|
||||
assertThat(person.getFavoriteNumber()).as("'favorite number' (protected method for a Number)").isEqualTo(Integer.valueOf(42));
|
||||
|
||||
assertThat(invokeGetterMethod(person, "getId")).isEqualTo(Long.valueOf(1));
|
||||
@@ -284,7 +284,7 @@ class ReflectionTestUtilsTests {
|
||||
assertThat(person.getName()).as("name (private method)").isEqualTo("Tom");
|
||||
assertThat(person.getAge()).as("age (protected method)").isEqualTo(42);
|
||||
assertThat(person.getEyeColor()).as("eye color (package private method)").isEqualTo("blue");
|
||||
assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isEqualTo(true);
|
||||
assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isTrue();
|
||||
assertThat(person.getFavoriteNumber()).as("'favorite number' (protected method for a Number)").isEqualTo(PI);
|
||||
|
||||
assertThat(invokeGetterMethod(person, "id")).isEqualTo(Long.valueOf(99));
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -851,7 +851,7 @@ public class HtmlUnitRequestBuilderTests {
|
||||
public void buildRequestSessionIsNew() throws Exception {
|
||||
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
|
||||
|
||||
assertThat(actualRequest.getSession().isNew()).isEqualTo(true);
|
||||
assertThat(actualRequest.getSession().isNew()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -861,7 +861,7 @@ public class HtmlUnitRequestBuilderTests {
|
||||
|
||||
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
|
||||
|
||||
assertThat(actualRequest.getSession().isNew()).isEqualTo(false);
|
||||
assertThat(actualRequest.getSession().isNew()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -873,7 +873,7 @@ public class HtmlUnitRequestBuilderTests {
|
||||
HttpSession sessionToRemove = actualRequest.getSession();
|
||||
sessionToRemove.invalidate();
|
||||
|
||||
assertThat(sessions.containsKey(sessionToRemove.getId())).isEqualTo(false);
|
||||
assertThat(sessions.containsKey(sessionToRemove.getId())).isFalse();
|
||||
assertSingleSessionCookie("JSESSIONID=" + sessionToRemove.getId()
|
||||
+ "; Expires=Thu, 01-Jan-1970 00:00:01 GMT; Path=/test; Domain=example.com");
|
||||
|
||||
@@ -882,8 +882,8 @@ public class HtmlUnitRequestBuilderTests {
|
||||
|
||||
actualRequest = requestBuilder.buildRequest(servletContext);
|
||||
|
||||
assertThat(actualRequest.getSession().isNew()).isEqualTo(true);
|
||||
assertThat(sessions.containsKey(sessionToRemove.getId())).isEqualTo(false);
|
||||
assertThat(actualRequest.getSession().isNew()).isTrue();
|
||||
assertThat(sessions.containsKey(sessionToRemove.getId())).isFalse();
|
||||
}
|
||||
|
||||
// --- setContextPath
|
||||
|
||||
+24
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,10 +23,12 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.result.PrintingResultHandler;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
@@ -61,6 +63,22 @@ class PrintingResultHandlerIntegrationTests {
|
||||
.contains("Headers = [Set-Cookie:\"enigma=42\", Content-Type:\"text/plain;charset=ISO-8859-1\", Content-Length:\"14\"]");
|
||||
}
|
||||
|
||||
@Test
|
||||
void printMvcResultsToWriterWithJsonResponseBodyInterpretedAsUtf8() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
standaloneSetup(new SimpleController()).build()
|
||||
// "Hallöchen" is German slang for "hello".
|
||||
.perform(get("/utf8").accept(MediaType.APPLICATION_JSON).content("Hallöchen, Welt!".getBytes(UTF_8)).characterEncoding(UTF_8))
|
||||
.andDo(print(writer))
|
||||
// "Grüß dich!" is German for "greetings to you".
|
||||
.andExpect(content().bytes("Grüß dich!".getBytes(UTF_8)));
|
||||
|
||||
assertThat(writer).asString()
|
||||
.contains("Body = Hallöchen, Welt!")
|
||||
.contains("Body = Grüß dich!");
|
||||
}
|
||||
|
||||
@Test
|
||||
void printMvcResultsToWriterWithFailingGlobalResultMatcher() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
@@ -92,6 +110,11 @@ class PrintingResultHandlerIntegrationTests {
|
||||
response.addCookie(new Cookie("enigma", "42"));
|
||||
return "Hello Response";
|
||||
}
|
||||
|
||||
@GetMapping("/utf8")
|
||||
String utf8(HttpServletResponse response) {
|
||||
return "Grüß dich!";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ DROP TABLE drivers_license IF EXISTS;
|
||||
DROP TABLE person IF EXISTS;
|
||||
|
||||
CREATE TABLE person (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
drivers_license_id INTEGER NOT NULL
|
||||
);
|
||||
@@ -10,7 +10,7 @@ CREATE UNIQUE INDEX person_name ON person(name);
|
||||
CREATE UNIQUE INDEX person_drivers_license_id ON person(drivers_license_id);
|
||||
|
||||
CREATE TABLE drivers_license (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
|
||||
license_number INTEGER NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX drivers_license_license_number ON drivers_license(license_number);
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
CREATE TABLE enigma (
|
||||
id INTEGER NOT NULL IDENTITY
|
||||
id INTEGER GENERATED BY DEFAULT AS IDENTITY
|
||||
);
|
||||
|
||||
+21
-24
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,62 +34,59 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
* @author Sam Brannen
|
||||
* @since 09.04.2003
|
||||
*/
|
||||
public class RollbackRuleTests {
|
||||
class RollbackRuleTests {
|
||||
|
||||
@Test
|
||||
public void foundImmediatelyWithString() {
|
||||
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Exception.class.getName());
|
||||
void foundImmediatelyWithString() {
|
||||
RollbackRuleAttribute rr = new RollbackRuleAttribute(Exception.class.getName());
|
||||
assertThat(rr.getDepth(new Exception())).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void foundImmediatelyWithClass() {
|
||||
void foundImmediatelyWithClass() {
|
||||
RollbackRuleAttribute rr = new RollbackRuleAttribute(Exception.class);
|
||||
assertThat(rr.getDepth(new Exception())).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notFound() {
|
||||
void notFound() {
|
||||
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.io.IOException.class.getName());
|
||||
assertThat(rr.getDepth(new MyRuntimeException(""))).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ancestry() {
|
||||
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Exception.class.getName());
|
||||
void ancestry() {
|
||||
RollbackRuleAttribute rr = new RollbackRuleAttribute(Exception.class.getName());
|
||||
// Exception -> Runtime -> NestedRuntime -> MyRuntimeException
|
||||
assertThat(rr.getDepth(new MyRuntimeException(""))).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alwaysTrueForThrowable() {
|
||||
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Throwable.class.getName());
|
||||
assertThat(rr.getDepth(new MyRuntimeException("")) > 0).isTrue();
|
||||
assertThat(rr.getDepth(new IOException()) > 0).isTrue();
|
||||
assertThat(rr.getDepth(new FatalBeanException(null,null)) > 0).isTrue();
|
||||
assertThat(rr.getDepth(new RuntimeException()) > 0).isTrue();
|
||||
void alwaysTrueForThrowable() {
|
||||
RollbackRuleAttribute rr = new RollbackRuleAttribute(Throwable.class.getName());
|
||||
assertThat(rr.getDepth(new MyRuntimeException(""))).isGreaterThan(0);
|
||||
assertThat(rr.getDepth(new IOException())).isGreaterThan(0);
|
||||
assertThat(rr.getDepth(new FatalBeanException(null, null))).isGreaterThan(0);
|
||||
assertThat(rr.getDepth(new RuntimeException())).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ctorArgMustBeAThrowableClassWithNonThrowableType() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new RollbackRuleAttribute(StringBuffer.class));
|
||||
void ctorArgMustBeAThrowableClassWithNonThrowableType() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new RollbackRuleAttribute(Object.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ctorArgMustBeAThrowableClassWithNullThrowableType() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new RollbackRuleAttribute((Class<?>) null));
|
||||
void ctorArgMustBeAThrowableClassWithNullThrowableType() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new RollbackRuleAttribute((Class<?>) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ctorArgExceptionStringNameVersionWithNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new RollbackRuleAttribute((String) null));
|
||||
void ctorArgExceptionStringNameVersionWithNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new RollbackRuleAttribute((String) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void foundEnclosedExceptionWithEnclosingException() {
|
||||
void foundEnclosedExceptionWithEnclosingException() {
|
||||
RollbackRuleAttribute rr = new RollbackRuleAttribute(EnclosingException.class);
|
||||
assertThat(rr.getDepth(new EnclosingException.EnclosedException())).isEqualTo(0);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,7 +56,7 @@ public class JtaTransactionManagerSerializationTests {
|
||||
.getUserTransaction() == ut2).as("UserTransaction looked up on client").isTrue();
|
||||
assertThat(serializedJtatm
|
||||
.getTransactionManager()).as("TransactionManager didn't survive").isNull();
|
||||
assertThat(serializedJtatm.isRollbackOnCommitFailure()).isEqualTo(true);
|
||||
assertThat(serializedJtatm.isRollbackOnCommitFailure()).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,7 +81,7 @@ public abstract class AbstractClientHttpRequest implements ClientHttpRequest {
|
||||
return this.readOnlyHeaders;
|
||||
}
|
||||
else if (State.COMMITTED.equals(this.state.get())) {
|
||||
this.readOnlyHeaders = HttpHeaders.readOnlyHttpHeaders(this.headers);
|
||||
this.readOnlyHeaders = initReadOnlyHeaders();
|
||||
return this.readOnlyHeaders;
|
||||
}
|
||||
else {
|
||||
@@ -89,6 +89,16 @@ public abstract class AbstractClientHttpRequest implements ClientHttpRequest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the read-only headers after the request is committed.
|
||||
* <p>By default, this method simply applies a read-only wrapper.
|
||||
* Subclasses can do the same for headers from the native request.
|
||||
* @since 5.3.15
|
||||
*/
|
||||
protected HttpHeaders initReadOnlyHeaders() {
|
||||
return HttpHeaders.readOnlyHttpHeaders(this.headers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiValueMap<String, HttpCookie> getCookies() {
|
||||
if (State.COMMITTED.equals(this.state.get())) {
|
||||
|
||||
+12
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,6 +62,8 @@ class HttpComponentsClientHttpRequest extends AbstractClientHttpRequest {
|
||||
@Nullable
|
||||
private Flux<ByteBuffer> byteBufferFlux;
|
||||
|
||||
private transient long contentLength = -1;
|
||||
|
||||
|
||||
public HttpComponentsClientHttpRequest(HttpMethod method, URI uri, HttpClientContext context,
|
||||
DataBufferFactory dataBufferFactory) {
|
||||
@@ -130,6 +132,8 @@ class HttpComponentsClientHttpRequest extends AbstractClientHttpRequest {
|
||||
if (!this.httpRequest.containsHeader(HttpHeaders.ACCEPT)) {
|
||||
this.httpRequest.addHeader(HttpHeaders.ACCEPT, ALL_VALUE);
|
||||
}
|
||||
|
||||
this.contentLength = headers.getContentLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,6 +155,11 @@ class HttpComponentsClientHttpRequest extends AbstractClientHttpRequest {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HttpHeaders initReadOnlyHeaders() {
|
||||
return HttpHeaders.readOnlyHttpHeaders(new HttpComponentsHeadersAdapter(this.httpRequest));
|
||||
}
|
||||
|
||||
public AsyncRequestProducer toRequestProducer() {
|
||||
ReactiveEntityProducer reactiveEntityProducer = null;
|
||||
|
||||
@@ -160,8 +169,8 @@ class HttpComponentsClientHttpRequest extends AbstractClientHttpRequest {
|
||||
if (getHeaders().getContentType() != null) {
|
||||
contentType = ContentType.parse(getHeaders().getContentType().toString());
|
||||
}
|
||||
reactiveEntityProducer = new ReactiveEntityProducer(this.byteBufferFlux, getHeaders().getContentLength(),
|
||||
contentType, contentEncoding);
|
||||
reactiveEntityProducer = new ReactiveEntityProducer(
|
||||
this.byteBufferFlux, this.contentLength, contentType, contentEncoding);
|
||||
}
|
||||
|
||||
return new BasicRequestProducer(this.httpRequest, reactiveEntityProducer);
|
||||
|
||||
+18
-18
@@ -28,7 +28,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.hc.core5.http.Header;
|
||||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.HttpMessage;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -44,23 +44,23 @@ import org.springframework.util.MultiValueMap;
|
||||
*/
|
||||
class HttpComponentsHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
private final HttpResponse response;
|
||||
private final HttpMessage message;
|
||||
|
||||
|
||||
HttpComponentsHeadersAdapter(HttpResponse response) {
|
||||
this.response = response;
|
||||
HttpComponentsHeadersAdapter(HttpMessage message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getFirst(String key) {
|
||||
Header header = this.response.getFirstHeader(key);
|
||||
Header header = this.message.getFirstHeader(key);
|
||||
return (header != null ? header.getValue() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(String key, @Nullable String value) {
|
||||
this.response.addHeader(key, value);
|
||||
this.message.addHeader(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,7 +75,7 @@ class HttpComponentsHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void set(String key, @Nullable String value) {
|
||||
this.response.setHeader(key, value);
|
||||
this.message.setHeader(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,29 +86,29 @@ class HttpComponentsHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Override
|
||||
public Map<String, String> toSingleValueMap() {
|
||||
Map<String, String> map = CollectionUtils.newLinkedHashMap(size());
|
||||
this.response.headerIterator().forEachRemaining(h -> map.putIfAbsent(h.getName(), h.getValue()));
|
||||
this.message.headerIterator().forEachRemaining(h -> map.putIfAbsent(h.getName(), h.getValue()));
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return this.response.getHeaders().length;
|
||||
return this.message.getHeaders().length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return (this.response.getHeaders().length == 0);
|
||||
return (this.message.getHeaders().length == 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
return (key instanceof String && this.response.containsHeader((String) key));
|
||||
return (key instanceof String && this.message.containsHeader((String) key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
return (value instanceof String &&
|
||||
Arrays.stream(this.response.getHeaders()).anyMatch(h -> h.getValue().equals(value)));
|
||||
Arrays.stream(this.message.getHeaders()).anyMatch(h -> h.getValue().equals(value)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -116,7 +116,7 @@ class HttpComponentsHeadersAdapter implements MultiValueMap<String, String> {
|
||||
public List<String> get(Object key) {
|
||||
List<String> values = null;
|
||||
if (containsKey(key)) {
|
||||
Header[] headers = this.response.getHeaders((String) key);
|
||||
Header[] headers = this.message.getHeaders((String) key);
|
||||
values = new ArrayList<>(headers.length);
|
||||
for (Header header : headers) {
|
||||
values.add(header.getValue());
|
||||
@@ -138,7 +138,7 @@ class HttpComponentsHeadersAdapter implements MultiValueMap<String, String> {
|
||||
public List<String> remove(Object key) {
|
||||
if (key instanceof String) {
|
||||
List<String> oldValues = get(key);
|
||||
this.response.removeHeaders((String) key);
|
||||
this.message.removeHeaders((String) key);
|
||||
return oldValues;
|
||||
}
|
||||
return null;
|
||||
@@ -151,13 +151,13 @@ class HttpComponentsHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.response.setHeaders();
|
||||
this.message.setHeaders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> keySet() {
|
||||
Set<String> keys = new LinkedHashSet<>(size());
|
||||
for (Header header : this.response.getHeaders()) {
|
||||
for (Header header : this.message.getHeaders()) {
|
||||
keys.add(header.getName());
|
||||
}
|
||||
return keys;
|
||||
@@ -166,7 +166,7 @@ class HttpComponentsHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Override
|
||||
public Collection<List<String>> values() {
|
||||
Collection<List<String>> values = new ArrayList<>(size());
|
||||
for (Header header : this.response.getHeaders()) {
|
||||
for (Header header : this.message.getHeaders()) {
|
||||
values.add(get(header.getName()));
|
||||
}
|
||||
return values;
|
||||
@@ -196,7 +196,7 @@ class HttpComponentsHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
private class EntryIterator implements Iterator<Entry<String, List<String>>> {
|
||||
|
||||
private Iterator<Header> iterator = response.headerIterator();
|
||||
private final Iterator<Header> iterator = message.headerIterator();
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
|
||||
+6
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -126,7 +126,6 @@ class JettyClientHttpRequest extends AbstractClientHttpRequest {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void applyCookies() {
|
||||
getCookies().values().stream().flatMap(Collection::stream)
|
||||
@@ -143,9 +142,13 @@ class JettyClientHttpRequest extends AbstractClientHttpRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HttpHeaders initReadOnlyHeaders() {
|
||||
return HttpHeaders.readOnlyHttpHeaders(new JettyHeadersAdapter(this.jettyRequest.getHeaders()));
|
||||
}
|
||||
|
||||
public ReactiveRequest toReactiveRequest() {
|
||||
return this.builder.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ class NettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends String, ? extends List<String>> map) {
|
||||
map.forEach(this.headers::add);
|
||||
map.forEach(this.headers::set);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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 reactor.netty.http.client.HttpClientRequest;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.NettyDataBufferFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ZeroCopyHttpOutputMessage;
|
||||
|
||||
@@ -133,4 +134,9 @@ class ReactorClientHttpRequest extends AbstractClientHttpRequest implements Zero
|
||||
.forEach(this.request::addCookie);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HttpHeaders initReadOnlyHeaders() {
|
||||
return HttpHeaders.readOnlyHttpHeaders(new NettyHeadersAdapter(this.request.requestHeaders()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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 @@ import org.springframework.lang.Nullable;
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
* @since 5.0
|
||||
*/
|
||||
public class ServerSentEventHttpMessageReader implements HttpMessageReader<Object> {
|
||||
@@ -140,22 +141,23 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
||||
private Object buildEvent(List<String> lines, ResolvableType valueType, boolean shouldWrap,
|
||||
Map<String, Object> hints) {
|
||||
|
||||
ServerSentEvent.Builder<Object> sseBuilder = shouldWrap ? ServerSentEvent.builder() : null;
|
||||
ServerSentEvent.Builder<Object> sseBuilder = (shouldWrap ? ServerSentEvent.builder() : null);
|
||||
StringBuilder data = null;
|
||||
StringBuilder comment = null;
|
||||
|
||||
for (String line : lines) {
|
||||
if (line.startsWith("data:")) {
|
||||
data = (data != null ? data : new StringBuilder());
|
||||
if (line.charAt(5) != ' ') {
|
||||
data.append(line, 5, line.length());
|
||||
int length = line.length();
|
||||
if (length > 5) {
|
||||
int index = (line.charAt(5) != ' ' ? 5 : 6);
|
||||
if (length > index) {
|
||||
data = (data != null ? data : new StringBuilder());
|
||||
data.append(line, index, line.length());
|
||||
data.append('\n');
|
||||
}
|
||||
}
|
||||
else {
|
||||
data.append(line, 6, line.length());
|
||||
}
|
||||
data.append('\n');
|
||||
}
|
||||
if (shouldWrap) {
|
||||
else if (shouldWrap) {
|
||||
if (line.startsWith("id:")) {
|
||||
sseBuilder.id(line.substring(3).trim());
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -169,6 +169,8 @@ public class BufferedImageHttpMessageConverter implements HttpMessageConverter<B
|
||||
|
||||
ImageInputStream imageInputStream = null;
|
||||
ImageReader imageReader = null;
|
||||
// We cannot use try-with-resources here for the ImageInputStream, since we have
|
||||
// custom handling of the close() method in a finally-block.
|
||||
try {
|
||||
imageInputStream = createImageInputStream(inputMessage.getBody());
|
||||
MediaType contentType = inputMessage.getHeaders().getContentType();
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,6 +131,8 @@ public class ResourceHttpMessageConverter extends AbstractHttpMessageConverter<R
|
||||
|
||||
protected void writeContent(Resource resource, HttpOutputMessage outputMessage)
|
||||
throws IOException, HttpMessageNotWritableException {
|
||||
// We cannot use try-with-resources here for the InputStream, since we have
|
||||
// custom handling of the close() method in a finally-block.
|
||||
try {
|
||||
InputStream in = resource.getInputStream();
|
||||
try {
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -155,6 +155,8 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
|
||||
responseHeaders.setContentLength(rangeLength);
|
||||
|
||||
InputStream in = region.getResource().getInputStream();
|
||||
// We cannot use try-with-resources here for the InputStream, since we have
|
||||
// custom handling of the close() method in a finally-block.
|
||||
try {
|
||||
StreamUtils.copyRange(in, outputMessage.getBody(), start, end);
|
||||
}
|
||||
|
||||
+11
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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,9 +218,18 @@ public abstract class AbstractServerHttpRequest implements ServerHttpRequest {
|
||||
*/
|
||||
String getLogPrefix() {
|
||||
if (this.logPrefix == null) {
|
||||
this.logPrefix = "[" + getId() + "] ";
|
||||
this.logPrefix = "[" + initLogPrefix() + "] ";
|
||||
}
|
||||
return this.logPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses can override this to provide the prefix to use for log messages.
|
||||
* <p>By default, this is {@link #getId()}.
|
||||
* @since 5.3.15
|
||||
*/
|
||||
protected String initLogPrefix() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ class NettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends String, ? extends List<String>> map) {
|
||||
map.forEach(this.headers::add);
|
||||
map.forEach(this.headers::set);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+17
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author 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 @@ class ReactorServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
private static URI initUri(HttpServerRequest request) throws URISyntaxException {
|
||||
Assert.notNull(request, "HttpServerRequest must not be null");
|
||||
return new URI(resolveBaseUrl(request).toString() + resolveRequestUri(request));
|
||||
return new URI(resolveBaseUrl(request) + resolveRequestUri(request));
|
||||
}
|
||||
|
||||
private static URI resolveBaseUrl(HttpServerRequest request) throws URISyntaxException {
|
||||
@@ -197,9 +197,6 @@ class ReactorServerHttpRequest extends AbstractServerHttpRequest {
|
||||
@Override
|
||||
@Nullable
|
||||
protected String initId() {
|
||||
if (reactorNettyRequestChannelOperationsIdPresent) {
|
||||
return (ChannelOperationsIdHelper.getId(this.request));
|
||||
}
|
||||
if (this.request instanceof Connection) {
|
||||
return ((Connection) this.request).channel().id().asShortText() +
|
||||
"-" + logPrefixIndex.incrementAndGet();
|
||||
@@ -207,6 +204,21 @@ class ReactorServerHttpRequest extends AbstractServerHttpRequest {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String initLogPrefix() {
|
||||
if (reactorNettyRequestChannelOperationsIdPresent) {
|
||||
String id = (ChannelOperationsIdHelper.getId(this.request));
|
||||
if (id != null) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
if (this.request instanceof Connection) {
|
||||
return ((Connection) this.request).channel().id().asShortText() +
|
||||
"-" + logPrefixIndex.incrementAndGet();
|
||||
}
|
||||
return getId();
|
||||
}
|
||||
|
||||
|
||||
private static class ChannelOperationsIdHelper {
|
||||
|
||||
|
||||
+11
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,6 +65,16 @@ public class ServerHttpResponseDecorator implements ServerHttpResponse {
|
||||
return getDelegate().getStatusCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setRawStatusCode(@Nullable Integer value) {
|
||||
return getDelegate().setRawStatusCode(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getRawStatusCode() {
|
||||
return getDelegate().getRawStatusCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return getDelegate().getHeaders();
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,11 +85,12 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the list of configured resolvers.
|
||||
* Clear the list of configured resolvers and the resolver cache.
|
||||
* @since 4.3
|
||||
*/
|
||||
public void clear() {
|
||||
this.argumentResolvers.clear();
|
||||
this.argumentResolverCache.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user