mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Compare commits
145 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 21c3b51e1f | |||
| aa14c24899 | |||
| 4c720eaa38 | |||
| 2d65bce18e | |||
| b8b85a6a59 | |||
| 3baacedfd9 | |||
| 4322ee1944 | |||
| 3faf445603 | |||
| 9e986c031b | |||
| f07e6a1b9d | |||
| 5cc09849ce | |||
| 92cd680a2c | |||
| caf88ff2cc | |||
| 813dbbce58 | |||
| c46cc666d6 | |||
| 674dc2f203 | |||
| 8adf28763b | |||
| b1a4d3033b | |||
| 8c14251a1a | |||
| 18ee308e4e | |||
| 6540e87ac0 | |||
| 6c17e9375b | |||
| 0a776a76d1 | |||
| 52b03e3326 | |||
| d55cbf8b4d | |||
| 04e6b233ca | |||
| db424d0bc5 | |||
| a087d13aea | |||
| c02ae7bcb8 | |||
| ca34d0cce8 | |||
| ab41db474e | |||
| cecc0849a8 | |||
| 2db1e6daad | |||
| 78dd219787 | |||
| bb45a7ae5e | |||
| c3e424c29a | |||
| c23f0cd070 | |||
| 63ffa710d6 | |||
| b6037d0d07 | |||
| 41ab268733 | |||
| 1dc128361f | |||
| 8f33450df2 | |||
| 55b3e064e9 | |||
| a3655c4858 | |||
| 3f66ef7aee | |||
| d8191b4808 | |||
| 417bce8be5 | |||
| 19283c9245 | |||
| d7ea4d230f | |||
| e7b499f7b6 | |||
| 77a6dce1b5 | |||
| d23afea168 | |||
| 0ec4be37d5 | |||
| 532b4b636d | |||
| d1a00b4301 | |||
| 87d3d1bbd1 | |||
| 1b3fd9edff | |||
| 5ea7592d70 | |||
| 9cf8cca96d | |||
| b2a17a8d86 | |||
| bec0bb0c53 | |||
| 434cbab6a7 | |||
| b2eaa7c1c3 | |||
| 2f60392fe3 | |||
| b6c2c11805 | |||
| 837301fdb3 | |||
| 164dcef6ae | |||
| 310bdbb1b2 | |||
| 88af24c1cb | |||
| 871e378ed0 | |||
| e5a5f8b20b | |||
| cc026fcb8a | |||
| 8d3e8ca3a2 | |||
| ae56f2ac09 | |||
| debf61b948 | |||
| b120e0b8f4 | |||
| c27ec00ae9 | |||
| 9a7fb7022d | |||
| bd72e4498b | |||
| e99b43b91e | |||
| 3c2dfebf4e | |||
| 25dca40413 | |||
| dd9b99e13d | |||
| cd078eaad8 | |||
| 5f47d3be22 | |||
| 35bec8102b | |||
| 4c153b80ee | |||
| 81a6ba42a3 | |||
| 8a7c4fc10d | |||
| 7da7a976e6 | |||
| b28f403bf8 | |||
| 6c71cf2f96 | |||
| 99970a5ddc | |||
| 462e19d417 | |||
| 9f7a94058a | |||
| caf6760ddd | |||
| 4a9c7e631c | |||
| af6fd6c303 | |||
| ac72277258 | |||
| 6770e4b3cc | |||
| 6177f00a63 | |||
| 9bdc545a95 | |||
| 44951873f9 | |||
| 77a562dfee | |||
| 7b80f4feeb | |||
| 98f69c51a1 | |||
| 3a35d79c72 | |||
| 451bcfc832 | |||
| d4cd9405dd | |||
| 31b651a114 | |||
| eaf9deedfd | |||
| ce6217be85 | |||
| e290ae285c | |||
| 8670b1c3f0 | |||
| 86ef0236e6 | |||
| ce94f69e52 | |||
| 01c8de0111 | |||
| bd1f5bd9fc | |||
| 4d115eef91 | |||
| 0f421f9f86 | |||
| 41fa199178 | |||
| 881fa889fc | |||
| e4b9b1fadb | |||
| 55e17ef306 | |||
| f2be4e9320 | |||
| 5b3f11c543 | |||
| 96ee8a3bc7 | |||
| 915f1027a5 | |||
| f1b35f1593 | |||
| c2f91765b4 | |||
| 403e04c0b4 | |||
| 6c68419073 | |||
| a747cc3e91 | |||
| 161c9dc3bd | |||
| 42edef0bcc | |||
| e94811f1b9 | |||
| d034a1f26d | |||
| 460947651a | |||
| af67764edb | |||
| ba08006d52 | |||
| 2594f4e058 | |||
| 9c0825629b | |||
| e0c0e7f878 | |||
| 0b1d14cdd9 | |||
| ca262eaa1c |
+52
-44
@@ -1,16 +1,16 @@
|
||||
plugins {
|
||||
id 'io.spring.dependency-management' version '1.0.9.RELEASE' apply false
|
||||
id 'io.spring.nohttp' version '0.0.5.RELEASE'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.5.21' apply false
|
||||
id 'org.jetbrains.dokka' version '0.10.1' apply false
|
||||
id 'org.asciidoctor.jvm.convert' version '3.1.0'
|
||||
id 'org.asciidoctor.jvm.pdf' version '3.1.0'
|
||||
id 'de.undercouch.download' version '4.1.1'
|
||||
id "io.freefair.aspectj" version '5.1.1' apply false
|
||||
id "com.github.ben-manes.versions" version '0.28.0'
|
||||
id "com.github.johnrengelman.shadow" version "6.1.0" apply false
|
||||
id "me.champeau.jmh" version "0.6.4" apply false
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "1.5.21" apply false
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE' apply false
|
||||
id 'io.spring.nohttp' version '0.0.10'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
|
||||
id 'org.jetbrains.dokka' version '1.5.0' apply false
|
||||
id 'org.asciidoctor.jvm.convert' version '3.3.2'
|
||||
id 'org.asciidoctor.jvm.pdf' version '3.3.2'
|
||||
id 'de.undercouch.download' version '4.1.2'
|
||||
id "io.freefair.aspectj" version '6.1.0' apply false
|
||||
id "com.github.ben-manes.versions" version '0.39.0'
|
||||
id "com.github.johnrengelman.shadow" version '7.0.0' apply false
|
||||
id "me.champeau.jmh" version "0.6.6" apply false
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "1.5.30" apply false
|
||||
id "org.unbroken-dome.xjc" version '2.0.0' apply false
|
||||
}
|
||||
|
||||
@@ -27,16 +27,16 @@ configure(allprojects) { project ->
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.4"
|
||||
mavenBom "io.netty:netty-bom:4.1.65.Final"
|
||||
mavenBom "io.projectreactor:reactor-bom:2020.0.9"
|
||||
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.5"
|
||||
mavenBom "io.netty:netty-bom:4.1.68.Final"
|
||||
mavenBom "io.projectreactor:reactor-bom:2020.0.11"
|
||||
mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR10"
|
||||
mavenBom "io.rsocket:rsocket-bom:1.1.1"
|
||||
mavenBom "org.eclipse.jetty:jetty-bom:9.4.43.v20210629"
|
||||
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.21"
|
||||
mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.5.1"
|
||||
mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.2.1"
|
||||
mavenBom "org.junit:junit-bom:5.7.2"
|
||||
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.30"
|
||||
mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.5.2"
|
||||
mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.2.2"
|
||||
mavenBom "org.junit:junit-bom:5.8.0"
|
||||
}
|
||||
dependencies {
|
||||
dependencySet(group: 'org.apache.logging.log4j', version: '2.14.1') {
|
||||
@@ -67,7 +67,8 @@ configure(allprojects) { project ->
|
||||
dependency "io.reactivex:rxjava:1.3.8"
|
||||
dependency "io.reactivex:rxjava-reactive-streams:1.2.1"
|
||||
dependency "io.reactivex.rxjava2:rxjava:2.2.21"
|
||||
dependency "io.reactivex.rxjava3:rxjava:3.0.13"
|
||||
dependency "io.reactivex.rxjava3:rxjava:3.1.1"
|
||||
dependency "io.smallrye.reactive:mutiny:1.0.0"
|
||||
dependency "io.projectreactor.tools:blockhound:1.0.4.RELEASE"
|
||||
|
||||
dependency "com.caucho:hessian:4.0.63"
|
||||
@@ -75,10 +76,10 @@ configure(allprojects) { project ->
|
||||
dependency("com.fasterxml.woodstox:woodstox-core:6.2.6") {
|
||||
exclude group: "stax", name: "stax-api"
|
||||
}
|
||||
dependency "com.google.code.gson:gson:2.8.7"
|
||||
dependency "com.google.code.gson:gson:2.8.8"
|
||||
dependency "com.google.protobuf:protobuf-java-util:3.17.3"
|
||||
dependency "com.googlecode.protobuf-java-format:protobuf-java-format:1.4"
|
||||
dependency("com.thoughtworks.xstream:xstream:1.4.17") {
|
||||
dependency("com.thoughtworks.xstream:xstream:1.4.18") {
|
||||
exclude group: "xpp3", name: "xpp3_min"
|
||||
exclude group: "xmlpull", name: "xmlpull"
|
||||
}
|
||||
@@ -127,18 +128,18 @@ configure(allprojects) { project ->
|
||||
dependency "org.webjars:webjars-locator-core:0.47"
|
||||
dependency "org.webjars:underscorejs:1.8.3"
|
||||
|
||||
dependencySet(group: 'org.apache.tomcat', version: '9.0.50') {
|
||||
dependencySet(group: 'org.apache.tomcat', version: '9.0.52') {
|
||||
entry 'tomcat-util'
|
||||
entry('tomcat-websocket') {
|
||||
exclude group: "org.apache.tomcat", name: "tomcat-websocket-api"
|
||||
exclude group: "org.apache.tomcat", name: "tomcat-servlet-api"
|
||||
}
|
||||
}
|
||||
dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.50') {
|
||||
dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.52') {
|
||||
entry 'tomcat-embed-core'
|
||||
entry 'tomcat-embed-websocket'
|
||||
}
|
||||
dependencySet(group: 'io.undertow', version: '2.2.8.Final') {
|
||||
dependencySet(group: 'io.undertow', version: '2.2.10.Final') {
|
||||
entry 'undertow-core'
|
||||
entry('undertow-websockets-jsr') {
|
||||
exclude group: "org.jboss.spec.javax.websocket", name: "jboss-websocket-api_1.1_spec"
|
||||
@@ -196,18 +197,18 @@ configure(allprojects) { project ->
|
||||
exclude group: "org.hamcrest", name: "hamcrest-core"
|
||||
}
|
||||
}
|
||||
dependencySet(group: 'org.mockito', version: '3.11.0') {
|
||||
dependencySet(group: 'org.mockito', version: '3.12.4') {
|
||||
entry('mockito-core') {
|
||||
exclude group: "org.hamcrest", name: "hamcrest-core"
|
||||
}
|
||||
entry 'mockito-junit-jupiter'
|
||||
}
|
||||
dependency "io.mockk:mockk:1.11.0"
|
||||
dependency "io.mockk:mockk:1.12.0"
|
||||
|
||||
dependency("net.sourceforge.htmlunit:htmlunit:2.51.0") {
|
||||
dependency("net.sourceforge.htmlunit:htmlunit:2.52.0") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.seleniumhq.selenium:htmlunit-driver:2.51.0") {
|
||||
dependency("org.seleniumhq.selenium:htmlunit-driver:2.52.0") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.seleniumhq.selenium:selenium-java:3.141.59") {
|
||||
@@ -215,7 +216,7 @@ configure(allprojects) { project ->
|
||||
exclude group: "io.netty", name: "netty"
|
||||
}
|
||||
dependency "org.skyscreamer:jsonassert:1.5.0"
|
||||
dependency "com.jayway.jsonpath:json-path:2.5.0"
|
||||
dependency "com.jayway.jsonpath:json-path:2.6.0"
|
||||
dependency "org.bouncycastle:bcpkix-jdk15on:1.66"
|
||||
|
||||
dependencySet(group: 'org.apache.tiles', version: '3.0.8') {
|
||||
@@ -312,6 +313,8 @@ configure([rootProject] + javaProjects) { project ->
|
||||
|
||||
pluginManager.withPlugin("kotlin") {
|
||||
apply plugin: "org.jetbrains.dokka"
|
||||
apply from: "${rootDir}/gradle/docs-dokka.gradle"
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
languageVersion = "1.3"
|
||||
@@ -336,23 +339,25 @@ configure([rootProject] + javaProjects) { project ->
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "8.44"
|
||||
toolVersion = "8.45.1"
|
||||
configDirectory.set(rootProject.file("src/checkstyle"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile("org.junit.jupiter:junit-jupiter-api")
|
||||
testCompile("org.junit.jupiter:junit-jupiter-params")
|
||||
testCompile("org.mockito:mockito-core")
|
||||
testCompile("org.mockito:mockito-junit-jupiter")
|
||||
testCompile("io.mockk:mockk")
|
||||
testCompile("org.assertj:assertj-core")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-params")
|
||||
testImplementation("org.junit.platform:junit-platform-suite-api")
|
||||
testImplementation("org.mockito:mockito-core")
|
||||
testImplementation("org.mockito:mockito-junit-jupiter")
|
||||
testImplementation("io.mockk:mockk")
|
||||
testImplementation("org.assertj:assertj-core")
|
||||
// Pull in the latest JUnit 5 Launcher API to ensure proper support in IDEs.
|
||||
testRuntime("org.junit.platform:junit-platform-launcher")
|
||||
testRuntime("org.junit.jupiter:junit-jupiter-engine")
|
||||
testRuntime("org.apache.logging.log4j:log4j-core")
|
||||
testRuntime("org.apache.logging.log4j:log4j-slf4j-impl")
|
||||
testRuntime("org.apache.logging.log4j:log4j-jul")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-suite-engine")
|
||||
testRuntimeOnly("org.apache.logging.log4j:log4j-core")
|
||||
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
|
||||
testRuntimeOnly("org.apache.logging.log4j:log4j-jul")
|
||||
// JSR-305 only used for non-required meta-annotations
|
||||
compileOnly("com.google.code.findbugs:jsr305")
|
||||
testCompileOnly("com.google.code.findbugs:jsr305")
|
||||
@@ -363,7 +368,7 @@ configure([rootProject] + javaProjects) { project ->
|
||||
"https://docs.oracle.com/javase/8/docs/api/",
|
||||
"https://docs.oracle.com/javaee/7/api/",
|
||||
"https://docs.oracle.com/cd/E13222_01/wls/docs90/javadocs/", // CommonJ
|
||||
"https://www.ibm.com/support/knowledgecenter/SS7JFU_8.5.5/com.ibm.websphere.javadoc.doc/web/apidocs/",
|
||||
"https://www.ibm.com/docs/api/v1/content/SSEQTP_8.5.5/com.ibm.websphere.javadoc.doc/web/apidocs/",
|
||||
"https://glassfish.java.net/nonav/docs/v3/api/",
|
||||
"https://docs.jboss.org/jbossas/javadoc/4.0.5/connector/",
|
||||
"https://docs.jboss.org/jbossas/javadoc/7.1.2.Final/",
|
||||
@@ -378,7 +383,10 @@ configure([rootProject] + javaProjects) { project ->
|
||||
"https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/",
|
||||
"https://projectreactor.io/docs/test/release/api/",
|
||||
"https://junit.org/junit4/javadoc/4.13.2/",
|
||||
"https://junit.org/junit5/docs/5.7.2/api/"
|
||||
"https://junit.org/junit5/docs/5.8.0/api/",
|
||||
"https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/",
|
||||
"https://javadoc.io/static/io.rsocket/rsocket-core/1.1.1/",
|
||||
"https://r2dbc.io/spec/0.8.5.RELEASE/api/"
|
||||
] as String[]
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -32,6 +32,7 @@ import org.gradle.api.tasks.compile.JavaCompile;
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Sam Brannen
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class CompilerConventionsPlugin implements Plugin<Project> {
|
||||
|
||||
@@ -43,7 +44,8 @@ public class CompilerConventionsPlugin implements Plugin<Project> {
|
||||
List<String> commonCompilerArgs = Arrays.asList(
|
||||
"-Xlint:serial", "-Xlint:cast", "-Xlint:classfile", "-Xlint:dep-ann",
|
||||
"-Xlint:divzero", "-Xlint:empty", "-Xlint:finally", "-Xlint:overrides",
|
||||
"-Xlint:path", "-Xlint:processing", "-Xlint:static", "-Xlint:try", "-Xlint:-options"
|
||||
"-Xlint:path", "-Xlint:processing", "-Xlint:static", "-Xlint:try", "-Xlint:-options",
|
||||
"-parameters"
|
||||
);
|
||||
COMPILER_ARGS = new ArrayList<>();
|
||||
COMPILER_ARGS.addAll(commonCompilerArgs);
|
||||
@@ -54,7 +56,7 @@ public class CompilerConventionsPlugin implements Plugin<Project> {
|
||||
TEST_COMPILER_ARGS = new ArrayList<>();
|
||||
TEST_COMPILER_ARGS.addAll(commonCompilerArgs);
|
||||
TEST_COMPILER_ARGS.addAll(Arrays.asList("-Xlint:-varargs", "-Xlint:-fallthrough", "-Xlint:-rawtypes",
|
||||
"-Xlint:-deprecation", "-Xlint:-unchecked", "-parameters"));
|
||||
"-Xlint:-deprecation", "-Xlint:-unchecked"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
-14
@@ -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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.build.optional;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.attributes.Usage;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.plugins.JavaPluginConvention;
|
||||
import org.gradle.api.tasks.SourceSetContainer;
|
||||
@@ -28,7 +29,7 @@ import org.gradle.plugins.ide.eclipse.model.EclipseModel;
|
||||
/**
|
||||
* A {@code Plugin} that adds support for Maven-style optional dependencies. Creates a new
|
||||
* {@code optional} configuration. The {@code optional} configuration is part of the
|
||||
* project's compile and runtime classpath's but does not affect the classpath of
|
||||
* project's compile and runtime classpaths but does not affect the classpath of
|
||||
* dependent projects.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
@@ -43,22 +44,16 @@ public class OptionalDependenciesPlugin implements Plugin<Project> {
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
Configuration optional = project.getConfigurations().create("optional");
|
||||
optional.setCanBeConsumed(false);
|
||||
optional.setCanBeResolved(false);
|
||||
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
|
||||
SourceSetContainer sourceSets = project.getConvention()
|
||||
.getPlugin(JavaPluginConvention.class).getSourceSets();
|
||||
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class)
|
||||
.getSourceSets();
|
||||
sourceSets.all((sourceSet) -> {
|
||||
sourceSet.setCompileClasspath(
|
||||
sourceSet.getCompileClasspath().plus(optional));
|
||||
sourceSet.setRuntimeClasspath(
|
||||
sourceSet.getRuntimeClasspath().plus(optional));
|
||||
project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName()).extendsFrom(optional);
|
||||
project.getConfigurations().getByName(sourceSet.getRuntimeClasspathConfigurationName()).extendsFrom(optional);
|
||||
});
|
||||
});
|
||||
project.getPlugins().withType(EclipsePlugin.class, (eclipePlugin) -> {
|
||||
project.getExtensions().getByType(EclipseModel.class)
|
||||
.classpath((classpath) -> {
|
||||
classpath.getPlusConfigurations().add(optional);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@ changelog:
|
||||
- title: ":star: New Features"
|
||||
labels:
|
||||
- "type: enhancement"
|
||||
- title: ":beetle: Bug Fixes"
|
||||
- title: ":lady_beetle: Bug Fixes"
|
||||
labels:
|
||||
- "type: bug"
|
||||
- "type: regression"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM ubuntu:focal-20210119
|
||||
FROM ubuntu:focal-20210827
|
||||
|
||||
ADD setup.sh /setup.sh
|
||||
ADD get-jdk-url.sh /get-jdk-url.sh
|
||||
@@ -6,6 +6,6 @@ RUN ./setup.sh java8
|
||||
|
||||
ENV JAVA_HOME /opt/openjdk/java8
|
||||
ENV JDK11 /opt/openjdk/java11
|
||||
ENV JDK15 /opt/openjdk/java15
|
||||
ENV JDK16 /opt/openjdk/java16
|
||||
|
||||
ENV PATH $JAVA_HOME/bin:$PATH
|
||||
|
||||
@@ -3,13 +3,13 @@ set -e
|
||||
|
||||
case "$1" in
|
||||
java8)
|
||||
echo "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u282-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u282b08.tar.gz"
|
||||
echo "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz"
|
||||
;;
|
||||
java11)
|
||||
echo "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz"
|
||||
echo "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz"
|
||||
;;
|
||||
java15)
|
||||
echo "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.2%2B7/OpenJDK15U-jdk_x64_linux_hotspot_15.0.2_7.tar.gz"
|
||||
java16)
|
||||
echo "https://github.com/adoptium/temurin16-binaries/releases/download/jdk-16.0.2%2B7/OpenJDK16U-jdk_x64_linux_hotspot_16.0.2_7.tar.gz"
|
||||
;;
|
||||
*)
|
||||
echo $"Unknown java version"
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ curl --output /opt/concourse-release-scripts.jar https://repo.spring.io/release/
|
||||
|
||||
mkdir -p /opt/openjdk
|
||||
pushd /opt/openjdk > /dev/null
|
||||
for jdk in java8 java11 java15
|
||||
for jdk in java8 java11 java16
|
||||
do
|
||||
JDK_URL=$( /get-jdk-url.sh $jdk )
|
||||
mkdir $jdk
|
||||
|
||||
+10
-10
@@ -2,7 +2,7 @@ anchors:
|
||||
git-repo-resource-source: &git-repo-resource-source
|
||||
uri: ((github-repo))
|
||||
username: ((github-username))
|
||||
password: ((github-password))
|
||||
password: ((github-ci-release-token))
|
||||
branch: ((branch))
|
||||
gradle-enterprise-task-params: &gradle-enterprise-task-params
|
||||
GRADLE_ENTERPRISE_ACCESS_KEY: ((gradle_enterprise_secret_access_key))
|
||||
@@ -45,7 +45,7 @@ resource_types:
|
||||
type: registry-image
|
||||
source:
|
||||
repository: springio/artifactory-resource
|
||||
tag: 0.0.13
|
||||
tag: 0.0.17
|
||||
- name: github-status-resource
|
||||
type: registry-image
|
||||
source:
|
||||
@@ -119,14 +119,14 @@ resources:
|
||||
access_token: ((github-ci-status-token))
|
||||
branch: ((branch))
|
||||
context: jdk11-build
|
||||
- name: repo-status-jdk15-build
|
||||
- name: repo-status-jdk16-build
|
||||
type: github-status-resource
|
||||
icon: eye-check-outline
|
||||
source:
|
||||
repository: ((github-repo-name))
|
||||
access_token: ((github-ci-status-token))
|
||||
branch: ((branch))
|
||||
context: jdk15-build
|
||||
context: jdk16-build
|
||||
- name: slack-alert
|
||||
type: slack-notification
|
||||
icon: slack
|
||||
@@ -244,7 +244,7 @@ jobs:
|
||||
<<: *slack-fail-params
|
||||
- put: repo-status-jdk11-build
|
||||
params: { state: "success", commit: "git-repo" }
|
||||
- name: jdk15-build
|
||||
- name: jdk16-build
|
||||
serial: true
|
||||
public: true
|
||||
plan:
|
||||
@@ -252,7 +252,7 @@ jobs:
|
||||
- get: git-repo
|
||||
- get: every-morning
|
||||
trigger: true
|
||||
- put: repo-status-jdk15-build
|
||||
- put: repo-status-jdk16-build
|
||||
params: { state: "pending", commit: "git-repo" }
|
||||
- do:
|
||||
- task: check-project
|
||||
@@ -265,12 +265,12 @@ jobs:
|
||||
<<: *build-project-task-params
|
||||
on_failure:
|
||||
do:
|
||||
- put: repo-status-jdk15-build
|
||||
- put: repo-status-jdk16-build
|
||||
params: { state: "failure", commit: "git-repo" }
|
||||
- put: slack-alert
|
||||
params:
|
||||
<<: *slack-fail-params
|
||||
- put: repo-status-jdk15-build
|
||||
- put: repo-status-jdk16-build
|
||||
params: { state: "success", commit: "git-repo" }
|
||||
- name: build-pull-requests
|
||||
serial: true
|
||||
@@ -292,7 +292,7 @@ jobs:
|
||||
privileged: true
|
||||
timeout: ((task-timeout))
|
||||
params:
|
||||
<<: *build-project-task-params
|
||||
BRANCH: ((branch))
|
||||
on_success:
|
||||
put: git-pull-request
|
||||
params:
|
||||
@@ -453,7 +453,7 @@ jobs:
|
||||
|
||||
groups:
|
||||
- name: "builds"
|
||||
jobs: ["build", "jdk11-build", "jdk15-build"]
|
||||
jobs: ["build", "jdk11-build", "jdk16-build"]
|
||||
- name: "releases"
|
||||
jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "create-github-release"]
|
||||
- name: "ci-images"
|
||||
|
||||
@@ -29,8 +29,8 @@ fi
|
||||
echo "Staging $stageVersion (next version will be $nextVersion)"
|
||||
sed -i "s/version=$snapshotVersion/version=$stageVersion/" gradle.properties
|
||||
|
||||
git config user.name "Spring Buildmaster" > /dev/null
|
||||
git config user.email "buildmaster@springframework.org" > /dev/null
|
||||
git config user.name "Spring Builds" > /dev/null
|
||||
git config user.email "spring-builds@users.noreply.github.com" > /dev/null
|
||||
git add gradle.properties > /dev/null
|
||||
git commit -m"Release v$stageVersion" > /dev/null
|
||||
git tag -a "v$stageVersion" -m"Release v$stageVersion" > /dev/null
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
version=5.3.9
|
||||
version=5.3.10
|
||||
org.gradle.jvmargs=-Xmx1536M
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
tasks.findByName("dokkaHtmlPartial")?.configure {
|
||||
outputDirectory.set(new File(buildDir, "docs/kdoc"))
|
||||
dokkaSourceSets {
|
||||
configureEach {
|
||||
sourceRoots.setFrom(file("src/main/kotlin"))
|
||||
classpath.from(sourceSets["main"].runtimeClasspath)
|
||||
externalDocumentationLink {
|
||||
url.set(new URL("https://docs.spring.io/spring-framework/docs/current/javadoc-api/"))
|
||||
}
|
||||
externalDocumentationLink {
|
||||
url.set(new URL("https://projectreactor.io/docs/core/release/api/"))
|
||||
}
|
||||
externalDocumentationLink {
|
||||
url.set(new URL("https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/"))
|
||||
}
|
||||
externalDocumentationLink {
|
||||
url.set(new URL("https://kotlin.github.io/kotlinx.coroutines/"))
|
||||
}
|
||||
externalDocumentationLink {
|
||||
url.set(new URL("https://hamcrest.org/JavaHamcrest/javadoc/2.1/"))
|
||||
}
|
||||
externalDocumentationLink {
|
||||
url.set(new URL("https://javadoc.io/doc/javax.servlet/javax.servlet-api/latest/"))
|
||||
}
|
||||
externalDocumentationLink {
|
||||
url.set(new URL("https://javadoc.io/static/io.rsocket/rsocket-core/1.1.1/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-58
@@ -61,57 +61,13 @@ task api(type: Javadoc) {
|
||||
/**
|
||||
* Produce KDoc for all Spring Framework modules in "build/docs/kdoc"
|
||||
*/
|
||||
dokka {
|
||||
dependsOn {
|
||||
tasks.getByName("api")
|
||||
}
|
||||
|
||||
doFirst {
|
||||
configuration {
|
||||
classpath = moduleProjects.collect { project -> project.jar.outputs.files.getFiles() }.flatten()
|
||||
classpath += files(moduleProjects.collect { it.sourceSets.main.compileClasspath })
|
||||
|
||||
moduleProjects.findAll {
|
||||
it.pluginManager.hasPlugin("kotlin")
|
||||
}.each { project ->
|
||||
def kotlinDirs = project.sourceSets.main.kotlin.srcDirs.collect()
|
||||
kotlinDirs -= project.sourceSets.main.java.srcDirs
|
||||
kotlinDirs.each { dir ->
|
||||
if (dir.exists()) {
|
||||
sourceRoot {
|
||||
path = dir.path
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outputFormat = "html"
|
||||
outputDirectory = "$buildDir/docs/kdoc"
|
||||
|
||||
configuration {
|
||||
moduleName = "spring-framework"
|
||||
|
||||
externalDocumentationLink {
|
||||
url = new URL("https://docs.spring.io/spring-framework/docs/$version/javadoc-api/")
|
||||
packageListUrl = new File(buildDir, "docs/javadoc/package-list").toURI().toURL()
|
||||
}
|
||||
externalDocumentationLink {
|
||||
url = new URL("https://projectreactor.io/docs/core/release/api/")
|
||||
}
|
||||
externalDocumentationLink {
|
||||
url = new URL("https://www.reactive-streams.org/reactive-streams-1.0.1-javadoc/")
|
||||
}
|
||||
/*
|
||||
This link causes errors, removing to fix the build.
|
||||
externalDocumentationLink {
|
||||
url = new URL("https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/")
|
||||
}
|
||||
*/
|
||||
externalDocumentationLink {
|
||||
url = new URL("https://r2dbc.io/spec/0.8.3.RELEASE/api/")
|
||||
pluginManager.withPlugin("kotlin") {
|
||||
tasks.dokkaHtmlMultiModule.configure {
|
||||
dependsOn {
|
||||
tasks.getByName("api")
|
||||
}
|
||||
moduleName.set("spring-framework")
|
||||
outputDirectory.set(project.file("$buildDir/docs/kdoc"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +95,7 @@ asciidoctorj {
|
||||
icons: 'font',
|
||||
idprefix: '',
|
||||
idseparator: '-',
|
||||
docinfo: 'shared',
|
||||
docinfo: 'shared,private-header', // https://docs.asciidoctor.org/asciidoctor/latest/docinfo/
|
||||
revnumber: project.version,
|
||||
sectanchors: '',
|
||||
sectnums: '',
|
||||
@@ -163,9 +119,6 @@ asciidoctorj {
|
||||
asciidoctor {
|
||||
baseDirFollowsSourceDir()
|
||||
configurations 'asciidoctorExt'
|
||||
attributes([
|
||||
noheader: '' // custom header in docinfo-header.html
|
||||
])
|
||||
sources {
|
||||
include '*.adoc'
|
||||
}
|
||||
@@ -196,7 +149,7 @@ asciidoctorPdf {
|
||||
/**
|
||||
* Zip all docs (API and reference) into a single archive
|
||||
*/
|
||||
task docsZip(type: Zip, dependsOn: ['api', 'asciidoctor', 'asciidoctorPdf', 'dokka']) {
|
||||
task docsZip(type: Zip, dependsOn: ['api', 'asciidoctor', 'asciidoctorPdf', 'dokkaHtmlMultiModule']) {
|
||||
group = "Distribution"
|
||||
description = "Builds -${archiveClassifier} archive containing api and reference " +
|
||||
"for deployment at https://docs.spring.io/spring-framework/docs."
|
||||
@@ -215,7 +168,7 @@ task docsZip(type: Zip, dependsOn: ['api', 'asciidoctor', 'asciidoctorPdf', 'dok
|
||||
from ("$asciidoctorPdf.outputDir") {
|
||||
into "reference/pdf"
|
||||
}
|
||||
from (dokka) {
|
||||
from (dokkaHtmlMultiModule.outputDirectory) {
|
||||
into "kdoc-api"
|
||||
}
|
||||
}
|
||||
@@ -272,11 +225,11 @@ task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) {
|
||||
expand(copyright: new Date().format("yyyy"), version: project.version)
|
||||
}
|
||||
|
||||
from(zipTree(docsZip.archivePath)) {
|
||||
from(zipTree(docsZip.archiveFile)) {
|
||||
into "${baseDir}/docs"
|
||||
}
|
||||
|
||||
from(zipTree(schemaZip.archivePath)) {
|
||||
from(zipTree(schemaZip.archiveFile)) {
|
||||
into "${baseDir}/schema"
|
||||
}
|
||||
|
||||
|
||||
+42
-42
@@ -1,7 +1,7 @@
|
||||
import org.gradle.plugins.ide.eclipse.model.ProjectDependency
|
||||
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
||||
|
||||
apply plugin: "eclipse"
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
eclipse.jdt {
|
||||
sourceCompatibility = 1.8
|
||||
@@ -18,40 +18,45 @@ eclipse.classpath.file.whenMerged { classpath ->
|
||||
if (matcher) {
|
||||
def projectName = matcher[0][1]
|
||||
def path = "/${projectName}"
|
||||
if(!classpath.entries.find { e -> e instanceof ProjectDependency && e.path == path }) {
|
||||
def dependency = new ProjectDependency(path)
|
||||
dependency.exported = true
|
||||
classpath.entries.add(dependency)
|
||||
if (!classpath.entries.find { e -> e instanceof ProjectDependency && e.path == path }) {
|
||||
def recursiveDependency = entry.path.matches('.+/' + projectName + '/build/([^/]+/)+(?:main|test)')
|
||||
// Avoid recursive dependency on current project.
|
||||
if (!recursiveDependency) {
|
||||
classpath.entries.add(new ProjectDependency(path))
|
||||
}
|
||||
}
|
||||
classpath.entries.remove(entry)
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any remaining direct depencencies on JARs in the build/libs folder
|
||||
// except Spring's spring-cglib-repack and spring-objenesis-repack JARs.
|
||||
classpath.entries.removeAll { entry -> (entry.path =~ /(?!.*?repack.*\.jar).*?\/([^\/]+)\/build\/libs\/[^\/]+\.jar/) }
|
||||
}
|
||||
|
||||
// Use separate main/test outputs (prevents WTP from packaging test classes)
|
||||
eclipse.classpath.defaultOutputDir = file(project.name+"/bin/eclipse")
|
||||
eclipse.classpath.defaultOutputDir = file(project.name + '/bin/eclipse')
|
||||
eclipse.classpath.file.beforeMerged { classpath ->
|
||||
classpath.entries.findAll{ it instanceof SourceFolder }.each {
|
||||
if (it.output.startsWith("bin/")) {
|
||||
if (it.output.startsWith('bin/')) {
|
||||
it.output = null
|
||||
}
|
||||
}
|
||||
}
|
||||
eclipse.classpath.file.whenMerged { classpath ->
|
||||
classpath.entries.findAll{ it instanceof SourceFolder }.each {
|
||||
it.output = "bin/" + it.path.split("/")[1]
|
||||
eclipse.classpath.file.whenMerged {
|
||||
entries.findAll{ it instanceof SourceFolder }.each {
|
||||
it.output = 'bin/' + it.path.split('/')[1]
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure project dependencies come after 3rd-party libs (SPR-11836)
|
||||
// https://jira.spring.io/browse/SPR-11836
|
||||
eclipse.classpath.file.whenMerged { classpath ->
|
||||
classpath.entries.findAll { it instanceof ProjectDependency }.each {
|
||||
eclipse.classpath.file.whenMerged {
|
||||
entries.findAll { it instanceof ProjectDependency }.each {
|
||||
// delete from original position
|
||||
classpath.entries.remove(it)
|
||||
entries.remove(it)
|
||||
// append to end of classpath
|
||||
classpath.entries.add(it)
|
||||
entries.add(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,46 +70,41 @@ eclipse.classpath.file.whenMerged {
|
||||
}
|
||||
|
||||
// Allow projects to be used as WTP modules
|
||||
eclipse.project.natures "org.eclipse.wst.common.project.facet.core.nature"
|
||||
eclipse.project.natures 'org.eclipse.wst.common.project.facet.core.nature'
|
||||
|
||||
// Include project specific settings
|
||||
task eclipseSettings(type: Copy) {
|
||||
from rootProject.files(
|
||||
"src/eclipse/org.eclipse.jdt.ui.prefs",
|
||||
"src/eclipse/org.eclipse.wst.common.project.facet.core.xml")
|
||||
'src/eclipse/org.eclipse.jdt.ui.prefs',
|
||||
'src/eclipse/org.eclipse.wst.common.project.facet.core.xml')
|
||||
into project.file('.settings/')
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
task eclipseWstComponent(type: Copy) {
|
||||
from rootProject.files(
|
||||
"src/eclipse/org.eclipse.wst.common.component")
|
||||
task eclipseJdtSettings(type: Copy) {
|
||||
from rootProject.file('src/eclipse/org.eclipse.jdt.core.prefs')
|
||||
into project.file('.settings/')
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
task eclipseBuildship {
|
||||
dependsOn eclipseSettings, eclipseJdtSettings
|
||||
}
|
||||
|
||||
task eclipseWstComponentSettings(type: Copy) {
|
||||
from rootProject.files('src/eclipse/org.eclipse.wst.common.component')
|
||||
into project.file('.settings/')
|
||||
expand(deployname: project.name)
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
task eclipseJdtPrepare(type: Copy) {
|
||||
from rootProject.file("src/eclipse/org.eclipse.jdt.core.prefs")
|
||||
into project.file(".settings/")
|
||||
outputs.upToDateWhen { false }
|
||||
task cleanEclipseSettings(type: Delete) {
|
||||
delete project.file('.settings/org.eclipse.jdt.core.prefs')
|
||||
delete project.file('.settings/org.eclipse.jdt.ui.prefs')
|
||||
delete project.file('.settings/org.eclipse.wst.common.component')
|
||||
delete project.file('.settings/org.eclipse.wst.common.project.facet.core.xml')
|
||||
}
|
||||
|
||||
task cleanEclipseJdtUi(type: Delete) {
|
||||
delete project.file(".settings/org.eclipse.jdt.core.prefs")
|
||||
delete project.file(".settings/org.eclipse.jdt.ui.prefs")
|
||||
delete project.file(".settings/org.eclipse.wst.common.component")
|
||||
delete project.file(".settings/org.eclipse.wst.common.project.facet.core.xml")
|
||||
}
|
||||
|
||||
task eclipseBuildship(type: Copy) {
|
||||
from rootProject.files(
|
||||
"src/eclipse/org.eclipse.jdt.ui.prefs",
|
||||
"src/eclipse/org.eclipse.jdt.core.prefs")
|
||||
into project.file('.settings/')
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
tasks["eclipseJdt"].dependsOn(eclipseJdtPrepare)
|
||||
tasks["cleanEclipse"].dependsOn(cleanEclipseJdtUi)
|
||||
tasks["eclipse"].dependsOn(eclipseSettings, eclipseWstComponent)
|
||||
tasks['eclipse'].dependsOn(eclipseSettings, eclipseJdtSettings, eclipseWstComponentSettings)
|
||||
tasks['eclipseJdt'].dependsOn(eclipseJdtSettings)
|
||||
tasks['cleanEclipse'].dependsOn(cleanEclipseSettings)
|
||||
|
||||
@@ -8,15 +8,19 @@ apply plugin: 'me.champeau.jmh'
|
||||
apply from: "$rootDir/gradle/publications.gradle"
|
||||
|
||||
dependencies {
|
||||
jmh 'org.openjdk.jmh:jmh-core:1.28'
|
||||
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.28'
|
||||
jmh 'net.sf.jopt-simple:jopt-simple:4.6'
|
||||
jmh 'org.openjdk.jmh:jmh-core:1.32'
|
||||
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.32'
|
||||
jmh 'net.sf.jopt-simple:jopt-simple'
|
||||
}
|
||||
|
||||
jmh {
|
||||
duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
||||
tasks.findByName("processJmhResources").configure {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
||||
jmhJar {
|
||||
// Uncomment the following for Shadow's Transformer support.
|
||||
// mergeServiceFiles()
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,67 +17,101 @@
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@@ -106,80 +140,95 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
description = "Spring Integration Tests"
|
||||
|
||||
dependencies {
|
||||
testCompile(project(":spring-aop"))
|
||||
testCompile(project(":spring-beans"))
|
||||
testCompile(project(":spring-context"))
|
||||
testCompile(project(":spring-core"))
|
||||
testCompile(testFixtures(project(":spring-aop")))
|
||||
testCompile(testFixtures(project(":spring-beans")))
|
||||
testCompile(testFixtures(project(":spring-core")))
|
||||
testCompile(testFixtures(project(":spring-tx")))
|
||||
testCompile(project(":spring-expression"))
|
||||
testCompile(project(":spring-jdbc"))
|
||||
testCompile(project(":spring-orm"))
|
||||
testCompile(project(":spring-test"))
|
||||
testCompile(project(":spring-tx"))
|
||||
testCompile(project(":spring-web"))
|
||||
testCompile("javax.inject:javax.inject")
|
||||
testCompile("javax.resource:javax.resource-api")
|
||||
testCompile("javax.servlet:javax.servlet-api")
|
||||
testCompile("org.aspectj:aspectjweaver")
|
||||
testCompile("org.hsqldb:hsqldb")
|
||||
testCompile("org.hibernate:hibernate-core")
|
||||
testImplementation(project(":spring-aop"))
|
||||
testImplementation(project(":spring-beans"))
|
||||
testImplementation(project(":spring-context"))
|
||||
testImplementation(project(":spring-core"))
|
||||
testImplementation(testFixtures(project(":spring-aop")))
|
||||
testImplementation(testFixtures(project(":spring-beans")))
|
||||
testImplementation(testFixtures(project(":spring-core")))
|
||||
testImplementation(testFixtures(project(":spring-tx")))
|
||||
testImplementation(project(":spring-expression"))
|
||||
testImplementation(project(":spring-jdbc"))
|
||||
testImplementation(project(":spring-orm"))
|
||||
testImplementation(project(":spring-test"))
|
||||
testImplementation(project(":spring-tx"))
|
||||
testImplementation(project(":spring-web"))
|
||||
testImplementation("javax.inject:javax.inject")
|
||||
testImplementation("javax.resource:javax.resource-api")
|
||||
testImplementation("javax.servlet:javax.servlet-api")
|
||||
testImplementation("org.aspectj:aspectjweaver")
|
||||
testImplementation("org.hsqldb:hsqldb")
|
||||
testImplementation("org.hibernate:hibernate-core")
|
||||
}
|
||||
|
||||
normalization {
|
||||
|
||||
+2
-4
@@ -1,7 +1,7 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven { url 'https://repo.spring.io/plugins-release' }
|
||||
maven { url "https://repo.spring.io/plugins-release" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ include "spring-context"
|
||||
include "spring-context-indexer"
|
||||
include "spring-context-support"
|
||||
include "spring-core"
|
||||
include "kotlin-coroutines"
|
||||
project(':kotlin-coroutines').projectDir = file('spring-core/kotlin-coroutines')
|
||||
include "spring-expression"
|
||||
include "spring-instrument"
|
||||
include "spring-jcl"
|
||||
@@ -51,7 +49,7 @@ settings.gradle.projectsLoaded {
|
||||
buildScanPublished { scan ->
|
||||
if (buildDir.exists()) {
|
||||
new File(buildDir, "build-scan-uri.txt").text = "${scan.buildScanUri}\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
description = "Spring AOP"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
api(project(":spring-beans"))
|
||||
api(project(":spring-core"))
|
||||
optional("org.aspectj:aspectjweaver")
|
||||
optional("org.apache.commons:commons-pool2")
|
||||
optional("com.jamonapi:jamon")
|
||||
testCompile(testFixtures(project(":spring-beans")))
|
||||
testCompile(testFixtures(project(":spring-core")))
|
||||
testImplementation(testFixtures(project(":spring-beans")))
|
||||
testImplementation(testFixtures(project(":spring-core")))
|
||||
testFixturesImplementation(testFixtures(project(":spring-beans")))
|
||||
testFixturesImplementation(testFixtures(project(":spring-core")))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -26,7 +26,7 @@ import javax.annotation.Nullable;
|
||||
* terminology).
|
||||
*
|
||||
* <p>A runtime joinpoint is an <i>event</i> that occurs on a static
|
||||
* joinpoint (i.e. a location in a the program). For instance, an
|
||||
* joinpoint (i.e. a location in a program). For instance, an
|
||||
* invocation is the runtime joinpoint on a method (static joinpoint).
|
||||
* The static part of a given joinpoint can be generically retrieved
|
||||
* using the {@link #getStaticPart()} method.
|
||||
|
||||
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 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,10 +103,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||
@Override
|
||||
public void validate(Class<?> aspectClass) throws AopConfigException {
|
||||
// If the parent has the annotation and isn't abstract it's an error
|
||||
if (aspectClass.getSuperclass().getAnnotation(Aspect.class) != null &&
|
||||
!Modifier.isAbstract(aspectClass.getSuperclass().getModifiers())) {
|
||||
Class<?> superclass = aspectClass.getSuperclass();
|
||||
if (superclass.getAnnotation(Aspect.class) != null &&
|
||||
!Modifier.isAbstract(superclass.getModifiers())) {
|
||||
throw new AopConfigException("[" + aspectClass.getName() + "] cannot extend concrete aspect [" +
|
||||
aspectClass.getSuperclass().getName() + "]");
|
||||
superclass.getName() + "]");
|
||||
}
|
||||
|
||||
AjType<?> ajType = AjTypeSystem.getAjType(aspectClass);
|
||||
|
||||
@@ -521,8 +521,8 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||
copy.copyFrom(this);
|
||||
copy.targetSource = EmptyTargetSource.forClass(getTargetClass(), getTargetSource().isStatic());
|
||||
copy.advisorChainFactory = this.advisorChainFactory;
|
||||
copy.interfaces = this.interfaces;
|
||||
copy.advisors = this.advisors;
|
||||
copy.interfaces = new ArrayList<>(this.interfaces);
|
||||
copy.advisors = new ArrayList<>(this.advisors);
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
+3
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -125,12 +125,8 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
|
||||
*/
|
||||
protected DefaultListableBeanFactory getInternalBeanFactoryForBean(String beanName) {
|
||||
synchronized (this.internalBeanFactories) {
|
||||
DefaultListableBeanFactory internalBeanFactory = this.internalBeanFactories.get(beanName);
|
||||
if (internalBeanFactory == null) {
|
||||
internalBeanFactory = buildInternalBeanFactory(this.beanFactory);
|
||||
this.internalBeanFactories.put(beanName, internalBeanFactory);
|
||||
}
|
||||
return internalBeanFactory;
|
||||
return this.internalBeanFactories.computeIfAbsent(beanName,
|
||||
name -> buildInternalBeanFactory(this.beanFactory));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ sourceSets.test.java.srcDirs = files()
|
||||
aspectj.version = dependencyManagement.managedVersions['org.aspectj:aspectjweaver']
|
||||
|
||||
dependencies {
|
||||
compile("org.aspectj:aspectjweaver")
|
||||
api("org.aspectj:aspectjweaver")
|
||||
compileOnly("org.aspectj:aspectjrt")
|
||||
optional(project(":spring-aop")) // for @Async support
|
||||
optional(project(":spring-beans")) // for @Configurable support
|
||||
@@ -21,13 +21,13 @@ dependencies {
|
||||
optional(project(":spring-tx")) // for JPA, @Transactional support
|
||||
optional("javax.cache:cache-api") // for JCache aspect
|
||||
optional("javax.transaction:javax.transaction-api") // for @javax.transaction.Transactional support
|
||||
testCompile(project(":spring-core")) // for CodeStyleAspect
|
||||
testCompile(project(":spring-test"))
|
||||
testCompile(testFixtures(project(":spring-context")))
|
||||
testCompile(testFixtures(project(":spring-context-support")))
|
||||
testCompile(testFixtures(project(":spring-core")))
|
||||
testCompile(testFixtures(project(":spring-tx")))
|
||||
testCompile("javax.mail:javax.mail-api")
|
||||
testImplementation(project(":spring-core")) // for CodeStyleAspect
|
||||
testImplementation(project(":spring-test"))
|
||||
testImplementation(testFixtures(project(":spring-context")))
|
||||
testImplementation(testFixtures(project(":spring-context-support")))
|
||||
testImplementation(testFixtures(project(":spring-core")))
|
||||
testImplementation(testFixtures(project(":spring-tx")))
|
||||
testImplementation("javax.mail:javax.mail-api")
|
||||
testCompileOnly("org.aspectj:aspectjrt")
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ apply plugin: "groovy"
|
||||
apply plugin: "kotlin"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-core"))
|
||||
api(project(":spring-core"))
|
||||
optional("javax.inject:javax.inject")
|
||||
optional("org.yaml:snakeyaml")
|
||||
optional("org.codehaus.groovy:groovy-xml")
|
||||
optional("org.jetbrains.kotlin:kotlin-reflect")
|
||||
optional("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
testCompile(testFixtures(project(":spring-core")))
|
||||
testCompile("javax.annotation:javax.annotation-api")
|
||||
testImplementation(testFixtures(project(":spring-core")))
|
||||
testImplementation("javax.annotation:javax.annotation-api")
|
||||
testFixturesApi("org.junit.jupiter:junit-jupiter-api")
|
||||
testFixturesImplementation("org.assertj:assertj-core")
|
||||
}
|
||||
|
||||
@@ -87,7 +87,10 @@ public abstract class BeanUtils {
|
||||
values.put(byte.class, (byte) 0);
|
||||
values.put(short.class, (short) 0);
|
||||
values.put(int.class, 0);
|
||||
values.put(long.class, (long) 0);
|
||||
values.put(long.class, 0L);
|
||||
values.put(float.class, 0F);
|
||||
values.put(double.class, 0D);
|
||||
values.put(char.class, '\0');
|
||||
DEFAULT_TYPE_VALUES = Collections.unmodifiableMap(values);
|
||||
}
|
||||
|
||||
|
||||
+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.
|
||||
@@ -138,7 +138,7 @@ final class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor {
|
||||
Set<Method> ambiguousCandidates = this.ambiguousWriteMethods;
|
||||
if (ambiguousCandidates != null) {
|
||||
this.ambiguousWriteMethods = null;
|
||||
LogFactory.getLog(GenericTypeAwarePropertyDescriptor.class).warn("Invalid JavaBean property '" +
|
||||
LogFactory.getLog(GenericTypeAwarePropertyDescriptor.class).debug("Non-unique JavaBean property '" +
|
||||
getName() + "' being accessed! Ambiguous write methods found next to actually used [" +
|
||||
this.writeMethod + "]: " + ambiguousCandidates);
|
||||
}
|
||||
|
||||
+4
-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.
|
||||
@@ -351,7 +351,9 @@ public class ConstructorArgumentValues {
|
||||
* @return the ValueHolder for the argument, or {@code null} if none set
|
||||
*/
|
||||
@Nullable
|
||||
public ValueHolder getArgumentValue(int index, @Nullable Class<?> requiredType, @Nullable String requiredName, @Nullable Set<ValueHolder> usedValueHolders) {
|
||||
public ValueHolder getArgumentValue(int index, @Nullable Class<?> requiredType,
|
||||
@Nullable String requiredName, @Nullable Set<ValueHolder> usedValueHolders) {
|
||||
|
||||
Assert.isTrue(index >= 0, "Index must not be negative");
|
||||
ValueHolder valueHolder = getIndexedArgumentValue(index, requiredType, requiredName);
|
||||
if (valueHolder == null) {
|
||||
|
||||
+18
@@ -246,6 +246,15 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
this.allowCircularReferences = allowCircularReferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether to allow circular references between beans.
|
||||
* @since 5.3.10
|
||||
* @see #setAllowCircularReferences
|
||||
*/
|
||||
public boolean isAllowCircularReferences() {
|
||||
return this.allowCircularReferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to allow the raw injection of a bean instance into some other
|
||||
* bean's property, despite the injected bean eventually getting wrapped
|
||||
@@ -264,6 +273,15 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
this.allowRawInjectionDespiteWrapping = allowRawInjectionDespiteWrapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether to allow the raw injection of a bean instance.
|
||||
* @since 5.3.10
|
||||
* @see #setAllowRawInjectionDespiteWrapping
|
||||
*/
|
||||
public boolean isAllowRawInjectionDespiteWrapping() {
|
||||
return this.allowRawInjectionDespiteWrapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignore the given dependency type for autowiring:
|
||||
* for example, String. Default is none.
|
||||
|
||||
+200
-269
File diff suppressed because it is too large
Load Diff
@@ -49,6 +49,7 @@ import org.springframework.lang.Nullable;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.assertj.core.api.SoftAssertions.assertSoftly;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link BeanUtils}.
|
||||
@@ -85,19 +86,43 @@ class BeanUtilsTests {
|
||||
}
|
||||
|
||||
@Test // gh-22531
|
||||
void instantiateClassWithOptionalPrimitiveType() throws NoSuchMethodException {
|
||||
Constructor<BeanWithPrimitiveTypes> ctor = BeanWithPrimitiveTypes.class.getDeclaredConstructor(int.class, boolean.class, String.class);
|
||||
BeanWithPrimitiveTypes bean = BeanUtils.instantiateClass(ctor, null, null, "foo");
|
||||
assertThat(bean.getCounter()).isEqualTo(0);
|
||||
assertThat(bean.isFlag()).isEqualTo(false);
|
||||
assertThat(bean.getValue()).isEqualTo("foo");
|
||||
void instantiateClassWithFewerArgsThanParameters() throws NoSuchMethodException {
|
||||
Constructor<BeanWithPrimitiveTypes> constructor = getBeanWithPrimitiveTypesConstructor();
|
||||
|
||||
assertThatExceptionOfType(BeanInstantiationException.class).isThrownBy(() ->
|
||||
BeanUtils.instantiateClass(constructor, null, null, "foo"));
|
||||
}
|
||||
|
||||
@Test // gh-22531
|
||||
void instantiateClassWithMoreArgsThanParameters() throws NoSuchMethodException {
|
||||
Constructor<BeanWithPrimitiveTypes> ctor = BeanWithPrimitiveTypes.class.getDeclaredConstructor(int.class, boolean.class, String.class);
|
||||
Constructor<BeanWithPrimitiveTypes> constructor = getBeanWithPrimitiveTypesConstructor();
|
||||
|
||||
assertThatExceptionOfType(BeanInstantiationException.class).isThrownBy(() ->
|
||||
BeanUtils.instantiateClass(ctor, null, null, "foo", null));
|
||||
BeanUtils.instantiateClass(constructor, null, null, null, null, null, null, null, null, "foo", null));
|
||||
}
|
||||
|
||||
@Test // gh-22531, gh-27390
|
||||
void instantiateClassWithOptionalPrimitiveTypes() throws NoSuchMethodException {
|
||||
Constructor<BeanWithPrimitiveTypes> constructor = getBeanWithPrimitiveTypesConstructor();
|
||||
|
||||
BeanWithPrimitiveTypes bean = BeanUtils.instantiateClass(constructor, null, null, null, null, null, null, null, null, "foo");
|
||||
|
||||
assertSoftly(softly -> {
|
||||
softly.assertThat(bean.isFlag()).isFalse();
|
||||
softly.assertThat(bean.getByteCount()).isEqualTo((byte) 0);
|
||||
softly.assertThat(bean.getShortCount()).isEqualTo((short) 0);
|
||||
softly.assertThat(bean.getIntCount()).isEqualTo(0);
|
||||
softly.assertThat(bean.getLongCount()).isEqualTo(0L);
|
||||
softly.assertThat(bean.getFloatCount()).isEqualTo(0F);
|
||||
softly.assertThat(bean.getDoubleCount()).isEqualTo(0D);
|
||||
softly.assertThat(bean.getCharacter()).isEqualTo('\0');
|
||||
softly.assertThat(bean.getText()).isEqualTo("foo");
|
||||
});
|
||||
}
|
||||
|
||||
private Constructor<BeanWithPrimitiveTypes> getBeanWithPrimitiveTypesConstructor() throws NoSuchMethodException {
|
||||
return BeanWithPrimitiveTypes.class.getConstructor(boolean.class, byte.class, short.class, int.class,
|
||||
long.class, float.class, double.class, char.class, String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -628,30 +653,68 @@ class BeanUtilsTests {
|
||||
|
||||
private static class BeanWithPrimitiveTypes {
|
||||
|
||||
private int counter;
|
||||
|
||||
private boolean flag;
|
||||
private byte byteCount;
|
||||
private short shortCount;
|
||||
private int intCount;
|
||||
private long longCount;
|
||||
private float floatCount;
|
||||
private double doubleCount;
|
||||
private char character;
|
||||
private String text;
|
||||
|
||||
private String value;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public BeanWithPrimitiveTypes(int counter, boolean flag, String value) {
|
||||
this.counter = counter;
|
||||
this.flag = flag;
|
||||
this.value = value;
|
||||
}
|
||||
public BeanWithPrimitiveTypes(boolean flag, byte byteCount, short shortCount, int intCount, long longCount,
|
||||
float floatCount, double doubleCount, char character, String text) {
|
||||
|
||||
public int getCounter() {
|
||||
return counter;
|
||||
this.flag = flag;
|
||||
this.byteCount = byteCount;
|
||||
this.shortCount = shortCount;
|
||||
this.intCount = intCount;
|
||||
this.longCount = longCount;
|
||||
this.floatCount = floatCount;
|
||||
this.doubleCount = doubleCount;
|
||||
this.character = character;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public boolean isFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
public byte getByteCount() {
|
||||
return byteCount;
|
||||
}
|
||||
|
||||
public short getShortCount() {
|
||||
return shortCount;
|
||||
}
|
||||
|
||||
public int getIntCount() {
|
||||
return intCount;
|
||||
}
|
||||
|
||||
public long getLongCount() {
|
||||
return longCount;
|
||||
}
|
||||
|
||||
public float getFloatCount() {
|
||||
return floatCount;
|
||||
}
|
||||
|
||||
public double getDoubleCount() {
|
||||
return doubleCount;
|
||||
}
|
||||
|
||||
public char getCharacter() {
|
||||
return character;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class PrivateBeanWithPrivateConstructor {
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public class BeanWrapperAutoGrowingTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
public void setup() {
|
||||
wrapper.setAutoGrowNestedPaths(true);
|
||||
}
|
||||
|
||||
|
||||
+72
-80
@@ -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.
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.beans;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -46,10 +45,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Chris Beams
|
||||
* @since 18.01.2006
|
||||
*/
|
||||
public class BeanWrapperGenericsTests {
|
||||
class BeanWrapperGenericsTests {
|
||||
|
||||
@Test
|
||||
public void testGenericSet() {
|
||||
void testGenericSet() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
Set<String> input = new HashSet<>();
|
||||
@@ -61,7 +60,7 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericLowerBoundedSet() {
|
||||
void testGenericLowerBoundedSet() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, true));
|
||||
@@ -74,7 +73,7 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericSetWithConversionFailure() {
|
||||
void testGenericSetWithConversionFailure() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
Set<TestBean> input = new HashSet<>();
|
||||
@@ -85,7 +84,7 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericList() throws MalformedURLException {
|
||||
void testGenericList() throws Exception {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
List<String> input = new ArrayList<>();
|
||||
@@ -97,7 +96,7 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListElement() throws MalformedURLException {
|
||||
void testGenericListElement() throws Exception {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
gb.setResourceList(new ArrayList<>());
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
@@ -106,29 +105,29 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMap() {
|
||||
void testGenericMap() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
Map<String, String> input = new HashMap<>();
|
||||
input.put("4", "5");
|
||||
input.put("6", "7");
|
||||
bw.setPropertyValue("shortMap", input);
|
||||
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(new Short("6"))).isEqualTo(7);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapElement() {
|
||||
void testGenericMapElement() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
gb.setShortMap(new HashMap<>());
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("shortMap[4]", "5");
|
||||
assertThat(bw.getPropertyValue("shortMap[4]")).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapWithKeyType() {
|
||||
void testGenericMapWithKeyType() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
Map<String, String> input = new HashMap<>();
|
||||
@@ -140,17 +139,17 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapElementWithKeyType() {
|
||||
void testGenericMapElementWithKeyType() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
gb.setLongMap(new HashMap<Long, Integer>());
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("longMap[4]", "5");
|
||||
assertThat(gb.getLongMap().get(new Long("4"))).isEqualTo("5");
|
||||
assertThat(gb.getLongMap().get(Long.valueOf("4"))).isEqualTo("5");
|
||||
assertThat(bw.getPropertyValue("longMap[4]")).isEqualTo("5");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapWithCollectionValue() {
|
||||
void testGenericMapWithCollectionValue() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
|
||||
@@ -162,14 +161,12 @@ public class BeanWrapperGenericsTests {
|
||||
value2.add(Boolean.TRUE);
|
||||
input.put("2", value2);
|
||||
bw.setPropertyValue("collectionMap", input);
|
||||
boolean condition1 = gb.getCollectionMap().get(1) instanceof HashSet;
|
||||
assertThat(condition1).isTrue();
|
||||
boolean condition = gb.getCollectionMap().get(2) instanceof ArrayList;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(gb.getCollectionMap().get(1) instanceof HashSet).isTrue();
|
||||
assertThat(gb.getCollectionMap().get(2) instanceof ArrayList).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapElementWithCollectionValue() {
|
||||
void testGenericMapElementWithCollectionValue() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
gb.setCollectionMap(new HashMap<>());
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
@@ -177,24 +174,23 @@ public class BeanWrapperGenericsTests {
|
||||
HashSet<Integer> value1 = new HashSet<>();
|
||||
value1.add(1);
|
||||
bw.setPropertyValue("collectionMap[1]", value1);
|
||||
boolean condition = gb.getCollectionMap().get(1) instanceof HashSet;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(gb.getCollectionMap().get(1) instanceof HashSet).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapFromProperties() {
|
||||
void testGenericMapFromProperties() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
Properties input = new Properties();
|
||||
input.setProperty("4", "5");
|
||||
input.setProperty("6", "7");
|
||||
bw.setPropertyValue("shortMap", input);
|
||||
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(new Short("6"))).isEqualTo(7);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListOfLists() throws MalformedURLException {
|
||||
void testGenericListOfLists() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
List<List<Integer>> list = new ArrayList<>();
|
||||
list.add(new ArrayList<>());
|
||||
@@ -206,7 +202,7 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListOfListsWithElementConversion() throws MalformedURLException {
|
||||
void testGenericListOfListsWithElementConversion() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
List<List<Integer>> list = new ArrayList<>();
|
||||
list.add(new ArrayList<>());
|
||||
@@ -218,7 +214,7 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListOfArrays() throws MalformedURLException {
|
||||
void testGenericListOfArrays() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
ArrayList<String[]> list = new ArrayList<>();
|
||||
list.add(new String[] {"str1", "str2"});
|
||||
@@ -230,7 +226,7 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListOfArraysWithElementConversion() throws MalformedURLException {
|
||||
void testGenericListOfArraysWithElementConversion() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
ArrayList<String[]> list = new ArrayList<>();
|
||||
list.add(new String[] {"str1", "str2"});
|
||||
@@ -243,55 +239,55 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListOfMaps() throws MalformedURLException {
|
||||
void testGenericListOfMaps() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
List<Map<Integer, Long>> list = new ArrayList<>();
|
||||
list.add(new HashMap<>());
|
||||
gb.setListOfMaps(list);
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("listOfMaps[0][10]", new Long(5));
|
||||
assertThat(bw.getPropertyValue("listOfMaps[0][10]")).isEqualTo(new Long(5));
|
||||
assertThat(gb.getListOfMaps().get(0).get(10)).isEqualTo(new Long(5));
|
||||
bw.setPropertyValue("listOfMaps[0][10]", 5L);
|
||||
assertThat(bw.getPropertyValue("listOfMaps[0][10]")).isEqualTo(5L);
|
||||
assertThat(gb.getListOfMaps().get(0).get(10)).isEqualTo(Long.valueOf(5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListOfMapsWithElementConversion() throws MalformedURLException {
|
||||
void testGenericListOfMapsWithElementConversion() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
List<Map<Integer, Long>> list = new ArrayList<>();
|
||||
list.add(new HashMap<>());
|
||||
gb.setListOfMaps(list);
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("listOfMaps[0][10]", "5");
|
||||
assertThat(bw.getPropertyValue("listOfMaps[0][10]")).isEqualTo(new Long(5));
|
||||
assertThat(gb.getListOfMaps().get(0).get(10)).isEqualTo(new Long(5));
|
||||
assertThat(bw.getPropertyValue("listOfMaps[0][10]")).isEqualTo(5L);
|
||||
assertThat(gb.getListOfMaps().get(0).get(10)).isEqualTo(Long.valueOf(5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapOfMaps() throws MalformedURLException {
|
||||
void testGenericMapOfMaps() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
Map<String, Map<Integer, Long>> map = new HashMap<>();
|
||||
map.put("mykey", new HashMap<>());
|
||||
gb.setMapOfMaps(map);
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("mapOfMaps[mykey][10]", new Long(5));
|
||||
assertThat(bw.getPropertyValue("mapOfMaps[mykey][10]")).isEqualTo(new Long(5));
|
||||
assertThat(gb.getMapOfMaps().get("mykey").get(10)).isEqualTo(new Long(5));
|
||||
bw.setPropertyValue("mapOfMaps[mykey][10]", 5L);
|
||||
assertThat(bw.getPropertyValue("mapOfMaps[mykey][10]")).isEqualTo(5L);
|
||||
assertThat(gb.getMapOfMaps().get("mykey").get(10)).isEqualTo(Long.valueOf(5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapOfMapsWithElementConversion() throws MalformedURLException {
|
||||
void testGenericMapOfMapsWithElementConversion() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
Map<String, Map<Integer, Long>> map = new HashMap<>();
|
||||
map.put("mykey", new HashMap<>());
|
||||
gb.setMapOfMaps(map);
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("mapOfMaps[mykey][10]", "5");
|
||||
assertThat(bw.getPropertyValue("mapOfMaps[mykey][10]")).isEqualTo(new Long(5));
|
||||
assertThat(gb.getMapOfMaps().get("mykey").get(10)).isEqualTo(new Long(5));
|
||||
assertThat(bw.getPropertyValue("mapOfMaps[mykey][10]")).isEqualTo(Long.valueOf(5));
|
||||
assertThat(gb.getMapOfMaps().get("mykey").get(10)).isEqualTo(Long.valueOf(5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapOfLists() throws MalformedURLException {
|
||||
void testGenericMapOfLists() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
Map<Integer, List<Integer>> map = new HashMap<>();
|
||||
map.put(1, new ArrayList<>());
|
||||
@@ -303,7 +299,7 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapOfListsWithElementConversion() throws MalformedURLException {
|
||||
void testGenericMapOfListsWithElementConversion() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
Map<Integer, List<Integer>> map = new HashMap<>();
|
||||
map.put(1, new ArrayList<>());
|
||||
@@ -315,7 +311,7 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericTypeNestingMapOfInteger() throws Exception {
|
||||
void testGenericTypeNestingMapOfInteger() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("testKey", "100");
|
||||
|
||||
@@ -324,14 +320,13 @@ public class BeanWrapperGenericsTests {
|
||||
bw.setPropertyValue("mapOfInteger", map);
|
||||
|
||||
Object obj = gb.getMapOfInteger().get("testKey");
|
||||
boolean condition = obj instanceof Integer;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(obj instanceof Integer).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericTypeNestingMapOfListOfInteger() throws Exception {
|
||||
void testGenericTypeNestingMapOfListOfInteger() {
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
List<String> list = Arrays.asList(new String[] {"1", "2", "3"});
|
||||
List<String> list = Arrays.asList("1", "2", "3");
|
||||
map.put("testKey", list);
|
||||
|
||||
NestedGenericCollectionBean gb = new NestedGenericCollectionBean();
|
||||
@@ -339,13 +334,12 @@ public class BeanWrapperGenericsTests {
|
||||
bw.setPropertyValue("mapOfListOfInteger", map);
|
||||
|
||||
Object obj = gb.getMapOfListOfInteger().get("testKey").get(0);
|
||||
boolean condition = obj instanceof Integer;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(obj instanceof Integer).isTrue();
|
||||
assertThat(((Integer) obj).intValue()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericTypeNestingListOfMapOfInteger() throws Exception {
|
||||
void testGenericTypeNestingListOfMapOfInteger() {
|
||||
List<Map<String, String>> list = new ArrayList<>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("testKey", "5");
|
||||
@@ -356,15 +350,14 @@ public class BeanWrapperGenericsTests {
|
||||
bw.setPropertyValue("listOfMapOfInteger", list);
|
||||
|
||||
Object obj = gb.getListOfMapOfInteger().get(0).get("testKey");
|
||||
boolean condition = obj instanceof Integer;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(obj instanceof Integer).isTrue();
|
||||
assertThat(((Integer) obj).intValue()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericTypeNestingMapOfListOfListOfInteger() throws Exception {
|
||||
void testGenericTypeNestingMapOfListOfListOfInteger() {
|
||||
Map<String, List<List<String>>> map = new HashMap<>();
|
||||
List<String> list = Arrays.asList(new String[] {"1", "2", "3"});
|
||||
List<String> list = Arrays.asList("1", "2", "3");
|
||||
map.put("testKey", Collections.singletonList(list));
|
||||
|
||||
NestedGenericCollectionBean gb = new NestedGenericCollectionBean();
|
||||
@@ -372,13 +365,12 @@ public class BeanWrapperGenericsTests {
|
||||
bw.setPropertyValue("mapOfListOfListOfInteger", map);
|
||||
|
||||
Object obj = gb.getMapOfListOfListOfInteger().get("testKey").get(0).get(0);
|
||||
boolean condition = obj instanceof Integer;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(obj instanceof Integer).isTrue();
|
||||
assertThat(((Integer) obj).intValue()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexGenericMap() {
|
||||
void testComplexGenericMap() {
|
||||
Map<List<String>, List<String>> inputMap = new HashMap<>();
|
||||
List<String> inputKey = new ArrayList<>();
|
||||
inputKey.add("1");
|
||||
@@ -391,11 +383,11 @@ public class BeanWrapperGenericsTests {
|
||||
bw.setPropertyValue("genericMap", inputMap);
|
||||
|
||||
assertThat(holder.getGenericMap().keySet().iterator().next().get(0)).isEqualTo(1);
|
||||
assertThat(holder.getGenericMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
|
||||
assertThat(holder.getGenericMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexGenericMapWithCollectionConversion() {
|
||||
void testComplexGenericMapWithCollectionConversion() {
|
||||
Map<Set<String>, Set<String>> inputMap = new HashMap<>();
|
||||
Set<String> inputKey = new HashSet<>();
|
||||
inputKey.add("1");
|
||||
@@ -408,11 +400,11 @@ public class BeanWrapperGenericsTests {
|
||||
bw.setPropertyValue("genericMap", inputMap);
|
||||
|
||||
assertThat(holder.getGenericMap().keySet().iterator().next().get(0)).isEqualTo(1);
|
||||
assertThat(holder.getGenericMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
|
||||
assertThat(holder.getGenericMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexGenericIndexedMapEntry() {
|
||||
void testComplexGenericIndexedMapEntry() {
|
||||
List<String> inputValue = new ArrayList<>();
|
||||
inputValue.add("10");
|
||||
|
||||
@@ -421,11 +413,11 @@ public class BeanWrapperGenericsTests {
|
||||
bw.setPropertyValue("genericIndexedMap[1]", inputValue);
|
||||
|
||||
assertThat(holder.getGenericIndexedMap().keySet().iterator().next()).isEqualTo(1);
|
||||
assertThat(holder.getGenericIndexedMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
|
||||
assertThat(holder.getGenericIndexedMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexGenericIndexedMapEntryWithCollectionConversion() {
|
||||
void testComplexGenericIndexedMapEntryWithCollectionConversion() {
|
||||
Set<String> inputValue = new HashSet<>();
|
||||
inputValue.add("10");
|
||||
|
||||
@@ -434,11 +426,11 @@ public class BeanWrapperGenericsTests {
|
||||
bw.setPropertyValue("genericIndexedMap[1]", inputValue);
|
||||
|
||||
assertThat(holder.getGenericIndexedMap().keySet().iterator().next()).isEqualTo(1);
|
||||
assertThat(holder.getGenericIndexedMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
|
||||
assertThat(holder.getGenericIndexedMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexDerivedIndexedMapEntry() {
|
||||
void testComplexDerivedIndexedMapEntry() {
|
||||
List<String> inputValue = new ArrayList<>();
|
||||
inputValue.add("10");
|
||||
|
||||
@@ -447,11 +439,11 @@ public class BeanWrapperGenericsTests {
|
||||
bw.setPropertyValue("derivedIndexedMap[1]", inputValue);
|
||||
|
||||
assertThat(holder.getDerivedIndexedMap().keySet().iterator().next()).isEqualTo(1);
|
||||
assertThat(holder.getDerivedIndexedMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
|
||||
assertThat(holder.getDerivedIndexedMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexDerivedIndexedMapEntryWithCollectionConversion() {
|
||||
void testComplexDerivedIndexedMapEntryWithCollectionConversion() {
|
||||
Set<String> inputValue = new HashSet<>();
|
||||
inputValue.add("10");
|
||||
|
||||
@@ -460,11 +452,11 @@ public class BeanWrapperGenericsTests {
|
||||
bw.setPropertyValue("derivedIndexedMap[1]", inputValue);
|
||||
|
||||
assertThat(holder.getDerivedIndexedMap().keySet().iterator().next()).isEqualTo(1);
|
||||
assertThat(holder.getDerivedIndexedMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
|
||||
assertThat(holder.getDerivedIndexedMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericallyTypedIntegerBean() throws Exception {
|
||||
void testGenericallyTypedIntegerBean() {
|
||||
GenericIntegerBean gb = new GenericIntegerBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("genericProperty", "10");
|
||||
@@ -475,7 +467,7 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericallyTypedSetOfIntegerBean() throws Exception {
|
||||
void testGenericallyTypedSetOfIntegerBean() {
|
||||
GenericSetOfIntegerBean gb = new GenericSetOfIntegerBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("genericProperty", "10");
|
||||
@@ -486,23 +478,23 @@ public class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSettingGenericPropertyWithReadOnlyInterface() {
|
||||
void testSettingGenericPropertyWithReadOnlyInterface() {
|
||||
Bar bar = new Bar();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bar);
|
||||
bw.setPropertyValue("version", "10");
|
||||
assertThat(bar.getVersion()).isEqualTo(new Double(10.0));
|
||||
assertThat(bar.getVersion()).isEqualTo(Double.valueOf(10.0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSettingLongPropertyWithGenericInterface() {
|
||||
void testSettingLongPropertyWithGenericInterface() {
|
||||
Promotion bean = new Promotion();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.setPropertyValue("id", "10");
|
||||
assertThat(bean.getId()).isEqualTo(new Long(10));
|
||||
assertThat(bean.getId()).isEqualTo(Long.valueOf(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUntypedPropertyWithMapAtRuntime() {
|
||||
void testUntypedPropertyWithMapAtRuntime() {
|
||||
class Holder<D> {
|
||||
private final D data;
|
||||
public Holder(D data) {
|
||||
|
||||
@@ -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.
|
||||
@@ -26,6 +26,7 @@ import org.springframework.beans.testfixture.beans.TestBean;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
|
||||
/**
|
||||
* Specific {@link BeanWrapperImpl} tests.
|
||||
@@ -37,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Chris Beams
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
|
||||
@Override
|
||||
protected BeanWrapperImpl createAccessor(Object target) {
|
||||
@@ -46,7 +47,7 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void setterDoesNotCallGetter() {
|
||||
void setterDoesNotCallGetter() {
|
||||
GetterBean target = new GetterBean();
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
accessor.setPropertyValue("name", "tom");
|
||||
@@ -55,7 +56,7 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getterSilentlyFailWithOldValueExtraction() {
|
||||
void getterSilentlyFailWithOldValueExtraction() {
|
||||
GetterBean target = new GetterBean();
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
accessor.setExtractOldValueForEditor(true); // This will call the getter
|
||||
@@ -65,7 +66,7 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aliasedSetterThroughDefaultMethod() {
|
||||
void aliasedSetterThroughDefaultMethod() {
|
||||
GetterBean target = new GetterBean();
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
accessor.setPropertyValue("aliasedName", "tom");
|
||||
@@ -74,7 +75,7 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setValidAndInvalidPropertyValuesShouldContainExceptionDetails() {
|
||||
void setValidAndInvalidPropertyValuesShouldContainExceptionDetails() {
|
||||
TestBean target = new TestBean();
|
||||
String newName = "tony";
|
||||
String invalidTouchy = ".valid";
|
||||
@@ -91,12 +92,12 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
.getNewValue()).isEqualTo(invalidTouchy);
|
||||
});
|
||||
// Test validly set property matches
|
||||
assertThat(target.getName().equals(newName)).as("Valid set property must stick").isTrue();
|
||||
assertThat(target.getAge() == 0).as("Invalid set property must retain old value").isTrue();
|
||||
assertThat(target.getName()).as("Valid set property must stick").isEqualTo(newName);
|
||||
assertThat(target.getAge()).as("Invalid set property must retain old value").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkNotWritablePropertyHoldPossibleMatches() {
|
||||
void checkNotWritablePropertyHoldPossibleMatches() {
|
||||
TestBean target = new TestBean();
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
assertThatExceptionOfType(NotWritablePropertyException.class).isThrownBy(() ->
|
||||
@@ -105,15 +106,15 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
}
|
||||
|
||||
@Test // Can't be shared; there is no such thing as a read-only field
|
||||
public void setReadOnlyMapProperty() {
|
||||
void setReadOnlyMapProperty() {
|
||||
TypedReadOnlyMap map = new TypedReadOnlyMap(Collections.singletonMap("key", new TestBean()));
|
||||
TypedReadOnlyMapClient target = new TypedReadOnlyMapClient();
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
accessor.setPropertyValue("map", map);
|
||||
assertThatNoException().isThrownBy(() -> accessor.setPropertyValue("map", map));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notWritablePropertyExceptionContainsAlternativeMatch() {
|
||||
void notWritablePropertyExceptionContainsAlternativeMatch() {
|
||||
IntelliBean target = new IntelliBean();
|
||||
BeanWrapper bw = createAccessor(target);
|
||||
try {
|
||||
@@ -121,12 +122,12 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
}
|
||||
catch (NotWritablePropertyException ex) {
|
||||
assertThat(ex.getPossibleMatches()).as("Possible matches not determined").isNotNull();
|
||||
assertThat(ex.getPossibleMatches().length).as("Invalid amount of alternatives").isEqualTo(1);
|
||||
assertThat(ex.getPossibleMatches()).as("Invalid amount of alternatives").hasSize(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notWritablePropertyExceptionContainsAlternativeMatches() {
|
||||
void notWritablePropertyExceptionContainsAlternativeMatches() {
|
||||
IntelliBean target = new IntelliBean();
|
||||
BeanWrapper bw = createAccessor(target);
|
||||
try {
|
||||
@@ -134,23 +135,23 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
}
|
||||
catch (NotWritablePropertyException ex) {
|
||||
assertThat(ex.getPossibleMatches()).as("Possible matches not determined").isNotNull();
|
||||
assertThat(ex.getPossibleMatches().length).as("Invalid amount of alternatives").isEqualTo(3);
|
||||
assertThat(ex.getPossibleMatches()).as("Invalid amount of alternatives").hasSize(3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test // Can't be shared: no type mismatch with a field
|
||||
public void setPropertyTypeMismatch() {
|
||||
void setPropertyTypeMismatch() {
|
||||
PropertyTypeMismatch target = new PropertyTypeMismatch();
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
accessor.setPropertyValue("object", "a String");
|
||||
assertThat(target.value).isEqualTo("a String");
|
||||
assertThat(target.getObject() == 8).isTrue();
|
||||
assertThat(target.getObject()).isEqualTo(8);
|
||||
assertThat(accessor.getPropertyValue("object")).isEqualTo(8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyDescriptors() {
|
||||
void propertyDescriptors() {
|
||||
TestBean target = new TestBean();
|
||||
target.setSpouse(new TestBean());
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
@@ -166,7 +167,7 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void getPropertyWithOptional() {
|
||||
void getPropertyWithOptional() {
|
||||
GetterWithOptional target = new GetterWithOptional();
|
||||
TestBean tb = new TestBean("x");
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
@@ -189,7 +190,7 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPropertyWithOptionalAndAutoGrow() {
|
||||
void getPropertyWithOptionalAndAutoGrow() {
|
||||
GetterWithOptional target = new GetterWithOptional();
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
accessor.setAutoGrowNestedPaths(true);
|
||||
@@ -201,7 +202,7 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void incompletelyQuotedKeyLeadsToPropertyException() {
|
||||
void incompletelyQuotedKeyLeadsToPropertyException() {
|
||||
TestBean target = new TestBean();
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
assertThatExceptionOfType(NotWritablePropertyException.class).isThrownBy(() ->
|
||||
|
||||
@@ -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.
|
||||
@@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Chris Beams
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class DirectFieldAccessorTests extends AbstractPropertyAccessorTests {
|
||||
class DirectFieldAccessorTests extends AbstractPropertyAccessorTests {
|
||||
|
||||
@Override
|
||||
protected DirectFieldAccessor createAccessor(Object target) {
|
||||
@@ -38,7 +38,7 @@ public class DirectFieldAccessorTests extends AbstractPropertyAccessorTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void withShadowedField() {
|
||||
void withShadowedField() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
TestBean target = new TestBean() {
|
||||
|
||||
+17
-17
@@ -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.
|
||||
@@ -182,9 +182,9 @@ class DefaultListableBeanFactoryTests {
|
||||
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
|
||||
assertThat(beanNames.length).isEqualTo(0);
|
||||
assertThat(beanNames).hasSize(0);
|
||||
beanNames = lbf.getBeanNamesForAnnotation(SuppressWarnings.class);
|
||||
assertThat(beanNames.length).isEqualTo(0);
|
||||
assertThat(beanNames).hasSize(0);
|
||||
|
||||
assertThat(lbf.containsSingleton("x1")).isFalse();
|
||||
assertThat(lbf.containsBean("x1")).isTrue();
|
||||
@@ -216,9 +216,9 @@ class DefaultListableBeanFactoryTests {
|
||||
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
|
||||
assertThat(beanNames.length).isEqualTo(0);
|
||||
assertThat(beanNames).hasSize(0);
|
||||
beanNames = lbf.getBeanNamesForAnnotation(SuppressWarnings.class);
|
||||
assertThat(beanNames.length).isEqualTo(0);
|
||||
assertThat(beanNames).hasSize(0);
|
||||
|
||||
assertThat(lbf.containsSingleton("x1")).isFalse();
|
||||
assertThat(lbf.containsBean("x1")).isTrue();
|
||||
@@ -249,9 +249,9 @@ class DefaultListableBeanFactoryTests {
|
||||
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
|
||||
assertThat(beanNames.length).isEqualTo(0);
|
||||
assertThat(beanNames).hasSize(0);
|
||||
beanNames = lbf.getBeanNamesForAnnotation(SuppressWarnings.class);
|
||||
assertThat(beanNames.length).isEqualTo(0);
|
||||
assertThat(beanNames).hasSize(0);
|
||||
|
||||
assertThat(lbf.containsSingleton("x1")).isFalse();
|
||||
assertThat(lbf.containsBean("x1")).isTrue();
|
||||
@@ -283,7 +283,7 @@ class DefaultListableBeanFactoryTests {
|
||||
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
|
||||
assertThat(beanNames.length).isEqualTo(1);
|
||||
assertThat(beanNames).hasSize(1);
|
||||
assertThat(beanNames[0]).isEqualTo("x1");
|
||||
assertThat(lbf.containsSingleton("x1")).isTrue();
|
||||
assertThat(lbf.containsBean("x1")).isTrue();
|
||||
@@ -337,7 +337,7 @@ class DefaultListableBeanFactoryTests {
|
||||
|
||||
TestBeanFactory.initialized = false;
|
||||
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
|
||||
assertThat(beanNames.length).isEqualTo(1);
|
||||
assertThat(beanNames).hasSize(1);
|
||||
assertThat(beanNames[0]).isEqualTo("x1");
|
||||
assertThat(lbf.containsSingleton("x1")).isFalse();
|
||||
assertThat(lbf.containsBean("x1")).isTrue();
|
||||
@@ -349,7 +349,7 @@ class DefaultListableBeanFactoryTests {
|
||||
assertThat(lbf.isTypeMatch("x1", TestBean.class)).isTrue();
|
||||
assertThat(lbf.isTypeMatch("&x1", TestBean.class)).isFalse();
|
||||
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
|
||||
assertThat(lbf.getType("&x1")).isEqualTo(null);
|
||||
assertThat(lbf.getType("&x1")).isNull();
|
||||
assertThat(TestBeanFactory.initialized).isFalse();
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ class DefaultListableBeanFactoryTests {
|
||||
|
||||
TestBeanFactory.initialized = false;
|
||||
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
|
||||
assertThat(beanNames.length).isEqualTo(1);
|
||||
assertThat(beanNames).hasSize(1);
|
||||
assertThat(beanNames[0]).isEqualTo("x1");
|
||||
assertThat(lbf.containsSingleton("x1")).isFalse();
|
||||
assertThat(lbf.containsBean("x1")).isTrue();
|
||||
@@ -374,7 +374,7 @@ class DefaultListableBeanFactoryTests {
|
||||
assertThat(lbf.isTypeMatch("x1", TestBean.class)).isTrue();
|
||||
assertThat(lbf.isTypeMatch("&x1", TestBean.class)).isFalse();
|
||||
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
|
||||
assertThat(lbf.getType("&x1")).isEqualTo(null);
|
||||
assertThat(lbf.getType("&x1")).isNull();
|
||||
assertThat(TestBeanFactory.initialized).isFalse();
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ class DefaultListableBeanFactoryTests {
|
||||
|
||||
TestBeanFactory.initialized = false;
|
||||
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
|
||||
assertThat(beanNames.length).isEqualTo(1);
|
||||
assertThat(beanNames).hasSize(1);
|
||||
assertThat(beanNames[0]).isEqualTo("x1");
|
||||
assertThat(lbf.containsSingleton("x1")).isFalse();
|
||||
assertThat(lbf.containsBean("x1")).isTrue();
|
||||
@@ -401,7 +401,7 @@ class DefaultListableBeanFactoryTests {
|
||||
assertThat(lbf.isTypeMatch("x1", TestBean.class)).isTrue();
|
||||
assertThat(lbf.isTypeMatch("&x1", TestBean.class)).isFalse();
|
||||
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
|
||||
assertThat(lbf.getType("&x1")).isEqualTo(null);
|
||||
assertThat(lbf.getType("&x1")).isNull();
|
||||
assertThat(TestBeanFactory.initialized).isFalse();
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ class DefaultListableBeanFactoryTests {
|
||||
|
||||
TestBeanFactory.initialized = false;
|
||||
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
|
||||
assertThat(beanNames.length).isEqualTo(1);
|
||||
assertThat(beanNames).hasSize(1);
|
||||
assertThat(beanNames[0]).isEqualTo("x1");
|
||||
assertThat(lbf.containsSingleton("x1")).isFalse();
|
||||
assertThat(lbf.containsBean("x1")).isTrue();
|
||||
@@ -450,7 +450,7 @@ class DefaultListableBeanFactoryTests {
|
||||
assertThat(lbf.isTypeMatch("x2", Object.class)).isTrue();
|
||||
assertThat(lbf.isTypeMatch("&x2", Object.class)).isFalse();
|
||||
assertThat(lbf.getType("x2")).isEqualTo(TestBean.class);
|
||||
assertThat(lbf.getType("&x2")).isEqualTo(null);
|
||||
assertThat(lbf.getType("&x2")).isNull();
|
||||
assertThat(lbf.getAliases("x1").length).isEqualTo(1);
|
||||
assertThat(lbf.getAliases("x1")[0]).isEqualTo("x2");
|
||||
assertThat(lbf.getAliases("&x1").length).isEqualTo(1);
|
||||
@@ -3030,7 +3030,7 @@ class DefaultListableBeanFactoryTests {
|
||||
public Object convertIfNecessary(Object value, @Nullable Class requiredType) {
|
||||
if (value instanceof String && Float.class.isAssignableFrom(requiredType)) {
|
||||
try {
|
||||
return new Float(this.numberFormat.parse((String) value).floatValue());
|
||||
return this.numberFormat.parse((String) value).floatValue();
|
||||
}
|
||||
catch (ParseException ex) {
|
||||
throw new TypeMismatchException(value, requiredType, ex);
|
||||
|
||||
+85
-85
@@ -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.
|
||||
@@ -64,10 +64,10 @@ import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING;
|
||||
* @author Sam Brannen
|
||||
* @since 20.01.2006
|
||||
*/
|
||||
public class BeanFactoryGenericsTests {
|
||||
class BeanFactoryGenericsTests {
|
||||
|
||||
@Test
|
||||
public void testGenericSetProperty() {
|
||||
void testGenericSetProperty() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListProperty() throws Exception {
|
||||
void testGenericListProperty() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
|
||||
@@ -101,7 +101,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListPropertyWithAutowiring() throws Exception {
|
||||
void testGenericListPropertyWithAutowiring() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));
|
||||
bf.registerSingleton("resource2", new UrlResource("http://localhost:9090"));
|
||||
@@ -116,7 +116,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListPropertyWithInvalidElementType() {
|
||||
void testGenericListPropertyWithInvalidElementType() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericIntegerBean.class);
|
||||
|
||||
@@ -134,7 +134,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListPropertyWithOptionalAutowiring() {
|
||||
void testGenericListPropertyWithOptionalAutowiring() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
@@ -146,7 +146,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapProperty() {
|
||||
void testGenericMapProperty() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
|
||||
@@ -158,12 +158,12 @@ public class BeanFactoryGenericsTests {
|
||||
bf.registerBeanDefinition("genericBean", rbd);
|
||||
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
|
||||
|
||||
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(new Short("6"))).isEqualTo(7);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListOfArraysProperty() {
|
||||
void testGenericListOfArraysProperty() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
new ClassPathResource("genericBeanTests.xml", getClass()));
|
||||
@@ -171,14 +171,14 @@ public class BeanFactoryGenericsTests {
|
||||
|
||||
assertThat(gb.getListOfArrays().size()).isEqualTo(1);
|
||||
String[] array = gb.getListOfArrays().get(0);
|
||||
assertThat(array.length).isEqualTo(2);
|
||||
assertThat(array).hasSize(2);
|
||||
assertThat(array[0]).isEqualTo("value1");
|
||||
assertThat(array[1]).isEqualTo("value2");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGenericSetConstructor() {
|
||||
void testGenericSetConstructor() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
|
||||
@@ -195,7 +195,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericSetConstructorWithAutowiring() {
|
||||
void testGenericSetConstructorWithAutowiring() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.registerSingleton("integer1", 4);
|
||||
bf.registerSingleton("integer2", 5);
|
||||
@@ -210,7 +210,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericSetConstructorWithOptionalAutowiring() {
|
||||
void testGenericSetConstructorWithOptionalAutowiring() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
@@ -222,7 +222,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericSetListConstructor() throws Exception {
|
||||
void testGenericSetListConstructor() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
|
||||
@@ -245,7 +245,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericSetListConstructorWithAutowiring() throws Exception {
|
||||
void testGenericSetListConstructorWithAutowiring() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.registerSingleton("integer1", 4);
|
||||
bf.registerSingleton("integer2", 5);
|
||||
@@ -264,7 +264,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericSetListConstructorWithOptionalAutowiring() throws Exception {
|
||||
void testGenericSetListConstructorWithOptionalAutowiring() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));
|
||||
bf.registerSingleton("resource2", new UrlResource("http://localhost:9090"));
|
||||
@@ -279,7 +279,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericSetMapConstructor() {
|
||||
void testGenericSetMapConstructor() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
|
||||
@@ -297,12 +297,12 @@ public class BeanFactoryGenericsTests {
|
||||
|
||||
assertThat(gb.getIntegerSet().contains(4)).isTrue();
|
||||
assertThat(gb.getIntegerSet().contains(5)).isTrue();
|
||||
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(new Short("6"))).isEqualTo(7);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapResourceConstructor() throws Exception {
|
||||
void testGenericMapResourceConstructor() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
|
||||
@@ -315,13 +315,13 @@ public class BeanFactoryGenericsTests {
|
||||
bf.registerBeanDefinition("genericBean", rbd);
|
||||
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
|
||||
|
||||
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(new Short("6"))).isEqualTo(7);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
|
||||
assertThat(gb.getResourceList().get(0)).isEqualTo(new UrlResource("http://localhost:8080"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapMapConstructor() {
|
||||
void testGenericMapMapConstructor() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
|
||||
@@ -338,16 +338,16 @@ public class BeanFactoryGenericsTests {
|
||||
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
|
||||
|
||||
assertThat(gb.getShortMap()).isNotSameAs(gb.getPlainMap());
|
||||
assertThat(gb.getPlainMap().size()).isEqualTo(2);
|
||||
assertThat(gb.getPlainMap()).hasSize(2);
|
||||
assertThat(gb.getPlainMap().get("1")).isEqualTo("0");
|
||||
assertThat(gb.getPlainMap().get("2")).isEqualTo("3");
|
||||
assertThat(gb.getShortMap().size()).isEqualTo(2);
|
||||
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(new Short("6"))).isEqualTo(7);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapMapConstructorWithSameRefAndConversion() {
|
||||
void testGenericMapMapConstructorWithSameRefAndConversion() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
|
||||
@@ -361,22 +361,22 @@ public class BeanFactoryGenericsTests {
|
||||
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
|
||||
|
||||
assertThat(gb.getShortMap()).isNotSameAs(gb.getPlainMap());
|
||||
assertThat(gb.getPlainMap().size()).isEqualTo(2);
|
||||
assertThat(gb.getPlainMap()).hasSize(2);
|
||||
assertThat(gb.getPlainMap().get("1")).isEqualTo("0");
|
||||
assertThat(gb.getPlainMap().get("2")).isEqualTo("3");
|
||||
assertThat(gb.getShortMap().size()).isEqualTo(2);
|
||||
assertThat(gb.getShortMap().get(new Short("1"))).isEqualTo(0);
|
||||
assertThat(gb.getShortMap().get(new Short("2"))).isEqualTo(3);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("1"))).isEqualTo(0);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("2"))).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapMapConstructorWithSameRefAndNoConversion() {
|
||||
void testGenericMapMapConstructorWithSameRefAndNoConversion() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
|
||||
Map<Short, Integer> input = new HashMap<>();
|
||||
input.put(new Short((short) 1), 0);
|
||||
input.put(new Short((short) 2), 3);
|
||||
input.put((short) 1, 0);
|
||||
input.put((short) 2, 3);
|
||||
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
|
||||
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
|
||||
|
||||
@@ -384,13 +384,13 @@ public class BeanFactoryGenericsTests {
|
||||
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
|
||||
|
||||
assertThat(gb.getShortMap()).isSameAs(gb.getPlainMap());
|
||||
assertThat(gb.getShortMap().size()).isEqualTo(2);
|
||||
assertThat(gb.getShortMap().get(new Short("1"))).isEqualTo(0);
|
||||
assertThat(gb.getShortMap().get(new Short("2"))).isEqualTo(3);
|
||||
assertThat(gb.getShortMap()).hasSize(2);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("1"))).isEqualTo(0);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("2"))).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapWithKeyTypeConstructor() {
|
||||
void testGenericMapWithKeyTypeConstructor() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
|
||||
@@ -407,7 +407,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapWithCollectionValueConstructor() {
|
||||
void testGenericMapWithCollectionValueConstructor() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
|
||||
@Override
|
||||
@@ -438,7 +438,7 @@ public class BeanFactoryGenericsTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testGenericSetFactoryMethod() {
|
||||
void testGenericSetFactoryMethod() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
rbd.setFactoryMethodName("createInstance");
|
||||
@@ -456,7 +456,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericSetListFactoryMethod() throws Exception {
|
||||
void testGenericSetListFactoryMethod() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
rbd.setFactoryMethodName("createInstance");
|
||||
@@ -480,7 +480,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericSetMapFactoryMethod() {
|
||||
void testGenericSetMapFactoryMethod() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
rbd.setFactoryMethodName("createInstance");
|
||||
@@ -499,12 +499,12 @@ public class BeanFactoryGenericsTests {
|
||||
|
||||
assertThat(gb.getIntegerSet().contains(4)).isTrue();
|
||||
assertThat(gb.getIntegerSet().contains(5)).isTrue();
|
||||
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(new Short("6"))).isEqualTo(7);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapResourceFactoryMethod() throws Exception {
|
||||
void testGenericMapResourceFactoryMethod() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
rbd.setFactoryMethodName("createInstance");
|
||||
@@ -518,13 +518,13 @@ public class BeanFactoryGenericsTests {
|
||||
bf.registerBeanDefinition("genericBean", rbd);
|
||||
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
|
||||
|
||||
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(new Short("6"))).isEqualTo(7);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
|
||||
assertThat(gb.getResourceList().get(0)).isEqualTo(new UrlResource("http://localhost:8080"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapMapFactoryMethod() {
|
||||
void testGenericMapMapFactoryMethod() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
rbd.setFactoryMethodName("createInstance");
|
||||
@@ -543,12 +543,12 @@ public class BeanFactoryGenericsTests {
|
||||
|
||||
assertThat(gb.getPlainMap().get("1")).isEqualTo("0");
|
||||
assertThat(gb.getPlainMap().get("2")).isEqualTo("3");
|
||||
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(new Short("6"))).isEqualTo(7);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
|
||||
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapWithKeyTypeFactoryMethod() {
|
||||
void testGenericMapWithKeyTypeFactoryMethod() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
|
||||
rbd.setFactoryMethodName("createInstance");
|
||||
@@ -561,12 +561,12 @@ public class BeanFactoryGenericsTests {
|
||||
bf.registerBeanDefinition("genericBean", rbd);
|
||||
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
|
||||
|
||||
assertThat(gb.getLongMap().get(new Long("4"))).isEqualTo("5");
|
||||
assertThat(gb.getLongMap().get(new Long("6"))).isEqualTo("7");
|
||||
assertThat(gb.getLongMap().get(Long.valueOf("4"))).isEqualTo("5");
|
||||
assertThat(gb.getLongMap().get(Long.valueOf("6"))).isEqualTo("7");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapWithCollectionValueFactoryMethod() {
|
||||
void testGenericMapWithCollectionValueFactoryMethod() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
|
||||
@Override
|
||||
@@ -597,7 +597,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericListBean() throws Exception {
|
||||
void testGenericListBean() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
new ClassPathResource("genericBeanTests.xml", getClass()));
|
||||
@@ -607,7 +607,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericSetBean() throws Exception {
|
||||
void testGenericSetBean() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
new ClassPathResource("genericBeanTests.xml", getClass()));
|
||||
@@ -617,18 +617,18 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMapBean() throws Exception {
|
||||
void testGenericMapBean() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
new ClassPathResource("genericBeanTests.xml", getClass()));
|
||||
Map<?, ?> map = (Map<?, ?>) bf.getBean("map");
|
||||
assertThat(map.size()).isEqualTo(1);
|
||||
assertThat(map).hasSize(1);
|
||||
assertThat(map.keySet().iterator().next()).isEqualTo(10);
|
||||
assertThat(map.values().iterator().next()).isEqualTo(new URL("http://localhost:8080"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericallyTypedIntegerBean() {
|
||||
void testGenericallyTypedIntegerBean() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
new ClassPathResource("genericBeanTests.xml", getClass()));
|
||||
@@ -639,7 +639,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericallyTypedSetOfIntegerBean() {
|
||||
void testGenericallyTypedSetOfIntegerBean() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
new ClassPathResource("genericBeanTests.xml", getClass()));
|
||||
@@ -651,7 +651,7 @@ public class BeanFactoryGenericsTests {
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public void testSetBean() throws Exception {
|
||||
void testSetBean() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
new ClassPathResource("genericBeanTests.xml", getClass()));
|
||||
@@ -671,7 +671,7 @@ public class BeanFactoryGenericsTests {
|
||||
* <p>See SPR-9493
|
||||
*/
|
||||
@Test
|
||||
public void parameterizedStaticFactoryMethod() {
|
||||
void parameterizedStaticFactoryMethod() {
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(Mockito.class);
|
||||
rbd.setFactoryMethodName("mock");
|
||||
rbd.getConstructorArgumentValues().addGenericArgumentValue(Runnable.class);
|
||||
@@ -682,7 +682,7 @@ public class BeanFactoryGenericsTests {
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
Map<String, Runnable> beans = bf.getBeansOfType(Runnable.class);
|
||||
assertThat(beans.size()).isEqualTo(1);
|
||||
assertThat(beans).hasSize(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -697,7 +697,7 @@ public class BeanFactoryGenericsTests {
|
||||
* <p>See SPR-10411
|
||||
*/
|
||||
@Test
|
||||
public void parameterizedInstanceFactoryMethod() {
|
||||
void parameterizedInstanceFactoryMethod() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(MocksControl.class);
|
||||
@@ -714,11 +714,11 @@ public class BeanFactoryGenericsTests {
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
Map<String, Runnable> beans = bf.getBeansOfType(Runnable.class);
|
||||
assertThat(beans.size()).isEqualTo(1);
|
||||
assertThat(beans).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parameterizedInstanceFactoryMethodWithNonResolvedClassName() {
|
||||
void parameterizedInstanceFactoryMethodWithNonResolvedClassName() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(MocksControl.class);
|
||||
@@ -735,11 +735,11 @@ public class BeanFactoryGenericsTests {
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
Map<String, Runnable> beans = bf.getBeansOfType(Runnable.class);
|
||||
assertThat(beans.size()).isEqualTo(1);
|
||||
assertThat(beans).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parameterizedInstanceFactoryMethodWithWrappedClassName() {
|
||||
void parameterizedInstanceFactoryMethodWithWrappedClassName() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
|
||||
RootBeanDefinition rbd = new RootBeanDefinition();
|
||||
@@ -754,11 +754,11 @@ public class BeanFactoryGenericsTests {
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
Map<String, Runnable> beans = bf.getBeansOfType(Runnable.class);
|
||||
assertThat(beans.size()).isEqualTo(1);
|
||||
assertThat(beans).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parameterizedInstanceFactoryMethodWithInvalidClassName() {
|
||||
void parameterizedInstanceFactoryMethodWithInvalidClassName() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(MocksControl.class);
|
||||
@@ -775,11 +775,11 @@ public class BeanFactoryGenericsTests {
|
||||
assertThat(bf.getType("mock")).isNull();
|
||||
assertThat(bf.getType("mock")).isNull();
|
||||
Map<String, Runnable> beans = bf.getBeansOfType(Runnable.class);
|
||||
assertThat(beans.size()).isEqualTo(0);
|
||||
assertThat(beans).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parameterizedInstanceFactoryMethodWithIndexedArgument() {
|
||||
void parameterizedInstanceFactoryMethodWithIndexedArgument() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(MocksControl.class);
|
||||
@@ -796,11 +796,11 @@ public class BeanFactoryGenericsTests {
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
Map<String, Runnable> beans = bf.getBeansOfType(Runnable.class);
|
||||
assertThat(beans.size()).isEqualTo(1);
|
||||
assertThat(beans).hasSize(1);
|
||||
}
|
||||
|
||||
@Test // SPR-16720
|
||||
public void parameterizedInstanceFactoryMethodWithTempClassLoader() {
|
||||
void parameterizedInstanceFactoryMethodWithTempClassLoader() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.setTempClassLoader(new OverridingClassLoader(getClass().getClassLoader()));
|
||||
|
||||
@@ -818,11 +818,11 @@ public class BeanFactoryGenericsTests {
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
assertThat(bf.getType("mock")).isEqualTo(Runnable.class);
|
||||
Map<String, Runnable> beans = bf.getBeansOfType(Runnable.class);
|
||||
assertThat(beans.size()).isEqualTo(1);
|
||||
assertThat(beans).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMatchingWithBeanNameDifferentiation() {
|
||||
void testGenericMatchingWithBeanNameDifferentiation() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.setAutowireCandidateResolver(new GenericTypeAwareAutowireCandidateResolver());
|
||||
|
||||
@@ -838,15 +838,15 @@ public class BeanFactoryGenericsTests {
|
||||
String[] numberStoreNames = bf.getBeanNamesForType(ResolvableType.forClass(NumberStore.class));
|
||||
String[] doubleStoreNames = bf.getBeanNamesForType(ResolvableType.forClassWithGenerics(NumberStore.class, Double.class));
|
||||
String[] floatStoreNames = bf.getBeanNamesForType(ResolvableType.forClassWithGenerics(NumberStore.class, Float.class));
|
||||
assertThat(numberStoreNames.length).isEqualTo(2);
|
||||
assertThat(numberStoreNames).hasSize(2);
|
||||
assertThat(numberStoreNames[0]).isEqualTo("doubleStore");
|
||||
assertThat(numberStoreNames[1]).isEqualTo("floatStore");
|
||||
assertThat(doubleStoreNames.length).isEqualTo(0);
|
||||
assertThat(floatStoreNames.length).isEqualTo(0);
|
||||
assertThat(doubleStoreNames).hasSize(0);
|
||||
assertThat(floatStoreNames).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMatchingWithFullTypeDifferentiation() {
|
||||
void testGenericMatchingWithFullTypeDifferentiation() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE);
|
||||
bf.setAutowireCandidateResolver(new GenericTypeAwareAutowireCandidateResolver());
|
||||
@@ -867,12 +867,12 @@ public class BeanFactoryGenericsTests {
|
||||
String[] numberStoreNames = bf.getBeanNamesForType(ResolvableType.forClass(NumberStore.class));
|
||||
String[] doubleStoreNames = bf.getBeanNamesForType(ResolvableType.forClassWithGenerics(NumberStore.class, Double.class));
|
||||
String[] floatStoreNames = bf.getBeanNamesForType(ResolvableType.forClassWithGenerics(NumberStore.class, Float.class));
|
||||
assertThat(numberStoreNames.length).isEqualTo(2);
|
||||
assertThat(numberStoreNames).hasSize(2);
|
||||
assertThat(numberStoreNames[0]).isEqualTo("store1");
|
||||
assertThat(numberStoreNames[1]).isEqualTo("store2");
|
||||
assertThat(doubleStoreNames.length).isEqualTo(1);
|
||||
assertThat(doubleStoreNames).hasSize(1);
|
||||
assertThat(doubleStoreNames[0]).isEqualTo("store1");
|
||||
assertThat(floatStoreNames.length).isEqualTo(1);
|
||||
assertThat(floatStoreNames).hasSize(1);
|
||||
assertThat(floatStoreNames[0]).isEqualTo("store2");
|
||||
|
||||
ObjectProvider<NumberStore<?>> numberStoreProvider = bf.getBeanProvider(ResolvableType.forClass(NumberStore.class));
|
||||
@@ -938,7 +938,7 @@ public class BeanFactoryGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericMatchingWithUnresolvedOrderedStream() {
|
||||
void testGenericMatchingWithUnresolvedOrderedStream() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE);
|
||||
bf.setAutowireCandidateResolver(new GenericTypeAwareAutowireCandidateResolver());
|
||||
|
||||
+5
-5
@@ -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.
|
||||
@@ -26,18 +26,18 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
*
|
||||
* @author Rick Evans
|
||||
*/
|
||||
public class ClassNameBeanWiringInfoResolverTests {
|
||||
class ClassNameBeanWiringInfoResolverTests {
|
||||
|
||||
@Test
|
||||
public void resolveWiringInfoWithNullBeanInstance() throws Exception {
|
||||
void resolveWiringInfoWithNullBeanInstance() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new ClassNameBeanWiringInfoResolver().resolveWiringInfo(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveWiringInfo() {
|
||||
void resolveWiringInfo() {
|
||||
ClassNameBeanWiringInfoResolver resolver = new ClassNameBeanWiringInfoResolver();
|
||||
Long beanInstance = new Long(1);
|
||||
Long beanInstance = 1L;
|
||||
BeanWiringInfo info = resolver.resolveWiringInfo(beanInstance);
|
||||
assertThat(info).isNotNull();
|
||||
assertThat(info.getBeanName()).as("Not resolving bean name to the class name of the supplied bean instance as per class contract.").isEqualTo(beanInstance.getClass().getName());
|
||||
|
||||
+158
-158
@@ -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.
|
||||
@@ -64,10 +64,10 @@ import static org.assertj.core.api.Assertions.within;
|
||||
* @author Chris Beams
|
||||
* @since 10.06.2003
|
||||
*/
|
||||
public class CustomEditorTests {
|
||||
class CustomEditorTests {
|
||||
|
||||
@Test
|
||||
public void testComplexObject() {
|
||||
void testComplexObject() {
|
||||
TestBean tb = new TestBean();
|
||||
String newName = "Rod";
|
||||
String tbString = "Kerry_34";
|
||||
@@ -80,12 +80,12 @@ public class CustomEditorTests {
|
||||
pvs.addPropertyValue(new PropertyValue("touchy", "valid"));
|
||||
pvs.addPropertyValue(new PropertyValue("spouse", tbString));
|
||||
bw.setPropertyValues(pvs);
|
||||
assertThat(tb.getSpouse() != null).as("spouse is non-null").isTrue();
|
||||
assertThat(tb.getSpouse()).as("spouse is non-null").isNotNull();
|
||||
assertThat(tb.getSpouse().getName().equals("Kerry") && tb.getSpouse().getAge() == 34).as("spouse name is Kerry and age is 34").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexObjectWithOldValueAccess() {
|
||||
void testComplexObjectWithOldValueAccess() {
|
||||
TestBean tb = new TestBean();
|
||||
String newName = "Rod";
|
||||
String tbString = "Kerry_34";
|
||||
@@ -100,7 +100,7 @@ public class CustomEditorTests {
|
||||
pvs.addPropertyValue(new PropertyValue("spouse", tbString));
|
||||
|
||||
bw.setPropertyValues(pvs);
|
||||
assertThat(tb.getSpouse() != null).as("spouse is non-null").isTrue();
|
||||
assertThat(tb.getSpouse()).as("spouse is non-null").isNotNull();
|
||||
assertThat(tb.getSpouse().getName().equals("Kerry") && tb.getSpouse().getAge() == 34).as("spouse name is Kerry and age is 34").isTrue();
|
||||
ITestBean spouse = tb.getSpouse();
|
||||
|
||||
@@ -109,7 +109,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEditorForSingleProperty() {
|
||||
void testCustomEditorForSingleProperty() {
|
||||
TestBean tb = new TestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(String.class, "name", new PropertyEditorSupport() {
|
||||
@@ -127,7 +127,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEditorForAllStringProperties() {
|
||||
void testCustomEditorForAllStringProperties() {
|
||||
TestBean tb = new TestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
||||
@@ -145,7 +145,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEditorForSingleNestedProperty() {
|
||||
void testCustomEditorForSingleNestedProperty() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setSpouse(new TestBean());
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
@@ -164,7 +164,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEditorForAllNestedStringProperties() {
|
||||
void testCustomEditorForAllNestedStringProperties() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setSpouse(new TestBean());
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
@@ -183,7 +183,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultBooleanEditorForPrimitiveType() {
|
||||
void testDefaultBooleanEditorForPrimitiveType() {
|
||||
BooleanTestBean tb = new BooleanTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
|
||||
@@ -229,7 +229,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultBooleanEditorForWrapperType() {
|
||||
void testDefaultBooleanEditorForWrapperType() {
|
||||
BooleanTestBean tb = new BooleanTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
|
||||
@@ -239,28 +239,28 @@ public class CustomEditorTests {
|
||||
|
||||
bw.setPropertyValue("bool2", "false");
|
||||
assertThat(Boolean.FALSE.equals(bw.getPropertyValue("bool2"))).as("Correct bool2 value").isTrue();
|
||||
boolean condition3 = !tb.getBool2().booleanValue();
|
||||
boolean condition3 = !tb.getBool2();
|
||||
assertThat(condition3).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "on");
|
||||
assertThat(tb.getBool2().booleanValue()).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "off");
|
||||
boolean condition2 = !tb.getBool2().booleanValue();
|
||||
boolean condition2 = !tb.getBool2();
|
||||
assertThat(condition2).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "yes");
|
||||
assertThat(tb.getBool2().booleanValue()).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "no");
|
||||
boolean condition1 = !tb.getBool2().booleanValue();
|
||||
boolean condition1 = !tb.getBool2();
|
||||
assertThat(condition1).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "1");
|
||||
assertThat(tb.getBool2().booleanValue()).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "0");
|
||||
boolean condition = !tb.getBool2().booleanValue();
|
||||
boolean condition = !tb.getBool2();
|
||||
assertThat(condition).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "");
|
||||
@@ -268,7 +268,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomBooleanEditorWithAllowEmpty() {
|
||||
void testCustomBooleanEditorWithAllowEmpty() {
|
||||
BooleanTestBean tb = new BooleanTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(Boolean.class, new CustomBooleanEditor(true));
|
||||
@@ -279,37 +279,37 @@ public class CustomEditorTests {
|
||||
|
||||
bw.setPropertyValue("bool2", "false");
|
||||
assertThat(Boolean.FALSE.equals(bw.getPropertyValue("bool2"))).as("Correct bool2 value").isTrue();
|
||||
boolean condition3 = !tb.getBool2().booleanValue();
|
||||
boolean condition3 = !tb.getBool2();
|
||||
assertThat(condition3).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "on");
|
||||
assertThat(tb.getBool2().booleanValue()).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "off");
|
||||
boolean condition2 = !tb.getBool2().booleanValue();
|
||||
boolean condition2 = !tb.getBool2();
|
||||
assertThat(condition2).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "yes");
|
||||
assertThat(tb.getBool2().booleanValue()).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "no");
|
||||
boolean condition1 = !tb.getBool2().booleanValue();
|
||||
boolean condition1 = !tb.getBool2();
|
||||
assertThat(condition1).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "1");
|
||||
assertThat(tb.getBool2().booleanValue()).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "0");
|
||||
boolean condition = !tb.getBool2().booleanValue();
|
||||
boolean condition = !tb.getBool2();
|
||||
assertThat(condition).as("Correct bool2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("bool2", "");
|
||||
assertThat(bw.getPropertyValue("bool2") == null).as("Correct bool2 value").isTrue();
|
||||
assertThat(tb.getBool2() == null).as("Correct bool2 value").isTrue();
|
||||
assertThat(bw.getPropertyValue("bool2")).as("Correct bool2 value").isNull();
|
||||
assertThat(tb.getBool2()).as("Correct bool2 value").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomBooleanEditorWithSpecialTrueAndFalseStrings() throws Exception {
|
||||
void testCustomBooleanEditorWithSpecialTrueAndFalseStrings() throws Exception {
|
||||
String trueString = "pechorin";
|
||||
String falseString = "nash";
|
||||
|
||||
@@ -333,7 +333,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultNumberEditor() {
|
||||
void testDefaultNumberEditor() {
|
||||
NumberTestBean tb = new NumberTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
|
||||
@@ -350,34 +350,34 @@ public class CustomEditorTests {
|
||||
bw.setPropertyValue("double2", "6.1");
|
||||
bw.setPropertyValue("bigDecimal", "4.5");
|
||||
|
||||
assertThat(new Short("1").equals(bw.getPropertyValue("short1"))).as("Correct short1 value").isTrue();
|
||||
assertThat(Short.valueOf("1").equals(bw.getPropertyValue("short1"))).as("Correct short1 value").isTrue();
|
||||
assertThat(tb.getShort1() == 1).as("Correct short1 value").isTrue();
|
||||
assertThat(new Short("2").equals(bw.getPropertyValue("short2"))).as("Correct short2 value").isTrue();
|
||||
assertThat(new Short("2").equals(tb.getShort2())).as("Correct short2 value").isTrue();
|
||||
assertThat(new Integer("7").equals(bw.getPropertyValue("int1"))).as("Correct int1 value").isTrue();
|
||||
assertThat(Short.valueOf("2").equals(bw.getPropertyValue("short2"))).as("Correct short2 value").isTrue();
|
||||
assertThat(Short.valueOf("2").equals(tb.getShort2())).as("Correct short2 value").isTrue();
|
||||
assertThat(Integer.valueOf("7").equals(bw.getPropertyValue("int1"))).as("Correct int1 value").isTrue();
|
||||
assertThat(tb.getInt1() == 7).as("Correct int1 value").isTrue();
|
||||
assertThat(new Integer("8").equals(bw.getPropertyValue("int2"))).as("Correct int2 value").isTrue();
|
||||
assertThat(new Integer("8").equals(tb.getInt2())).as("Correct int2 value").isTrue();
|
||||
assertThat(new Long("5").equals(bw.getPropertyValue("long1"))).as("Correct long1 value").isTrue();
|
||||
assertThat(Integer.valueOf("8").equals(bw.getPropertyValue("int2"))).as("Correct int2 value").isTrue();
|
||||
assertThat(Integer.valueOf("8").equals(tb.getInt2())).as("Correct int2 value").isTrue();
|
||||
assertThat(Long.valueOf("5").equals(bw.getPropertyValue("long1"))).as("Correct long1 value").isTrue();
|
||||
assertThat(tb.getLong1() == 5).as("Correct long1 value").isTrue();
|
||||
assertThat(new Long("6").equals(bw.getPropertyValue("long2"))).as("Correct long2 value").isTrue();
|
||||
assertThat(new Long("6").equals(tb.getLong2())).as("Correct long2 value").isTrue();
|
||||
assertThat(Long.valueOf("6").equals(bw.getPropertyValue("long2"))).as("Correct long2 value").isTrue();
|
||||
assertThat(Long.valueOf("6").equals(tb.getLong2())).as("Correct long2 value").isTrue();
|
||||
assertThat(new BigInteger("3").equals(bw.getPropertyValue("bigInteger"))).as("Correct bigInteger value").isTrue();
|
||||
assertThat(new BigInteger("3").equals(tb.getBigInteger())).as("Correct bigInteger value").isTrue();
|
||||
assertThat(new Float("7.1").equals(bw.getPropertyValue("float1"))).as("Correct float1 value").isTrue();
|
||||
assertThat(new Float("7.1").equals(new Float(tb.getFloat1()))).as("Correct float1 value").isTrue();
|
||||
assertThat(new Float("8.1").equals(bw.getPropertyValue("float2"))).as("Correct float2 value").isTrue();
|
||||
assertThat(new Float("8.1").equals(tb.getFloat2())).as("Correct float2 value").isTrue();
|
||||
assertThat(new Double("5.1").equals(bw.getPropertyValue("double1"))).as("Correct double1 value").isTrue();
|
||||
assertThat(Float.valueOf("7.1").equals(bw.getPropertyValue("float1"))).as("Correct float1 value").isTrue();
|
||||
assertThat(Float.valueOf("7.1").equals(tb.getFloat1())).as("Correct float1 value").isTrue();
|
||||
assertThat(Float.valueOf("8.1").equals(bw.getPropertyValue("float2"))).as("Correct float2 value").isTrue();
|
||||
assertThat(Float.valueOf("8.1").equals(tb.getFloat2())).as("Correct float2 value").isTrue();
|
||||
assertThat(Double.valueOf("5.1").equals(bw.getPropertyValue("double1"))).as("Correct double1 value").isTrue();
|
||||
assertThat(tb.getDouble1() == 5.1).as("Correct double1 value").isTrue();
|
||||
assertThat(new Double("6.1").equals(bw.getPropertyValue("double2"))).as("Correct double2 value").isTrue();
|
||||
assertThat(new Double("6.1").equals(tb.getDouble2())).as("Correct double2 value").isTrue();
|
||||
assertThat(Double.valueOf("6.1").equals(bw.getPropertyValue("double2"))).as("Correct double2 value").isTrue();
|
||||
assertThat(Double.valueOf("6.1").equals(tb.getDouble2())).as("Correct double2 value").isTrue();
|
||||
assertThat(new BigDecimal("4.5").equals(bw.getPropertyValue("bigDecimal"))).as("Correct bigDecimal value").isTrue();
|
||||
assertThat(new BigDecimal("4.5").equals(tb.getBigDecimal())).as("Correct bigDecimal value").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomNumberEditorWithoutAllowEmpty() {
|
||||
void testCustomNumberEditorWithoutAllowEmpty() {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMAN);
|
||||
NumberTestBean tb = new NumberTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
@@ -407,34 +407,34 @@ public class CustomEditorTests {
|
||||
bw.setPropertyValue("double2", "6,1");
|
||||
bw.setPropertyValue("bigDecimal", "4,5");
|
||||
|
||||
assertThat(new Short("1").equals(bw.getPropertyValue("short1"))).as("Correct short1 value").isTrue();
|
||||
assertThat(bw.getPropertyValue("short1")).as("Correct short1 value").isEqualTo(Short.valueOf("1"));
|
||||
assertThat(tb.getShort1() == 1).as("Correct short1 value").isTrue();
|
||||
assertThat(new Short("2").equals(bw.getPropertyValue("short2"))).as("Correct short2 value").isTrue();
|
||||
assertThat(new Short("2").equals(tb.getShort2())).as("Correct short2 value").isTrue();
|
||||
assertThat(new Integer("7").equals(bw.getPropertyValue("int1"))).as("Correct int1 value").isTrue();
|
||||
assertThat(bw.getPropertyValue("short2")).as("Correct short2 value").isEqualTo(Short.valueOf("2"));
|
||||
assertThat(tb.getShort2()).as("Correct short2 value").isEqualTo(Short.valueOf("2"));
|
||||
assertThat(bw.getPropertyValue("int1")).as("Correct int1 value").isEqualTo(Integer.valueOf("7"));
|
||||
assertThat(tb.getInt1() == 7).as("Correct int1 value").isTrue();
|
||||
assertThat(new Integer("8").equals(bw.getPropertyValue("int2"))).as("Correct int2 value").isTrue();
|
||||
assertThat(new Integer("8").equals(tb.getInt2())).as("Correct int2 value").isTrue();
|
||||
assertThat(new Long("5").equals(bw.getPropertyValue("long1"))).as("Correct long1 value").isTrue();
|
||||
assertThat(bw.getPropertyValue("int2")).as("Correct int2 value").isEqualTo(Integer.valueOf("8"));
|
||||
assertThat(tb.getInt2()).as("Correct int2 value").isEqualTo(Integer.valueOf("8"));
|
||||
assertThat(bw.getPropertyValue("long1")).as("Correct long1 value").isEqualTo(Long.valueOf("5"));
|
||||
assertThat(tb.getLong1() == 5).as("Correct long1 value").isTrue();
|
||||
assertThat(new Long("6").equals(bw.getPropertyValue("long2"))).as("Correct long2 value").isTrue();
|
||||
assertThat(new Long("6").equals(tb.getLong2())).as("Correct long2 value").isTrue();
|
||||
assertThat(bw.getPropertyValue("long2")).as("Correct long2 value").isEqualTo(Long.valueOf("6"));
|
||||
assertThat(tb.getLong2()).as("Correct long2 value").isEqualTo(Long.valueOf("6"));
|
||||
assertThat(new BigInteger("3").equals(bw.getPropertyValue("bigInteger"))).as("Correct bigInteger value").isTrue();
|
||||
assertThat(new BigInteger("3").equals(tb.getBigInteger())).as("Correct bigInteger value").isTrue();
|
||||
assertThat(new Float("7.1").equals(bw.getPropertyValue("float1"))).as("Correct float1 value").isTrue();
|
||||
assertThat(new Float("7.1").equals(new Float(tb.getFloat1()))).as("Correct float1 value").isTrue();
|
||||
assertThat(new Float("8.1").equals(bw.getPropertyValue("float2"))).as("Correct float2 value").isTrue();
|
||||
assertThat(new Float("8.1").equals(tb.getFloat2())).as("Correct float2 value").isTrue();
|
||||
assertThat(new Double("5.1").equals(bw.getPropertyValue("double1"))).as("Correct double1 value").isTrue();
|
||||
assertThat(bw.getPropertyValue("float1")).as("Correct float1 value").isEqualTo(Float.valueOf("7.1"));
|
||||
assertThat(Float.valueOf(tb.getFloat1())).as("Correct float1 value").isEqualTo(Float.valueOf("7.1"));
|
||||
assertThat(bw.getPropertyValue("float2")).as("Correct float2 value").isEqualTo(Float.valueOf("8.1"));
|
||||
assertThat(tb.getFloat2()).as("Correct float2 value").isEqualTo(Float.valueOf("8.1"));
|
||||
assertThat(bw.getPropertyValue("double1")).as("Correct double1 value").isEqualTo(Double.valueOf("5.1"));
|
||||
assertThat(tb.getDouble1() == 5.1).as("Correct double1 value").isTrue();
|
||||
assertThat(new Double("6.1").equals(bw.getPropertyValue("double2"))).as("Correct double2 value").isTrue();
|
||||
assertThat(new Double("6.1").equals(tb.getDouble2())).as("Correct double2 value").isTrue();
|
||||
assertThat(bw.getPropertyValue("double2")).as("Correct double2 value").isEqualTo(Double.valueOf("6.1"));
|
||||
assertThat(tb.getDouble2()).as("Correct double2 value").isEqualTo(Double.valueOf("6.1"));
|
||||
assertThat(new BigDecimal("4.5").equals(bw.getPropertyValue("bigDecimal"))).as("Correct bigDecimal value").isTrue();
|
||||
assertThat(new BigDecimal("4.5").equals(tb.getBigDecimal())).as("Correct bigDecimal value").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomNumberEditorWithAllowEmpty() {
|
||||
void testCustomNumberEditorWithAllowEmpty() {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMAN);
|
||||
NumberTestBean tb = new NumberTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
@@ -443,10 +443,10 @@ public class CustomEditorTests {
|
||||
|
||||
bw.setPropertyValue("long1", "5");
|
||||
bw.setPropertyValue("long2", "6");
|
||||
assertThat(new Long("5").equals(bw.getPropertyValue("long1"))).as("Correct long1 value").isTrue();
|
||||
assertThat(Long.valueOf("5").equals(bw.getPropertyValue("long1"))).as("Correct long1 value").isTrue();
|
||||
assertThat(tb.getLong1() == 5).as("Correct long1 value").isTrue();
|
||||
assertThat(new Long("6").equals(bw.getPropertyValue("long2"))).as("Correct long2 value").isTrue();
|
||||
assertThat(new Long("6").equals(tb.getLong2())).as("Correct long2 value").isTrue();
|
||||
assertThat(Long.valueOf("6").equals(bw.getPropertyValue("long2"))).as("Correct long2 value").isTrue();
|
||||
assertThat(Long.valueOf("6").equals(tb.getLong2())).as("Correct long2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("long2", "");
|
||||
assertThat(bw.getPropertyValue("long2") == null).as("Correct long2 value").isTrue();
|
||||
@@ -458,7 +458,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomNumberEditorWithFrenchBigDecimal() throws Exception {
|
||||
void testCustomNumberEditorWithFrenchBigDecimal() throws Exception {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(Locale.FRENCH);
|
||||
NumberTestBean tb = new NumberTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
@@ -475,14 +475,14 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseShortGreaterThanMaxValueWithoutNumberFormat() {
|
||||
void testParseShortGreaterThanMaxValueWithoutNumberFormat() {
|
||||
CustomNumberEditor editor = new CustomNumberEditor(Short.class, true);
|
||||
assertThatExceptionOfType(NumberFormatException.class).as("greater than Short.MAX_VALUE + 1").isThrownBy(() ->
|
||||
editor.setAsText(String.valueOf(Short.MAX_VALUE + 1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testByteArrayPropertyEditor() {
|
||||
void testByteArrayPropertyEditor() {
|
||||
PrimitiveArrayBean bean = new PrimitiveArrayBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.setPropertyValue("byteArray", "myvalue");
|
||||
@@ -490,7 +490,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCharArrayPropertyEditor() {
|
||||
void testCharArrayPropertyEditor() {
|
||||
PrimitiveArrayBean bean = new PrimitiveArrayBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.setPropertyValue("charArray", "myvalue");
|
||||
@@ -498,7 +498,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCharacterEditor() {
|
||||
void testCharacterEditor() {
|
||||
CharBean cb = new CharBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(cb);
|
||||
|
||||
@@ -520,78 +520,78 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCharacterEditorWithAllowEmpty() {
|
||||
void testCharacterEditorWithAllowEmpty() {
|
||||
CharBean cb = new CharBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(cb);
|
||||
bw.registerCustomEditor(Character.class, new CharacterEditor(true));
|
||||
|
||||
bw.setPropertyValue("myCharacter", new Character('c'));
|
||||
assertThat(cb.getMyCharacter()).isEqualTo(new Character('c'));
|
||||
bw.setPropertyValue("myCharacter", 'c');
|
||||
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf('c'));
|
||||
|
||||
bw.setPropertyValue("myCharacter", "c");
|
||||
assertThat(cb.getMyCharacter()).isEqualTo(new Character('c'));
|
||||
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf('c'));
|
||||
|
||||
bw.setPropertyValue("myCharacter", "\u0041");
|
||||
assertThat(cb.getMyCharacter()).isEqualTo(new Character('A'));
|
||||
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf('A'));
|
||||
|
||||
bw.setPropertyValue("myCharacter", " ");
|
||||
assertThat(cb.getMyCharacter()).isEqualTo(new Character(' '));
|
||||
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf(' '));
|
||||
|
||||
bw.setPropertyValue("myCharacter", "");
|
||||
assertThat(cb.getMyCharacter()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCharacterEditorSetAsTextWithStringLongerThanOneCharacter() throws Exception {
|
||||
void testCharacterEditorSetAsTextWithStringLongerThanOneCharacter() throws Exception {
|
||||
PropertyEditor charEditor = new CharacterEditor(false);
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
charEditor.setAsText("ColdWaterCanyon"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCharacterEditorGetAsTextReturnsEmptyStringIfValueIsNull() throws Exception {
|
||||
void testCharacterEditorGetAsTextReturnsEmptyStringIfValueIsNull() throws Exception {
|
||||
PropertyEditor charEditor = new CharacterEditor(false);
|
||||
assertThat(charEditor.getAsText()).isEqualTo("");
|
||||
assertThat(charEditor.getAsText()).isEmpty();
|
||||
charEditor = new CharacterEditor(true);
|
||||
charEditor.setAsText(null);
|
||||
assertThat(charEditor.getAsText()).isEqualTo("");
|
||||
assertThat(charEditor.getAsText()).isEmpty();
|
||||
charEditor.setAsText("");
|
||||
assertThat(charEditor.getAsText()).isEqualTo("");
|
||||
assertThat(charEditor.getAsText()).isEmpty();
|
||||
charEditor.setAsText(" ");
|
||||
assertThat(charEditor.getAsText()).isEqualTo(" ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCharacterEditorSetAsTextWithNullNotAllowingEmptyAsNull() throws Exception {
|
||||
void testCharacterEditorSetAsTextWithNullNotAllowingEmptyAsNull() throws Exception {
|
||||
PropertyEditor charEditor = new CharacterEditor(false);
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
charEditor.setAsText(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassEditor() {
|
||||
void testClassEditor() {
|
||||
PropertyEditor classEditor = new ClassEditor();
|
||||
classEditor.setAsText(TestBean.class.getName());
|
||||
assertThat(classEditor.getValue()).isEqualTo(TestBean.class);
|
||||
assertThat(classEditor.getAsText()).isEqualTo(TestBean.class.getName());
|
||||
|
||||
classEditor.setAsText(null);
|
||||
assertThat(classEditor.getAsText()).isEqualTo("");
|
||||
assertThat(classEditor.getAsText()).isEmpty();
|
||||
classEditor.setAsText("");
|
||||
assertThat(classEditor.getAsText()).isEqualTo("");
|
||||
assertThat(classEditor.getAsText()).isEmpty();
|
||||
classEditor.setAsText("\t ");
|
||||
assertThat(classEditor.getAsText()).isEqualTo("");
|
||||
assertThat(classEditor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassEditorWithNonExistentClass() throws Exception {
|
||||
void testClassEditorWithNonExistentClass() throws Exception {
|
||||
PropertyEditor classEditor = new ClassEditor();
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
classEditor.setAsText("hairdresser.on.Fire"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassEditorWithArray() {
|
||||
void testClassEditorWithArray() {
|
||||
PropertyEditor classEditor = new ClassEditor();
|
||||
classEditor.setAsText("org.springframework.beans.testfixture.beans.TestBean[]");
|
||||
assertThat(classEditor.getValue()).isEqualTo(TestBean[].class);
|
||||
@@ -602,7 +602,7 @@ public class CustomEditorTests {
|
||||
* SPR_2165 - ClassEditor is inconsistent with multidimensional arrays
|
||||
*/
|
||||
@Test
|
||||
public void testGetAsTextWithTwoDimensionalArray() throws Exception {
|
||||
void testGetAsTextWithTwoDimensionalArray() throws Exception {
|
||||
String[][] chessboard = new String[8][8];
|
||||
ClassEditor editor = new ClassEditor();
|
||||
editor.setValue(chessboard.getClass());
|
||||
@@ -613,7 +613,7 @@ public class CustomEditorTests {
|
||||
* SPR_2165 - ClassEditor is inconsistent with multidimensional arrays
|
||||
*/
|
||||
@Test
|
||||
public void testGetAsTextWithRidiculousMultiDimensionalArray() throws Exception {
|
||||
void testGetAsTextWithRidiculousMultiDimensionalArray() throws Exception {
|
||||
String[][][][][] ridiculousChessboard = new String[8][4][0][1][3];
|
||||
ClassEditor editor = new ClassEditor();
|
||||
editor.setValue(ridiculousChessboard.getClass());
|
||||
@@ -621,7 +621,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileEditor() {
|
||||
void testFileEditor() {
|
||||
PropertyEditor fileEditor = new FileEditor();
|
||||
fileEditor.setAsText("file:myfile.txt");
|
||||
assertThat(fileEditor.getValue()).isEqualTo(new File("myfile.txt"));
|
||||
@@ -629,7 +629,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileEditorWithRelativePath() {
|
||||
void testFileEditorWithRelativePath() {
|
||||
PropertyEditor fileEditor = new FileEditor();
|
||||
try {
|
||||
fileEditor.setAsText("myfile.txt");
|
||||
@@ -641,7 +641,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileEditorWithAbsolutePath() {
|
||||
void testFileEditorWithAbsolutePath() {
|
||||
PropertyEditor fileEditor = new FileEditor();
|
||||
// testing on Windows
|
||||
if (new File("C:/myfile.txt").isAbsolute()) {
|
||||
@@ -656,18 +656,18 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocaleEditor() {
|
||||
void testLocaleEditor() {
|
||||
PropertyEditor localeEditor = new LocaleEditor();
|
||||
localeEditor.setAsText("en_CA");
|
||||
assertThat(localeEditor.getValue()).isEqualTo(Locale.CANADA);
|
||||
assertThat(localeEditor.getAsText()).isEqualTo("en_CA");
|
||||
|
||||
localeEditor = new LocaleEditor();
|
||||
assertThat(localeEditor.getAsText()).isEqualTo("");
|
||||
assertThat(localeEditor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPatternEditor() {
|
||||
void testPatternEditor() {
|
||||
final String REGEX = "a.*";
|
||||
|
||||
PropertyEditor patternEditor = new PatternEditor();
|
||||
@@ -676,15 +676,15 @@ public class CustomEditorTests {
|
||||
assertThat(patternEditor.getAsText()).isEqualTo(REGEX);
|
||||
|
||||
patternEditor = new PatternEditor();
|
||||
assertThat(patternEditor.getAsText()).isEqualTo("");
|
||||
assertThat(patternEditor.getAsText()).isEmpty();
|
||||
|
||||
patternEditor = new PatternEditor();
|
||||
patternEditor.setAsText(null);
|
||||
assertThat(patternEditor.getAsText()).isEqualTo("");
|
||||
assertThat(patternEditor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomBooleanEditor() {
|
||||
void testCustomBooleanEditor() {
|
||||
CustomBooleanEditor editor = new CustomBooleanEditor(false);
|
||||
|
||||
editor.setAsText("true");
|
||||
@@ -696,15 +696,15 @@ public class CustomEditorTests {
|
||||
assertThat(editor.getAsText()).isEqualTo("false");
|
||||
|
||||
editor.setValue(null);
|
||||
assertThat(editor.getValue()).isEqualTo(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
editor.setAsText(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomBooleanEditorWithEmptyAsNull() {
|
||||
void testCustomBooleanEditorWithEmptyAsNull() {
|
||||
CustomBooleanEditor editor = new CustomBooleanEditor(true);
|
||||
|
||||
editor.setAsText("true");
|
||||
@@ -716,34 +716,34 @@ public class CustomEditorTests {
|
||||
assertThat(editor.getAsText()).isEqualTo("false");
|
||||
|
||||
editor.setValue(null);
|
||||
assertThat(editor.getValue()).isEqualTo(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomDateEditor() {
|
||||
void testCustomDateEditor() {
|
||||
CustomDateEditor editor = new CustomDateEditor(null, false);
|
||||
editor.setValue(null);
|
||||
assertThat(editor.getValue()).isEqualTo(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomDateEditorWithEmptyAsNull() {
|
||||
void testCustomDateEditorWithEmptyAsNull() {
|
||||
CustomDateEditor editor = new CustomDateEditor(null, true);
|
||||
editor.setValue(null);
|
||||
assertThat(editor.getValue()).isEqualTo(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomDateEditorWithExactDateLength() {
|
||||
void testCustomDateEditorWithExactDateLength() {
|
||||
int maxLength = 10;
|
||||
String validDate = "01/01/2005";
|
||||
String invalidDate = "01/01/05";
|
||||
|
||||
assertThat(validDate.length() == maxLength).isTrue();
|
||||
assertThat(invalidDate.length() == maxLength).isFalse();
|
||||
assertThat(validDate).hasSize(maxLength);
|
||||
assertThat(invalidDate.length()).isNotEqualTo(maxLength);
|
||||
|
||||
CustomDateEditor editor = new CustomDateEditor(new SimpleDateFormat("MM/dd/yyyy"), true, maxLength);
|
||||
editor.setAsText(validDate);
|
||||
@@ -753,39 +753,39 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomNumberEditor() {
|
||||
void testCustomNumberEditor() {
|
||||
CustomNumberEditor editor = new CustomNumberEditor(Integer.class, false);
|
||||
editor.setAsText("5");
|
||||
assertThat(editor.getValue()).isEqualTo(5);
|
||||
assertThat(editor.getAsText()).isEqualTo("5");
|
||||
editor.setValue(null);
|
||||
assertThat(editor.getValue()).isEqualTo(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomNumberEditorWithHex() {
|
||||
void testCustomNumberEditorWithHex() {
|
||||
CustomNumberEditor editor = new CustomNumberEditor(Integer.class, false);
|
||||
editor.setAsText("0x" + Integer.toHexString(64));
|
||||
assertThat(editor.getValue()).isEqualTo(64);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomNumberEditorWithEmptyAsNull() {
|
||||
void testCustomNumberEditorWithEmptyAsNull() {
|
||||
CustomNumberEditor editor = new CustomNumberEditor(Integer.class, true);
|
||||
editor.setAsText("5");
|
||||
assertThat(editor.getValue()).isEqualTo(5);
|
||||
assertThat(editor.getAsText()).isEqualTo("5");
|
||||
editor.setAsText("");
|
||||
assertThat(editor.getValue()).isEqualTo(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
editor.setValue(null);
|
||||
assertThat(editor.getValue()).isEqualTo(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringTrimmerEditor() {
|
||||
void testStringTrimmerEditor() {
|
||||
StringTrimmerEditor editor = new StringTrimmerEditor(false);
|
||||
editor.setAsText("test");
|
||||
assertThat(editor.getValue()).isEqualTo("test");
|
||||
@@ -795,15 +795,15 @@ public class CustomEditorTests {
|
||||
assertThat(editor.getAsText()).isEqualTo("test");
|
||||
editor.setAsText("");
|
||||
assertThat(editor.getValue()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
editor.setValue(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
editor.setAsText(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringTrimmerEditorWithEmptyAsNull() {
|
||||
void testStringTrimmerEditorWithEmptyAsNull() {
|
||||
StringTrimmerEditor editor = new StringTrimmerEditor(true);
|
||||
editor.setAsText("test");
|
||||
assertThat(editor.getValue()).isEqualTo("test");
|
||||
@@ -812,14 +812,14 @@ public class CustomEditorTests {
|
||||
assertThat(editor.getValue()).isEqualTo("test");
|
||||
assertThat(editor.getAsText()).isEqualTo("test");
|
||||
editor.setAsText(" ");
|
||||
assertThat(editor.getValue()).isEqualTo(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
editor.setValue(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringTrimmerEditorWithCharsToDelete() {
|
||||
void testStringTrimmerEditorWithCharsToDelete() {
|
||||
StringTrimmerEditor editor = new StringTrimmerEditor("\r\n\f", false);
|
||||
editor.setAsText("te\ns\ft");
|
||||
assertThat(editor.getValue()).isEqualTo("test");
|
||||
@@ -829,13 +829,13 @@ public class CustomEditorTests {
|
||||
assertThat(editor.getAsText()).isEqualTo("test");
|
||||
editor.setAsText("");
|
||||
assertThat(editor.getValue()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
editor.setValue(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringTrimmerEditorWithCharsToDeleteAndEmptyAsNull() {
|
||||
void testStringTrimmerEditorWithCharsToDeleteAndEmptyAsNull() {
|
||||
StringTrimmerEditor editor = new StringTrimmerEditor("\r\n\f", true);
|
||||
editor.setAsText("te\ns\ft");
|
||||
assertThat(editor.getValue()).isEqualTo("test");
|
||||
@@ -844,14 +844,14 @@ public class CustomEditorTests {
|
||||
assertThat(editor.getValue()).isEqualTo("test");
|
||||
assertThat(editor.getAsText()).isEqualTo("test");
|
||||
editor.setAsText(" \n\f ");
|
||||
assertThat(editor.getValue()).isEqualTo(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
editor.setValue(null);
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexedPropertiesWithCustomEditorForType() {
|
||||
void testIndexedPropertiesWithCustomEditorForType() {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
||||
@@ -904,7 +904,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexedPropertiesWithCustomEditorForProperty() {
|
||||
void testIndexedPropertiesWithCustomEditorForProperty() {
|
||||
IndexedTestBean bean = new IndexedTestBean(false);
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(String.class, "array.name", new PropertyEditorSupport() {
|
||||
@@ -971,7 +971,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexedPropertiesWithIndividualCustomEditorForProperty() {
|
||||
void testIndexedPropertiesWithIndividualCustomEditorForProperty() {
|
||||
IndexedTestBean bean = new IndexedTestBean(false);
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(String.class, "array[0].name", new PropertyEditorSupport() {
|
||||
@@ -1056,7 +1056,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNestedIndexedPropertiesWithCustomEditorForProperty() {
|
||||
void testNestedIndexedPropertiesWithCustomEditorForProperty() {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
TestBean tb0 = bean.getArray()[0];
|
||||
TestBean tb1 = bean.getArray()[1];
|
||||
@@ -1140,7 +1140,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNestedIndexedPropertiesWithIndexedCustomEditorForProperty() {
|
||||
void testNestedIndexedPropertiesWithIndexedCustomEditorForProperty() {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
TestBean tb0 = bean.getArray()[0];
|
||||
TestBean tb1 = bean.getArray()[1];
|
||||
@@ -1191,7 +1191,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexedPropertiesWithDirectAccessAndPropertyEditors() {
|
||||
void testIndexedPropertiesWithDirectAccessAndPropertyEditors() {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(TestBean.class, "array", new PropertyEditorSupport() {
|
||||
@@ -1245,7 +1245,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexedPropertiesWithDirectAccessAndSpecificPropertyEditors() {
|
||||
void testIndexedPropertiesWithDirectAccessAndSpecificPropertyEditors() {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(TestBean.class, "array[0]", new PropertyEditorSupport() {
|
||||
@@ -1332,7 +1332,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexedPropertiesWithListPropertyEditor() {
|
||||
void testIndexedPropertiesWithListPropertyEditor() {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(List.class, "list", new PropertyEditorSupport() {
|
||||
@@ -1350,7 +1350,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConversionToOldCollections() throws PropertyVetoException {
|
||||
void testConversionToOldCollections() throws PropertyVetoException {
|
||||
OldCollectionsBean tb = new OldCollectionsBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(Vector.class, new CustomCollectionEditor(Vector.class));
|
||||
@@ -1367,7 +1367,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUninitializedArrayPropertyWithCustomEditor() {
|
||||
void testUninitializedArrayPropertyWithCustomEditor() {
|
||||
IndexedTestBean bean = new IndexedTestBean(false);
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
PropertyEditor pe = new CustomNumberEditor(Integer.class, true);
|
||||
@@ -1383,7 +1383,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArrayToArrayConversion() throws PropertyVetoException {
|
||||
void testArrayToArrayConversion() throws PropertyVetoException {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(TestBean.class, new PropertyEditorSupport() {
|
||||
@@ -1399,7 +1399,7 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArrayToStringConversion() throws PropertyVetoException {
|
||||
void testArrayToStringConversion() throws PropertyVetoException {
|
||||
TestBean tb = new TestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
||||
@@ -1408,16 +1408,16 @@ public class CustomEditorTests {
|
||||
setValue("-" + text + "-");
|
||||
}
|
||||
});
|
||||
bw.setPropertyValue("name", new String[] {"a", "b"});
|
||||
bw.setPropertyValue("name", new String[]{"a", "b"});
|
||||
assertThat(tb.getName()).isEqualTo("-a,b-");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassArrayEditorSunnyDay() throws Exception {
|
||||
void testClassArrayEditorSunnyDay() throws Exception {
|
||||
ClassArrayEditor classArrayEditor = new ClassArrayEditor();
|
||||
classArrayEditor.setAsText("java.lang.String,java.util.HashMap");
|
||||
Class<?>[] classes = (Class<?>[]) classArrayEditor.getValue();
|
||||
assertThat(classes.length).isEqualTo(2);
|
||||
assertThat(classes).hasSize(2);
|
||||
assertThat(classes[0]).isEqualTo(String.class);
|
||||
assertThat(classes[1]).isEqualTo(HashMap.class);
|
||||
assertThat(classArrayEditor.getAsText()).isEqualTo("java.lang.String,java.util.HashMap");
|
||||
@@ -1426,11 +1426,11 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassArrayEditorSunnyDayWithArrayTypes() throws Exception {
|
||||
void testClassArrayEditorSunnyDayWithArrayTypes() throws Exception {
|
||||
ClassArrayEditor classArrayEditor = new ClassArrayEditor();
|
||||
classArrayEditor.setAsText("java.lang.String[],java.util.Map[],int[],float[][][]");
|
||||
Class<?>[] classes = (Class<?>[]) classArrayEditor.getValue();
|
||||
assertThat(classes.length).isEqualTo(4);
|
||||
assertThat(classes).hasSize(4);
|
||||
assertThat(classes[0]).isEqualTo(String[].class);
|
||||
assertThat(classes[1]).isEqualTo(Map[].class);
|
||||
assertThat(classes[2]).isEqualTo(int[].class);
|
||||
@@ -1441,31 +1441,31 @@ public class CustomEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassArrayEditorSetAsTextWithNull() throws Exception {
|
||||
void testClassArrayEditorSetAsTextWithNull() throws Exception {
|
||||
ClassArrayEditor editor = new ClassArrayEditor();
|
||||
editor.setAsText(null);
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassArrayEditorSetAsTextWithEmptyString() throws Exception {
|
||||
void testClassArrayEditorSetAsTextWithEmptyString() throws Exception {
|
||||
ClassArrayEditor editor = new ClassArrayEditor();
|
||||
editor.setAsText("");
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassArrayEditorSetAsTextWithWhitespaceString() throws Exception {
|
||||
void testClassArrayEditorSetAsTextWithWhitespaceString() throws Exception {
|
||||
ClassArrayEditor editor = new ClassArrayEditor();
|
||||
editor.setAsText("\n");
|
||||
assertThat(editor.getValue()).isNull();
|
||||
assertThat(editor.getAsText()).isEqualTo("");
|
||||
assertThat(editor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCharsetEditor() throws Exception {
|
||||
void testCharsetEditor() throws Exception {
|
||||
CharsetEditor editor = new CharsetEditor();
|
||||
String name = "UTF-8";
|
||||
editor.setAsText(name);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
description = "Spring Context Indexer"
|
||||
|
||||
dependencies {
|
||||
testCompile(project(":spring-context"))
|
||||
testCompile("javax.inject:javax.inject")
|
||||
testCompile("javax.annotation:javax.annotation-api")
|
||||
testCompile("javax.transaction:javax.transaction-api")
|
||||
testCompile("org.eclipse.persistence:javax.persistence")
|
||||
testImplementation(project(":spring-context"))
|
||||
testImplementation("javax.inject:javax.inject")
|
||||
testImplementation("javax.annotation:javax.annotation-api")
|
||||
testImplementation("javax.transaction:javax.transaction-api")
|
||||
testImplementation("org.eclipse.persistence:javax.persistence")
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
description = "Spring Context Support"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-context"))
|
||||
compile(project(":spring-core"))
|
||||
api(project(":spring-beans"))
|
||||
api(project(":spring-context"))
|
||||
api(project(":spring-core"))
|
||||
optional(project(":spring-jdbc")) // for Quartz support
|
||||
optional(project(":spring-tx")) // for Quartz support
|
||||
optional("javax.activation:javax.activation-api")
|
||||
@@ -14,18 +14,18 @@ dependencies {
|
||||
optional("org.quartz-scheduler:quartz")
|
||||
optional("org.codehaus.fabric3.api:commonj")
|
||||
optional("org.freemarker:freemarker")
|
||||
testCompile(project(":spring-context"))
|
||||
testCompile(testFixtures(project(":spring-beans")))
|
||||
testCompile(testFixtures(project(":spring-context")))
|
||||
testCompile(testFixtures(project(":spring-core")))
|
||||
testCompile(testFixtures(project(":spring-tx")))
|
||||
testCompile("org.hsqldb:hsqldb")
|
||||
testCompile("org.hibernate:hibernate-validator")
|
||||
testCompile("javax.annotation:javax.annotation-api")
|
||||
testRuntime("org.ehcache:jcache")
|
||||
testRuntime("org.ehcache:ehcache")
|
||||
testRuntime("org.glassfish:javax.el")
|
||||
testRuntime("com.sun.mail:javax.mail")
|
||||
testImplementation(project(":spring-context"))
|
||||
testImplementation(testFixtures(project(":spring-beans")))
|
||||
testImplementation(testFixtures(project(":spring-context")))
|
||||
testImplementation(testFixtures(project(":spring-core")))
|
||||
testImplementation(testFixtures(project(":spring-tx")))
|
||||
testImplementation("org.hsqldb:hsqldb")
|
||||
testImplementation("org.hibernate:hibernate-validator")
|
||||
testImplementation("javax.annotation:javax.annotation-api")
|
||||
testRuntimeOnly("org.ehcache:jcache")
|
||||
testRuntimeOnly("org.ehcache:ehcache")
|
||||
testRuntimeOnly("org.glassfish:javax.el")
|
||||
testRuntimeOnly("com.sun.mail:javax.mail")
|
||||
testFixturesApi("org.junit.jupiter:junit-jupiter-api")
|
||||
testFixturesImplementation("org.assertj:assertj-core")
|
||||
testFixturesImplementation("org.mockito:mockito-core")
|
||||
|
||||
@@ -4,10 +4,10 @@ apply plugin: "groovy"
|
||||
apply plugin: "kotlin"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-aop"))
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-expression"))
|
||||
api(project(":spring-aop"))
|
||||
api(project(":spring-beans"))
|
||||
api(project(":spring-core"))
|
||||
api(project(":spring-expression"))
|
||||
optional(project(":spring-instrument"))
|
||||
optional("javax.annotation:javax.annotation-api")
|
||||
optional("javax.ejb:javax.ejb-api")
|
||||
@@ -26,22 +26,22 @@ dependencies {
|
||||
optional("org.jetbrains.kotlin:kotlin-reflect")
|
||||
optional("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
optional("org.reactivestreams:reactive-streams")
|
||||
testCompile(testFixtures(project(":spring-aop")))
|
||||
testCompile(testFixtures(project(":spring-beans")))
|
||||
testCompile(testFixtures(project(":spring-core")))
|
||||
testCompile("io.projectreactor:reactor-core")
|
||||
testCompile("org.codehaus.groovy:groovy-jsr223")
|
||||
testCompile("org.codehaus.groovy:groovy-test")
|
||||
testCompile("org.codehaus.groovy:groovy-xml")
|
||||
testCompile("org.apache.commons:commons-pool2")
|
||||
testCompile("javax.inject:javax.inject-tck")
|
||||
testCompile("org.awaitility:awaitility")
|
||||
testRuntime("javax.xml.bind:jaxb-api")
|
||||
testRuntime("org.glassfish:javax.el")
|
||||
testImplementation(testFixtures(project(":spring-aop")))
|
||||
testImplementation(testFixtures(project(":spring-beans")))
|
||||
testImplementation(testFixtures(project(":spring-core")))
|
||||
testImplementation("io.projectreactor:reactor-core")
|
||||
testImplementation("org.codehaus.groovy:groovy-jsr223")
|
||||
testImplementation("org.codehaus.groovy:groovy-test")
|
||||
testImplementation("org.codehaus.groovy:groovy-xml")
|
||||
testImplementation("org.apache.commons:commons-pool2")
|
||||
testImplementation("javax.inject:javax.inject-tck")
|
||||
testImplementation("org.awaitility:awaitility")
|
||||
testRuntimeOnly("javax.xml.bind:jaxb-api")
|
||||
testRuntimeOnly("org.glassfish:javax.el")
|
||||
// Substitute for javax.management:jmxremote_optional:1.0.1_04 (not available on Maven Central)
|
||||
testRuntime("org.glassfish.external:opendmk_jmxremote_optional_jar")
|
||||
testRuntime("org.javamoney:moneta")
|
||||
testRuntime("org.junit.vintage:junit-vintage-engine") // for @Inject TCK
|
||||
testRuntimeOnly("org.glassfish.external:opendmk_jmxremote_optional_jar")
|
||||
testRuntimeOnly("org.javamoney:moneta")
|
||||
testRuntimeOnly("org.junit.vintage:junit-vintage-engine") // for @Inject TCK
|
||||
testFixturesApi("org.junit.jupiter:junit-jupiter-api")
|
||||
testFixturesImplementation(testFixtures(project(":spring-beans")))
|
||||
testFixturesImplementation("com.google.code.findbugs:jsr305")
|
||||
|
||||
+6
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -38,9 +38,11 @@ import org.springframework.core.annotation.AliasFor;
|
||||
* replace the default one (see {@link #keyGenerator}).
|
||||
*
|
||||
* <p>If no value is found in the cache for the computed key, the target method
|
||||
* will be invoked and the returned value stored in the associated cache. Note
|
||||
* that Java8's {@code Optional} return types are automatically handled and its
|
||||
* content is stored in the cache if present.
|
||||
* will be invoked and the returned value will be stored in the associated cache.
|
||||
* Note that {@link java.util.Optional} return types are unwrapped automatically.
|
||||
* If an {@code Optional} value is {@linkplain java.util.Optional#isPresent()
|
||||
* present}, it will be stored in the associated cache. If an {@code Optional}
|
||||
* value is not present, {@code null} will be stored in the associated cache.
|
||||
*
|
||||
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom
|
||||
* <em>composed annotations</em> with attribute overrides.
|
||||
|
||||
+13
-17
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
/**
|
||||
* Enables Spring's scheduled task execution capability, similar to
|
||||
* functionality found in Spring's {@code <task:*>} XML namespace. To be used
|
||||
* on @{@link Configuration} classes as follows:
|
||||
* on {@link Configuration @Configuration} classes as follows:
|
||||
*
|
||||
* <pre class="code">
|
||||
* @Configuration
|
||||
@@ -41,8 +41,8 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
* // various @Bean definitions
|
||||
* }</pre>
|
||||
*
|
||||
* This enables detection of @{@link Scheduled} annotations on any Spring-managed
|
||||
* bean in the container. For example, given a class {@code MyTask}
|
||||
* <p>This enables detection of {@link Scheduled @Scheduled} annotations on any
|
||||
* Spring-managed bean in the container. For example, given a class {@code MyTask}:
|
||||
*
|
||||
* <pre class="code">
|
||||
* package com.myco.tasks;
|
||||
@@ -55,7 +55,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* the following configuration would ensure that {@code MyTask.work()} is called
|
||||
* <p>the following configuration would ensure that {@code MyTask.work()} is called
|
||||
* once every 1000 ms:
|
||||
*
|
||||
* <pre class="code">
|
||||
@@ -69,7 +69,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* Alternatively, if {@code MyTask} were annotated with {@code @Component}, the
|
||||
* <p>Alternatively, if {@code MyTask} were annotated with {@code @Component}, the
|
||||
* following configuration would ensure that its {@code @Scheduled} method is
|
||||
* invoked at the desired interval:
|
||||
*
|
||||
@@ -80,7 +80,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
* public class AppConfig {
|
||||
* }</pre>
|
||||
*
|
||||
* Methods annotated with {@code @Scheduled} may even be declared directly within
|
||||
* <p>Methods annotated with {@code @Scheduled} may even be declared directly within
|
||||
* {@code @Configuration} classes:
|
||||
*
|
||||
* <pre class="code">
|
||||
@@ -94,7 +94,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* <p>By default, will be searching for an associated scheduler definition: either
|
||||
* <p>By default, Spring will search for an associated scheduler definition: either
|
||||
* a unique {@link org.springframework.scheduling.TaskScheduler} bean in the context,
|
||||
* or a {@code TaskScheduler} bean named "taskScheduler" otherwise; the same lookup
|
||||
* will also be performed for a {@link java.util.concurrent.ScheduledExecutorService}
|
||||
@@ -141,11 +141,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
* public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
* taskRegistrar.setScheduler(taskScheduler());
|
||||
* taskRegistrar.addTriggerTask(
|
||||
* new Runnable() {
|
||||
* public void run() {
|
||||
* myTask().work();
|
||||
* }
|
||||
* },
|
||||
* () -> myTask().work(),
|
||||
* new CustomTrigger()
|
||||
* );
|
||||
* }
|
||||
@@ -165,7 +161,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
* configuration:
|
||||
*
|
||||
* <pre class="code">
|
||||
* <beans>
|
||||
* <beans>
|
||||
*
|
||||
* <task:annotation-driven scheduler="taskScheduler"/>
|
||||
*
|
||||
@@ -180,13 +176,13 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
* </beans>
|
||||
* </pre>
|
||||
*
|
||||
* The examples are equivalent save that in XML a <em>fixed-rate</em> period is used
|
||||
* <p>The examples are equivalent save that in XML a <em>fixed-rate</em> period is used
|
||||
* instead of a custom <em>{@code Trigger}</em> implementation; this is because the
|
||||
* {@code task:} namespace {@code scheduled} cannot easily expose such support. This is
|
||||
* but one demonstration how the code-based approach allows for maximum configurability
|
||||
* through direct access to actual componentry.<p>
|
||||
* through direct access to actual componentry.
|
||||
*
|
||||
* <b>Note: {@code @EnableScheduling} applies to its local application context only,
|
||||
* <p><b>Note: {@code @EnableScheduling} applies to its local application context only,
|
||||
* allowing for selective scheduling of beans at different levels.</b> Please redeclare
|
||||
* {@code @EnableScheduling} in each individual context, e.g. the common root web
|
||||
* application context and any separate {@code DispatcherServlet} application contexts,
|
||||
|
||||
+43
-17
@@ -22,6 +22,7 @@ import java.lang.annotation.Repeatable;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
|
||||
@@ -37,7 +38,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
* <p>Processing of {@code @Scheduled} annotations is performed by
|
||||
* registering a {@link ScheduledAnnotationBeanPostProcessor}. This can be
|
||||
* done manually or, more conveniently, through the {@code <task:annotation-driven/>}
|
||||
* element or @{@link EnableScheduling} annotation.
|
||||
* XML element or {@link EnableScheduling @EnableScheduling} annotation.
|
||||
*
|
||||
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom
|
||||
* <em>composed annotations</em> with attribute overrides.
|
||||
@@ -46,6 +47,8 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
* @author Juergen Hoeller
|
||||
* @author Dave Syer
|
||||
* @author Chris Beams
|
||||
* @author Victor Brown
|
||||
* @author Sam Brannen
|
||||
* @since 3.0
|
||||
* @see EnableScheduling
|
||||
* @see ScheduledAnnotationBeanPostProcessor
|
||||
@@ -101,52 +104,75 @@ public @interface Scheduled {
|
||||
String zone() default "";
|
||||
|
||||
/**
|
||||
* Execute the annotated method with a fixed period in milliseconds between the
|
||||
* end of the last invocation and the start of the next.
|
||||
* @return the delay in milliseconds
|
||||
* Execute the annotated method with a fixed period between the end of the
|
||||
* last invocation and the start of the next.
|
||||
* <p>The time unit is milliseconds by default but can be overridden via
|
||||
* {@link #timeUnit}.
|
||||
* @return the delay
|
||||
*/
|
||||
long fixedDelay() default -1;
|
||||
|
||||
/**
|
||||
* Execute the annotated method with a fixed period in milliseconds between the
|
||||
* end of the last invocation and the start of the next.
|
||||
* @return the delay in milliseconds as a String value, e.g. a placeholder
|
||||
* Execute the annotated method with a fixed period between the end of the
|
||||
* last invocation and the start of the next.
|
||||
* <p>The time unit is milliseconds by default but can be overridden via
|
||||
* {@link #timeUnit}.
|
||||
* @return the delay as a String value — for example, a placeholder
|
||||
* or a {@link java.time.Duration#parse java.time.Duration} compliant value
|
||||
* @since 3.2.2
|
||||
*/
|
||||
String fixedDelayString() default "";
|
||||
|
||||
/**
|
||||
* Execute the annotated method with a fixed period in milliseconds between
|
||||
* invocations.
|
||||
* @return the period in milliseconds
|
||||
* Execute the annotated method with a fixed period between invocations.
|
||||
* <p>The time unit is milliseconds by default but can be overridden via
|
||||
* {@link #timeUnit}.
|
||||
* @return the period
|
||||
*/
|
||||
long fixedRate() default -1;
|
||||
|
||||
/**
|
||||
* Execute the annotated method with a fixed period in milliseconds between
|
||||
* invocations.
|
||||
* @return the period in milliseconds as a String value, e.g. a placeholder
|
||||
* Execute the annotated method with a fixed period between invocations.
|
||||
* <p>The time unit is milliseconds by default but can be overridden via
|
||||
* {@link #timeUnit}.
|
||||
* @return the period as a String value — for example, a placeholder
|
||||
* or a {@link java.time.Duration#parse java.time.Duration} compliant value
|
||||
* @since 3.2.2
|
||||
*/
|
||||
String fixedRateString() default "";
|
||||
|
||||
/**
|
||||
* Number of milliseconds to delay before the first execution of a
|
||||
* Number of units of time to delay before the first execution of a
|
||||
* {@link #fixedRate} or {@link #fixedDelay} task.
|
||||
* @return the initial delay in milliseconds
|
||||
* <p>The time unit is milliseconds by default but can be overridden via
|
||||
* {@link #timeUnit}.
|
||||
* @return the initial
|
||||
* @since 3.2
|
||||
*/
|
||||
long initialDelay() default -1;
|
||||
|
||||
/**
|
||||
* Number of milliseconds to delay before the first execution of a
|
||||
* Number of units of time to delay before the first execution of a
|
||||
* {@link #fixedRate} or {@link #fixedDelay} task.
|
||||
* @return the initial delay in milliseconds as a String value, e.g. a placeholder
|
||||
* <p>The time unit is milliseconds by default but can be overridden via
|
||||
* {@link #timeUnit}.
|
||||
* @return the initial delay as a String value — for example, a placeholder
|
||||
* or a {@link java.time.Duration#parse java.time.Duration} compliant value
|
||||
* @since 3.2.2
|
||||
*/
|
||||
String initialDelayString() default "";
|
||||
|
||||
/**
|
||||
* The {@link TimeUnit} to use for {@link #fixedDelay}, {@link #fixedDelayString},
|
||||
* {@link #fixedRate}, {@link #fixedRateString}, {@link #initialDelay}, and
|
||||
* {@link #initialDelayString}.
|
||||
* <p>Defaults to {@link TimeUnit#MILLISECONDS}.
|
||||
* <p>This attribute is ignored for {@linkplain #cron() cron expressions}
|
||||
* and for {@link java.time.Duration} values supplied via {@link #fixedDelayString},
|
||||
* {@link #fixedRateString}, or {@link #initialDelayString}.
|
||||
* @return the {@code TimeUnit} to use
|
||||
* @since 5.3.10
|
||||
*/
|
||||
TimeUnit timeUnit() default TimeUnit.MILLISECONDS;
|
||||
|
||||
}
|
||||
|
||||
+31
-16
@@ -30,6 +30,7 @@ import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -77,9 +78,10 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
|
||||
/**
|
||||
* Bean post-processor that registers methods annotated with @{@link Scheduled}
|
||||
* to be invoked by a {@link org.springframework.scheduling.TaskScheduler} according
|
||||
* to the "fixedRate", "fixedDelay", or "cron" expression provided via the annotation.
|
||||
* Bean post-processor that registers methods annotated with
|
||||
* {@link Scheduled @Scheduled} to be invoked by a
|
||||
* {@link org.springframework.scheduling.TaskScheduler} according to the
|
||||
* "fixedRate", "fixedDelay", or "cron" expression provided via the annotation.
|
||||
*
|
||||
* <p>This post-processor is automatically registered by Spring's
|
||||
* {@code <task:annotation-driven>} XML element, and also by the
|
||||
@@ -87,13 +89,16 @@ import org.springframework.util.StringValueResolver;
|
||||
*
|
||||
* <p>Autodetects any {@link SchedulingConfigurer} instances in the container,
|
||||
* allowing for customization of the scheduler to be used or for fine-grained
|
||||
* control over task registration (e.g. registration of {@link Trigger} tasks.
|
||||
* See the @{@link EnableScheduling} javadocs for complete usage details.
|
||||
* control over task registration (e.g. registration of {@link Trigger} tasks).
|
||||
* See the {@link EnableScheduling @EnableScheduling} javadocs for complete usage
|
||||
* details.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
* @author Elizabeth Chatman
|
||||
* @author Victor Brown
|
||||
* @author Sam Brannen
|
||||
* @since 3.0
|
||||
* @see Scheduled
|
||||
* @see EnableScheduling
|
||||
@@ -150,7 +155,8 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
/**
|
||||
* Create a {@code ScheduledAnnotationBeanPostProcessor} delegating to the
|
||||
* specified {@link ScheduledTaskRegistrar}.
|
||||
* @param registrar the ScheduledTaskRegistrar to register @Scheduled tasks on
|
||||
* @param registrar the ScheduledTaskRegistrar to register {@code @Scheduled}
|
||||
* tasks on
|
||||
* @since 5.1
|
||||
*/
|
||||
public ScheduledAnnotationBeanPostProcessor(ScheduledTaskRegistrar registrar) {
|
||||
@@ -383,7 +389,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
|
||||
/**
|
||||
* Process the given {@code @Scheduled} method declaration on the given bean.
|
||||
* @param scheduled the @Scheduled annotation
|
||||
* @param scheduled the {@code @Scheduled} annotation
|
||||
* @param method the method that the annotation has been declared on
|
||||
* @param bean the target bean instance
|
||||
* @see #createRunnable(Object, Method)
|
||||
@@ -398,7 +404,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
Set<ScheduledTask> tasks = new LinkedHashSet<>(4);
|
||||
|
||||
// Determine initial delay
|
||||
long initialDelay = scheduled.initialDelay();
|
||||
long initialDelay = convertToMillis(scheduled.initialDelay(), scheduled.timeUnit());
|
||||
String initialDelayString = scheduled.initialDelayString();
|
||||
if (StringUtils.hasText(initialDelayString)) {
|
||||
Assert.isTrue(initialDelay < 0, "Specify 'initialDelay' or 'initialDelayString', not both");
|
||||
@@ -407,7 +413,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
}
|
||||
if (StringUtils.hasLength(initialDelayString)) {
|
||||
try {
|
||||
initialDelay = parseDelayAsLong(initialDelayString);
|
||||
initialDelay = convertToMillis(initialDelayString, scheduled.timeUnit());
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -446,12 +452,13 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
}
|
||||
|
||||
// Check fixed delay
|
||||
long fixedDelay = scheduled.fixedDelay();
|
||||
long fixedDelay = convertToMillis(scheduled.fixedDelay(), scheduled.timeUnit());
|
||||
if (fixedDelay >= 0) {
|
||||
Assert.isTrue(!processedSchedule, errorMessage);
|
||||
processedSchedule = true;
|
||||
tasks.add(this.registrar.scheduleFixedDelayTask(new FixedDelayTask(runnable, fixedDelay, initialDelay)));
|
||||
}
|
||||
|
||||
String fixedDelayString = scheduled.fixedDelayString();
|
||||
if (StringUtils.hasText(fixedDelayString)) {
|
||||
if (this.embeddedValueResolver != null) {
|
||||
@@ -461,7 +468,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
Assert.isTrue(!processedSchedule, errorMessage);
|
||||
processedSchedule = true;
|
||||
try {
|
||||
fixedDelay = parseDelayAsLong(fixedDelayString);
|
||||
fixedDelay = convertToMillis(fixedDelayString, scheduled.timeUnit());
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -472,7 +479,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
}
|
||||
|
||||
// Check fixed rate
|
||||
long fixedRate = scheduled.fixedRate();
|
||||
long fixedRate = convertToMillis(scheduled.fixedRate(), scheduled.timeUnit());
|
||||
if (fixedRate >= 0) {
|
||||
Assert.isTrue(!processedSchedule, errorMessage);
|
||||
processedSchedule = true;
|
||||
@@ -487,7 +494,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
Assert.isTrue(!processedSchedule, errorMessage);
|
||||
processedSchedule = true;
|
||||
try {
|
||||
fixedRate = parseDelayAsLong(fixedRateString);
|
||||
fixedRate = convertToMillis(fixedRateString, scheduled.timeUnit());
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -527,11 +534,19 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
return new ScheduledMethodRunnable(target, invocableMethod);
|
||||
}
|
||||
|
||||
private static long parseDelayAsLong(String value) throws RuntimeException {
|
||||
if (value.length() > 1 && (isP(value.charAt(0)) || isP(value.charAt(1)))) {
|
||||
private static long convertToMillis(long value, TimeUnit timeUnit) {
|
||||
return TimeUnit.MILLISECONDS.convert(value, timeUnit);
|
||||
}
|
||||
|
||||
private static long convertToMillis(String value, TimeUnit timeUnit) {
|
||||
if (isDurationString(value)) {
|
||||
return Duration.parse(value).toMillis();
|
||||
}
|
||||
return Long.parseLong(value);
|
||||
return convertToMillis(Long.parseLong(value), timeUnit);
|
||||
}
|
||||
|
||||
private static boolean isDurationString(String value) {
|
||||
return (value.length() > 1 && (isP(value.charAt(0)) || isP(value.charAt(1))));
|
||||
}
|
||||
|
||||
private static boolean isP(char ch) {
|
||||
|
||||
+9
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -19,17 +19,17 @@ package org.springframework.scheduling.annotation;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
|
||||
/**
|
||||
* Optional interface to be implemented by @{@link
|
||||
* org.springframework.context.annotation.Configuration Configuration} classes annotated
|
||||
* with @{@link EnableScheduling}. Typically used for setting a specific
|
||||
* Optional interface to be implemented by {@link
|
||||
* org.springframework.context.annotation.Configuration @Configuration} classes annotated
|
||||
* with {@link EnableScheduling @EnableScheduling}. Typically used for setting a specific
|
||||
* {@link org.springframework.scheduling.TaskScheduler TaskScheduler} bean to be used when
|
||||
* executing scheduled tasks or for registering scheduled tasks in a <em>programmatic</em>
|
||||
* fashion as opposed to the <em>declarative</em> approach of using the @{@link Scheduled}
|
||||
* annotation. For example, this may be necessary when implementing {@link
|
||||
* org.springframework.scheduling.Trigger Trigger}-based tasks, which are not supported by
|
||||
* the {@code @Scheduled} annotation.
|
||||
* fashion as opposed to the <em>declarative</em> approach of using the
|
||||
* {@link Scheduled @Scheduled} annotation. For example, this may be necessary
|
||||
* when implementing {@link org.springframework.scheduling.Trigger Trigger}-based
|
||||
* tasks, which are not supported by the {@code @Scheduled} annotation.
|
||||
*
|
||||
* <p>See @{@link EnableScheduling} for detailed usage examples.
|
||||
* <p>See {@link EnableScheduling @EnableScheduling} for detailed usage examples.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @since 3.1
|
||||
|
||||
@@ -162,13 +162,13 @@ class ProceedTestingAspect implements Ordered {
|
||||
|
||||
public Object doubleOrQuits(ProceedingJoinPoint pjp) throws Throwable {
|
||||
int value = ((Integer) pjp.getArgs()[0]).intValue();
|
||||
pjp.getArgs()[0] = new Integer(value * 2);
|
||||
pjp.getArgs()[0] = Integer.valueOf(value * 2);
|
||||
return pjp.proceed();
|
||||
}
|
||||
|
||||
public Object addOne(ProceedingJoinPoint pjp, Float value) throws Throwable {
|
||||
float fv = value.floatValue();
|
||||
return pjp.proceed(new Object[] {new Float(fv + 1.0F)});
|
||||
return pjp.proceed(new Object[] {Float.valueOf(fv + 1.0F)});
|
||||
}
|
||||
|
||||
public void captureStringArgument(JoinPoint tjp, String arg) {
|
||||
|
||||
+1
-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.
|
||||
@@ -20,8 +20,6 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
@@ -40,7 +38,6 @@ import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.config.MethodInvokingFactoryBean;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.testfixture.beans.ITestBean;
|
||||
import org.springframework.beans.testfixture.beans.TestBean;
|
||||
@@ -66,9 +63,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
public class AspectJAutoProxyCreatorTests {
|
||||
|
||||
private static final Log factoryLog = LogFactory.getLog(DefaultListableBeanFactory.class);
|
||||
|
||||
|
||||
@Test
|
||||
public void testAspectsAreApplied() {
|
||||
ClassPathXmlApplicationContext bf = newContext("aspects.xml");
|
||||
|
||||
+38
-38
@@ -79,7 +79,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
* @author Stephane Nicoll
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class AnnotationDrivenEventListenerTests {
|
||||
class AnnotationDrivenEventListenerTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void simpleEventJavaConfig() {
|
||||
void simpleEventJavaConfig() {
|
||||
load(TestEventListener.class);
|
||||
TestEvent event = new TestEvent(this, "test");
|
||||
TestEventListener listener = this.context.getBean(TestEventListener.class);
|
||||
@@ -120,7 +120,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleEventXmlConfig() {
|
||||
void simpleEventXmlConfig() {
|
||||
this.context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/context/event/simple-event-configuration.xml");
|
||||
|
||||
@@ -141,7 +141,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void metaAnnotationIsDiscovered() {
|
||||
void metaAnnotationIsDiscovered() {
|
||||
load(MetaAnnotationListenerTestBean.class);
|
||||
MetaAnnotationListenerTestBean bean = this.context.getBean(MetaAnnotationListenerTestBean.class);
|
||||
this.eventCollector.assertNoEventReceived(bean);
|
||||
@@ -159,7 +159,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contextEventsAreReceived() {
|
||||
void contextEventsAreReceived() {
|
||||
load(ContextEventListener.class);
|
||||
ContextEventListener listener = this.context.getBean(ContextEventListener.class);
|
||||
|
||||
@@ -175,7 +175,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodSignatureNoEvent() {
|
||||
void methodSignatureNoEvent() {
|
||||
@SuppressWarnings("resource")
|
||||
AnnotationConfigApplicationContext failingContext =
|
||||
new AnnotationConfigApplicationContext();
|
||||
@@ -189,7 +189,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleReply() {
|
||||
void simpleReply() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
AnotherTestEvent event = new AnotherTestEvent(this, "dummy");
|
||||
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
|
||||
@@ -204,7 +204,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullReplyIgnored() {
|
||||
void nullReplyIgnored() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
AnotherTestEvent event = new AnotherTestEvent(this, null); // No response
|
||||
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
|
||||
@@ -219,7 +219,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void arrayReply() {
|
||||
void arrayReply() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
AnotherTestEvent event = new AnotherTestEvent(this, new String[]{"first", "second"});
|
||||
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
|
||||
@@ -234,7 +234,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void collectionReply() {
|
||||
void collectionReply() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
Set<Object> replies = new LinkedHashSet<>();
|
||||
replies.add("first");
|
||||
@@ -253,7 +253,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void collectionReplyNullValue() {
|
||||
void collectionReplyNullValue() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
AnotherTestEvent event = new AnotherTestEvent(this, Arrays.asList(null, "test"));
|
||||
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
|
||||
@@ -268,7 +268,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listenableFutureReply() {
|
||||
void listenableFutureReply() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
SettableListenableFuture<String> future = new SettableListenableFuture<>();
|
||||
future.set("dummy");
|
||||
@@ -285,7 +285,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void completableFutureReply() {
|
||||
void completableFutureReply() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
AnotherTestEvent event = new AnotherTestEvent(this, CompletableFuture.completedFuture("dummy"));
|
||||
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
|
||||
@@ -300,7 +300,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void monoReply() {
|
||||
void monoReply() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
AnotherTestEvent event = new AnotherTestEvent(this, Mono.just("dummy"));
|
||||
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
|
||||
@@ -315,7 +315,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fluxReply() {
|
||||
void fluxReply() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
AnotherTestEvent event = new AnotherTestEvent(this, Flux.just("dummy1", "dummy2"));
|
||||
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
|
||||
@@ -330,7 +330,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void eventListenerWorksWithSimpleInterfaceProxy() {
|
||||
void eventListenerWorksWithSimpleInterfaceProxy() {
|
||||
load(ScopedProxyTestBean.class);
|
||||
|
||||
SimpleService proxy = this.context.getBean(SimpleService.class);
|
||||
@@ -347,7 +347,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void eventListenerWorksWithAnnotatedInterfaceProxy() {
|
||||
void eventListenerWorksWithAnnotatedInterfaceProxy() {
|
||||
load(AnnotatedProxyTestBean.class);
|
||||
|
||||
AnnotatedSimpleService proxy = this.context.getBean(AnnotatedSimpleService.class);
|
||||
@@ -364,7 +364,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void eventListenerWorksWithCglibProxy() {
|
||||
void eventListenerWorksWithCglibProxy() {
|
||||
load(CglibProxyTestBean.class);
|
||||
|
||||
CglibProxyTestBean proxy = this.context.getBean(CglibProxyTestBean.class);
|
||||
@@ -381,14 +381,14 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void privateMethodOnCglibProxyFails() {
|
||||
void privateMethodOnCglibProxyFails() {
|
||||
assertThatExceptionOfType(BeanInitializationException.class).isThrownBy(() ->
|
||||
load(CglibProxyWithPrivateMethod.class))
|
||||
.withCauseInstanceOf(IllegalStateException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void eventListenerWorksWithCustomScope() {
|
||||
void eventListenerWorksWithCustomScope() {
|
||||
load(CustomScopeTestBean.class);
|
||||
CustomScope customScope = new CustomScope();
|
||||
this.context.getBeanFactory().registerScope("custom", customScope);
|
||||
@@ -417,7 +417,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asyncProcessingApplied() throws InterruptedException {
|
||||
void asyncProcessingApplied() throws InterruptedException {
|
||||
loadAsync(AsyncEventListener.class);
|
||||
|
||||
String threadName = Thread.currentThread().getName();
|
||||
@@ -432,7 +432,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asyncProcessingAppliedWithInterfaceProxy() throws InterruptedException {
|
||||
void asyncProcessingAppliedWithInterfaceProxy() throws InterruptedException {
|
||||
doLoad(AsyncConfigurationWithInterfaces.class, SimpleProxyTestBean.class);
|
||||
|
||||
String threadName = Thread.currentThread().getName();
|
||||
@@ -447,7 +447,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asyncProcessingAppliedWithScopedProxy() throws InterruptedException {
|
||||
void asyncProcessingAppliedWithScopedProxy() throws InterruptedException {
|
||||
doLoad(AsyncConfigurationWithInterfaces.class, ScopedProxyTestBean.class);
|
||||
|
||||
String threadName = Thread.currentThread().getName();
|
||||
@@ -462,7 +462,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exceptionPropagated() {
|
||||
void exceptionPropagated() {
|
||||
load(ExceptionEventListener.class);
|
||||
TestEvent event = new TestEvent(this, "fail");
|
||||
ExceptionEventListener listener = this.context.getBean(ExceptionEventListener.class);
|
||||
@@ -475,7 +475,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exceptionNotPropagatedWithAsync() throws InterruptedException {
|
||||
void exceptionNotPropagatedWithAsync() throws InterruptedException {
|
||||
loadAsync(ExceptionEventListener.class);
|
||||
AnotherTestEvent event = new AnotherTestEvent(this, "fail");
|
||||
ExceptionEventListener listener = this.context.getBean(ExceptionEventListener.class);
|
||||
@@ -489,7 +489,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listenerWithSimplePayload() {
|
||||
void listenerWithSimplePayload() {
|
||||
load(TestEventListener.class);
|
||||
TestEventListener listener = this.context.getBean(TestEventListener.class);
|
||||
|
||||
@@ -500,7 +500,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listenerWithNonMatchingPayload() {
|
||||
void listenerWithNonMatchingPayload() {
|
||||
load(TestEventListener.class);
|
||||
TestEventListener listener = this.context.getBean(TestEventListener.class);
|
||||
|
||||
@@ -511,7 +511,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replyWithPayload() {
|
||||
void replyWithPayload() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
AnotherTestEvent event = new AnotherTestEvent(this, "String");
|
||||
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
|
||||
@@ -527,7 +527,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listenerWithGenericApplicationEvent() {
|
||||
void listenerWithGenericApplicationEvent() {
|
||||
load(GenericEventListener.class);
|
||||
GenericEventListener listener = this.context.getBean(GenericEventListener.class);
|
||||
|
||||
@@ -538,7 +538,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listenerWithResolvableTypeEvent() {
|
||||
void listenerWithResolvableTypeEvent() {
|
||||
load(ResolvableTypeEventListener.class);
|
||||
ResolvableTypeEventListener listener = this.context.getBean(ResolvableTypeEventListener.class);
|
||||
|
||||
@@ -550,7 +550,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listenerWithResolvableTypeEventWrongGeneric() {
|
||||
void listenerWithResolvableTypeEventWrongGeneric() {
|
||||
load(ResolvableTypeEventListener.class);
|
||||
ResolvableTypeEventListener listener = this.context.getBean(ResolvableTypeEventListener.class);
|
||||
|
||||
@@ -562,12 +562,12 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void conditionMatch() {
|
||||
void conditionMatch() {
|
||||
validateConditionMatch(ConditionalEventListener.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void conditionMatchWithProxy() {
|
||||
void conditionMatchWithProxy() {
|
||||
validateConditionMatch(ConditionalEventListener.class, MethodValidationPostProcessor.class);
|
||||
}
|
||||
|
||||
@@ -600,7 +600,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void conditionDoesNotMatch() {
|
||||
void conditionDoesNotMatch() {
|
||||
long maxLong = Long.MAX_VALUE;
|
||||
load(ConditionalEventListener.class);
|
||||
TestEvent event = new TestEvent(this, "KO");
|
||||
@@ -625,7 +625,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void orderedListeners() {
|
||||
void orderedListeners() {
|
||||
load(OrderedTestListener.class);
|
||||
OrderedTestListener listener = this.context.getBean(OrderedTestListener.class);
|
||||
|
||||
@@ -635,7 +635,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test @Disabled // SPR-15122
|
||||
public void listenersReceiveEarlyEvents() {
|
||||
void listenersReceiveEarlyEvents() {
|
||||
load(EventOnPostConstruct.class, OrderedTestListener.class);
|
||||
OrderedTestListener listener = this.context.getBean(OrderedTestListener.class);
|
||||
|
||||
@@ -643,7 +643,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void missingListenerBeanIgnored() {
|
||||
void missingListenerBeanIgnored() {
|
||||
load(MissingEventListener.class);
|
||||
context.getBean(UseMissingEventListener.class);
|
||||
context.getBean(ApplicationEventMulticaster.class).multicastEvent(new TestEvent(this));
|
||||
@@ -697,7 +697,7 @@ public class AnnotationDrivenEventListenerTests {
|
||||
static class TestConditionEvaluator {
|
||||
|
||||
public boolean valid(Double ratio) {
|
||||
return new Double(42).equals(ratio);
|
||||
return Double.valueOf(42).equals(ratio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-7
@@ -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.
|
||||
@@ -28,8 +28,6 @@ import java.security.Permission;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
@@ -40,7 +38,6 @@ import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.Scope;
|
||||
import org.springframework.beans.factory.config.TypedStringValue;
|
||||
import org.springframework.beans.factory.support.AutowireCandidateQualifier;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.GenericBeanDefinition;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.testfixture.beans.TestBean;
|
||||
@@ -64,9 +61,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class ApplicationContextExpressionTests {
|
||||
|
||||
private static final Log factoryLog = LogFactory.getLog(DefaultListableBeanFactory.class);
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void genericApplicationContext() throws Exception {
|
||||
|
||||
@@ -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.
|
||||
@@ -341,10 +341,10 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
|
||||
|
||||
assertIsRegistered("Bean instance not registered", objectName);
|
||||
|
||||
Object result = server.invoke(objectName, "add", new Object[] {new Integer(2), new Integer(3)}, new String[] {
|
||||
Object result = server.invoke(objectName, "add", new Object[] {2, 3}, new String[] {
|
||||
int.class.getName(), int.class.getName()});
|
||||
|
||||
assertThat(new Integer(5)).as("Incorrect result return from add").isEqualTo(result);
|
||||
assertThat(Integer.valueOf(5)).as("Incorrect result return from add").isEqualTo(result);
|
||||
assertThat(server.getAttribute(objectName, "Name")).as("Incorrect attribute value").isEqualTo(name);
|
||||
|
||||
server.setAttribute(objectName, new Attribute("Name", otherName));
|
||||
@@ -352,7 +352,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBonaFideMBeanIsNotExportedWhenAutodetectIsTotallyTurnedOff() throws Exception {
|
||||
void testBonaFideMBeanIsNotExportedWhenAutodetectIsTotallyTurnedOff() {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
|
||||
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
|
||||
factory.registerBeanDefinition("^&_invalidObjectName_(*", builder.getBeanDefinition());
|
||||
|
||||
+11
-11
@@ -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.
|
||||
@@ -60,7 +60,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
|
||||
IJmxTestBean bean = getBean();
|
||||
assertThat(bean).isNotNull();
|
||||
MBeanInfo inf = getMBeanInfo();
|
||||
assertThat(inf.getOperations().length).as("Incorrect number of operations registered").isEqualTo(getExpectedOperationCount());
|
||||
assertThat(inf.getOperations()).as("Incorrect number of operations registered").hasSize(getExpectedOperationCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,7 +68,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
|
||||
IJmxTestBean bean = getBean();
|
||||
assertThat(bean).isNotNull();
|
||||
MBeanInfo inf = getMBeanInfo();
|
||||
assertThat(inf.getAttributes().length).as("Incorrect number of attributes registered").isEqualTo(getExpectedAttributeCount());
|
||||
assertThat(inf.getAttributes()).as("Incorrect number of attributes registered").hasSize(getExpectedAttributeCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +81,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
|
||||
public void testGetMBeanAttributeInfo() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
MBeanAttributeInfo[] inf = info.getAttributes();
|
||||
assertThat(inf.length).as("Invalid number of Attributes returned").isEqualTo(getExpectedAttributeCount());
|
||||
assertThat(inf).as("Invalid number of Attributes returned").hasSize(getExpectedAttributeCount());
|
||||
|
||||
for (int x = 0; x < inf.length; x++) {
|
||||
assertThat(inf[x]).as("MBeanAttributeInfo should not be null").isNotNull();
|
||||
@@ -93,7 +93,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
|
||||
public void testGetMBeanOperationInfo() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
MBeanOperationInfo[] inf = info.getOperations();
|
||||
assertThat(inf.length).as("Invalid number of Operations returned").isEqualTo(getExpectedOperationCount());
|
||||
assertThat(inf).as("Invalid number of Operations returned").hasSize(getExpectedOperationCount());
|
||||
|
||||
for (int x = 0; x < inf.length; x++) {
|
||||
assertThat(inf[x]).as("MBeanOperationInfo should not be null").isNotNull();
|
||||
@@ -128,8 +128,8 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
|
||||
public void testOperationInvocation() throws Exception{
|
||||
ObjectName objectName = ObjectNameManager.getInstance(getObjectName());
|
||||
Object result = getServer().invoke(objectName, "add",
|
||||
new Object[] {new Integer(20), new Integer(30)}, new String[] {"int", "int"});
|
||||
assertThat(result).as("Incorrect result").isEqualTo(new Integer(50));
|
||||
new Object[] {20, 30}, new String[] {"int", "int"});
|
||||
assertThat(result).as("Incorrect result").isEqualTo(50);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,12 +150,12 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
|
||||
|
||||
ModelMBeanOperationInfo get = info.getOperation("getName");
|
||||
assertThat(get).as("get operation should not be null").isNotNull();
|
||||
assertThat(new Integer(4)).as("get operation should have visibility of four").isEqualTo(get.getDescriptor().getFieldValue("visibility"));
|
||||
assertThat(Integer.valueOf(4)).as("get operation should have visibility of four").isEqualTo(get.getDescriptor().getFieldValue("visibility"));
|
||||
assertThat(get.getDescriptor().getFieldValue("role")).as("get operation should have role \"getter\"").isEqualTo("getter");
|
||||
|
||||
ModelMBeanOperationInfo set = info.getOperation("setName");
|
||||
assertThat(set).as("set operation should not be null").isNotNull();
|
||||
assertThat(new Integer(4)).as("set operation should have visibility of four").isEqualTo(set.getDescriptor().getFieldValue("visibility"));
|
||||
assertThat(Integer.valueOf(4)).as("set operation should have visibility of four").isEqualTo(set.getDescriptor().getFieldValue("visibility"));
|
||||
assertThat(set.getDescriptor().getFieldValue("role")).as("set operation should have role \"setter\"").isEqualTo("setter");
|
||||
}
|
||||
|
||||
@@ -163,12 +163,12 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
|
||||
public void testNotificationMetadata() throws Exception {
|
||||
ModelMBeanInfo info = (ModelMBeanInfo) getMBeanInfo();
|
||||
MBeanNotificationInfo[] notifications = info.getNotifications();
|
||||
assertThat(notifications.length).as("Incorrect number of notifications").isEqualTo(1);
|
||||
assertThat(notifications).as("Incorrect number of notifications").hasSize(1);
|
||||
assertThat(notifications[0].getName()).as("Incorrect notification name").isEqualTo("My Notification");
|
||||
|
||||
String[] notifTypes = notifications[0].getNotifTypes();
|
||||
|
||||
assertThat(notifTypes.length).as("Incorrect number of notification types").isEqualTo(2);
|
||||
assertThat(notifTypes).as("Incorrect number of notification types").hasSize(2);
|
||||
assertThat(notifTypes[0]).as("Notification type.foo not found").isEqualTo("type.foo");
|
||||
assertThat(notifTypes[1]).as("Notification type.bar not found").isEqualTo("type.bar");
|
||||
}
|
||||
|
||||
+200
-96
@@ -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.
|
||||
@@ -29,9 +29,16 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ParameterContext;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.converter.ArgumentConversionException;
|
||||
import org.junit.jupiter.params.converter.ArgumentConverter;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.aop.scope.ScopedProxyUtils;
|
||||
@@ -60,29 +67,37 @@ import org.springframework.validation.beanvalidation.MethodValidationPostProcess
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.SoftAssertions.assertSoftly;
|
||||
|
||||
/**
|
||||
* Tests for {@link ScheduledAnnotationBeanPostProcessor}.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
* @author Sam Brannen
|
||||
* @author Stevo Slavić
|
||||
* @author Victor Brown
|
||||
*/
|
||||
public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
class ScheduledAnnotationBeanPostProcessorTests {
|
||||
|
||||
private final StaticApplicationContext context = new StaticApplicationContext();
|
||||
|
||||
|
||||
@AfterEach
|
||||
public void closeContextAfterTest() {
|
||||
void closeContextAfterTest() {
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void fixedDelayTask() {
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"FixedDelay, 5000",
|
||||
"FixedDelayInSeconds, 5000",
|
||||
"FixedDelayInMinutes, 180000"
|
||||
})
|
||||
void fixedDelayTask(@NameToClass Class<?> beanClass, long expectedInterval) {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(FixedDelayTestBean.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(beanClass);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
context.registerBeanDefinition("target", targetDefinition);
|
||||
context.refresh();
|
||||
@@ -96,7 +111,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IntervalTask> fixedDelayTasks = (List<IntervalTask>)
|
||||
new DirectFieldAccessor(registrar).getPropertyValue("fixedDelayTasks");
|
||||
assertThat(fixedDelayTasks.size()).isEqualTo(1);
|
||||
assertThat(fixedDelayTasks).hasSize(1);
|
||||
IntervalTask task = fixedDelayTasks.get(0);
|
||||
ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
|
||||
Object targetObject = runnable.getTarget();
|
||||
@@ -104,13 +119,18 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
assertThat(targetObject).isEqualTo(target);
|
||||
assertThat(targetMethod.getName()).isEqualTo("fixedDelay");
|
||||
assertThat(task.getInitialDelay()).isEqualTo(0L);
|
||||
assertThat(task.getInterval()).isEqualTo(5000L);
|
||||
assertThat(task.getInterval()).isEqualTo(expectedInterval);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedRateTask() {
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"FixedRate, 3000",
|
||||
"FixedRateInSeconds, 5000",
|
||||
"FixedRateInMinutes, 180000"
|
||||
})
|
||||
void fixedRateTask(@NameToClass Class<?> beanClass, long expectedInterval) {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(FixedRateTestBean.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(beanClass);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
context.registerBeanDefinition("target", targetDefinition);
|
||||
context.refresh();
|
||||
@@ -131,14 +151,21 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
Method targetMethod = runnable.getMethod();
|
||||
assertThat(targetObject).isEqualTo(target);
|
||||
assertThat(targetMethod.getName()).isEqualTo("fixedRate");
|
||||
assertThat(task.getInitialDelay()).isEqualTo(0L);
|
||||
assertThat(task.getInterval()).isEqualTo(3000L);
|
||||
assertSoftly(softly -> {
|
||||
softly.assertThat(task.getInitialDelay()).as("initial delay").isEqualTo(0);
|
||||
softly.assertThat(task.getInterval()).as("interval").isEqualTo(expectedInterval);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedRateTaskWithInitialDelay() {
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"FixedRateWithInitialDelay, 1000, 3000",
|
||||
"FixedRateWithInitialDelayInSeconds, 5000, 3000",
|
||||
"FixedRateWithInitialDelayInMinutes, 60000, 180000"
|
||||
})
|
||||
void fixedRateTaskWithInitialDelay(@NameToClass Class<?> beanClass, long expectedInitialDelay, long expectedInterval) {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(FixedRateWithInitialDelayTestBean.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(beanClass);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
context.registerBeanDefinition("target", targetDefinition);
|
||||
context.refresh();
|
||||
@@ -159,40 +186,42 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
Method targetMethod = runnable.getMethod();
|
||||
assertThat(targetObject).isEqualTo(target);
|
||||
assertThat(targetMethod.getName()).isEqualTo("fixedRate");
|
||||
assertThat(task.getInitialDelay()).isEqualTo(1000L);
|
||||
assertThat(task.getInterval()).isEqualTo(3000L);
|
||||
assertSoftly(softly -> {
|
||||
softly.assertThat(task.getInitialDelay()).as("initial delay").isEqualTo(expectedInitialDelay);
|
||||
softly.assertThat(task.getInterval()).as("interval").isEqualTo(expectedInterval);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalFixedRatesWithRepeatedScheduledAnnotation() {
|
||||
void severalFixedRatesWithRepeatedScheduledAnnotation() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(SeveralFixedRatesWithRepeatedScheduledAnnotationTestBean.class);
|
||||
severalFixedRates(context, processorDefinition, targetDefinition);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalFixedRatesWithSchedulesContainerAnnotation() {
|
||||
void severalFixedRatesWithSchedulesContainerAnnotation() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(SeveralFixedRatesWithSchedulesContainerAnnotationTestBean.class);
|
||||
severalFixedRates(context, processorDefinition, targetDefinition);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalFixedRatesOnBaseClass() {
|
||||
void severalFixedRatesOnBaseClass() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(FixedRatesSubBean.class);
|
||||
severalFixedRates(context, processorDefinition, targetDefinition);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalFixedRatesOnDefaultMethod() {
|
||||
void severalFixedRatesOnDefaultMethod() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(FixedRatesDefaultBean.class);
|
||||
severalFixedRates(context, processorDefinition, targetDefinition);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalFixedRatesAgainstNestedCglibProxy() {
|
||||
void severalFixedRatesAgainstNestedCglibProxy() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(SeveralFixedRatesWithRepeatedScheduledAnnotationTestBean.class);
|
||||
targetDefinition.setFactoryMethodName("nestedProxy");
|
||||
@@ -235,7 +264,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cronTask() {
|
||||
void cronTask() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(CronTestBean.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
@@ -262,7 +291,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cronTaskWithZone() {
|
||||
void cronTaskWithZone() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(CronWithTimezoneTestBean.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
@@ -308,7 +337,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cronTaskWithInvalidZone() {
|
||||
void cronTaskWithInvalidZone() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(CronWithInvalidTimezoneTestBean.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
@@ -318,7 +347,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cronTaskWithMethodValidation() {
|
||||
void cronTaskWithMethodValidation() {
|
||||
BeanDefinition validationDefinition = new RootBeanDefinition(MethodValidationPostProcessor.class);
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(CronTestBean.class);
|
||||
@@ -330,7 +359,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cronTaskWithScopedProxy() {
|
||||
void cronTaskWithScopedProxy() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
new AnnotatedBeanDefinitionReader(context).register(ProxiedCronTestBean.class, ProxiedCronTestBeanDependent.class);
|
||||
@@ -355,7 +384,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void metaAnnotationWithFixedRate() {
|
||||
void metaAnnotationWithFixedRate() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(MetaAnnotationFixedRateTestBean.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
@@ -382,7 +411,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void composedAnnotationWithInitialDelayAndFixedRate() {
|
||||
void composedAnnotationWithInitialDelayAndFixedRate() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(ComposedAnnotationFixedRateTestBean.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
@@ -410,7 +439,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void metaAnnotationWithCronExpression() {
|
||||
void metaAnnotationWithCronExpression() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(MetaAnnotationCronTestBean.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
@@ -437,7 +466,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyPlaceholderWithCron() {
|
||||
void propertyPlaceholderWithCron() {
|
||||
String businessHoursCronExpression = "0 0 9-17 * * MON-FRI";
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
|
||||
@@ -470,7 +499,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyPlaceholderWithInactiveCron() {
|
||||
void propertyPlaceholderWithInactiveCron() {
|
||||
String businessHoursCronExpression = "-";
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
|
||||
@@ -487,24 +516,23 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
assertThat(postProcessor.getScheduledTasks().isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyPlaceholderWithFixedDelayInMillis() {
|
||||
propertyPlaceholderWithFixedDelay(false);
|
||||
}
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"PropertyPlaceholderWithFixedDelay, 5000, 1000, 5000, 1000",
|
||||
"PropertyPlaceholderWithFixedDelay, PT5S, PT1S, 5000, 1000",
|
||||
"PropertyPlaceholderWithFixedDelayInSeconds, 5000, 1000, 5000000, 1000000",
|
||||
"PropertyPlaceholderWithFixedDelayInSeconds, PT5S, PT1S, 5000, 1000"
|
||||
})
|
||||
void propertyPlaceholderWithFixedDelay(@NameToClass Class<?> beanClass, String fixedDelay, String initialDelay,
|
||||
long expectedInterval, long expectedInitialDelay) {
|
||||
|
||||
@Test
|
||||
public void propertyPlaceholderWithFixedDelayInDuration() {
|
||||
propertyPlaceholderWithFixedDelay(true);
|
||||
}
|
||||
|
||||
private void propertyPlaceholderWithFixedDelay(boolean durationFormat) {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("fixedDelay", (durationFormat ? "PT5S" : "5000"));
|
||||
properties.setProperty("initialDelay", (durationFormat ? "PT1S" : "1000"));
|
||||
properties.setProperty("fixedDelay", fixedDelay);
|
||||
properties.setProperty("initialDelay", initialDelay);
|
||||
placeholderDefinition.getPropertyValues().addPropertyValue("properties", properties);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(PropertyPlaceholderWithFixedDelayTestBean.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(beanClass);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
context.registerBeanDefinition("placeholder", placeholderDefinition);
|
||||
context.registerBeanDefinition("target", targetDefinition);
|
||||
@@ -526,28 +554,29 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
Method targetMethod = runnable.getMethod();
|
||||
assertThat(targetObject).isEqualTo(target);
|
||||
assertThat(targetMethod.getName()).isEqualTo("fixedDelay");
|
||||
assertThat(task.getInitialDelay()).isEqualTo(1000L);
|
||||
assertThat(task.getInterval()).isEqualTo(5000L);
|
||||
assertSoftly(softly -> {
|
||||
softly.assertThat(task.getInitialDelay()).as("initial delay").isEqualTo(expectedInitialDelay);
|
||||
softly.assertThat(task.getInterval()).as("interval").isEqualTo(expectedInterval);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyPlaceholderWithFixedRateInMillis() {
|
||||
propertyPlaceholderWithFixedRate(false);
|
||||
}
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"PropertyPlaceholderWithFixedRate, 3000, 1000, 3000, 1000",
|
||||
"PropertyPlaceholderWithFixedRate, PT3S, PT1S, 3000, 1000",
|
||||
"PropertyPlaceholderWithFixedRateInSeconds, 3000, 1000, 3000000, 1000000",
|
||||
"PropertyPlaceholderWithFixedRateInSeconds, PT3S, PT1S, 3000, 1000"
|
||||
})
|
||||
void propertyPlaceholderWithFixedRate(@NameToClass Class<?> beanClass, String fixedRate, String initialDelay,
|
||||
long expectedInterval, long expectedInitialDelay) {
|
||||
|
||||
@Test
|
||||
public void propertyPlaceholderWithFixedRateInDuration() {
|
||||
propertyPlaceholderWithFixedRate(true);
|
||||
}
|
||||
|
||||
private void propertyPlaceholderWithFixedRate(boolean durationFormat) {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("fixedRate", (durationFormat ? "PT3S" : "3000"));
|
||||
properties.setProperty("initialDelay", (durationFormat ? "PT1S" : "1000"));
|
||||
properties.setProperty("fixedRate", fixedRate);
|
||||
properties.setProperty("initialDelay", initialDelay);
|
||||
placeholderDefinition.getPropertyValues().addPropertyValue("properties", properties);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(PropertyPlaceholderWithFixedRateTestBean.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(beanClass);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
context.registerBeanDefinition("placeholder", placeholderDefinition);
|
||||
context.registerBeanDefinition("target", targetDefinition);
|
||||
@@ -569,12 +598,14 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
Method targetMethod = runnable.getMethod();
|
||||
assertThat(targetObject).isEqualTo(target);
|
||||
assertThat(targetMethod.getName()).isEqualTo("fixedRate");
|
||||
assertThat(task.getInitialDelay()).isEqualTo(1000L);
|
||||
assertThat(task.getInterval()).isEqualTo(3000L);
|
||||
assertSoftly(softly -> {
|
||||
softly.assertThat(task.getInitialDelay()).as("initial delay").isEqualTo(expectedInitialDelay);
|
||||
softly.assertThat(task.getInterval()).as("interval").isEqualTo(expectedInterval);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expressionWithCron() {
|
||||
void expressionWithCron() {
|
||||
String businessHoursCronExpression = "0 0 9-17 * * MON-FRI";
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(ExpressionWithCronTestBean.class);
|
||||
@@ -605,7 +636,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyPlaceholderForMetaAnnotation() {
|
||||
void propertyPlaceholderForMetaAnnotation() {
|
||||
String businessHoursCronExpression = "0 0 9-17 * * MON-FRI";
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition placeholderDefinition = new RootBeanDefinition(PropertySourcesPlaceholderConfigurer.class);
|
||||
@@ -638,7 +669,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonVoidReturnType() {
|
||||
void nonVoidReturnType() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(NonVoidReturnTypeTestBean.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
@@ -665,7 +696,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyAnnotation() {
|
||||
void emptyAnnotation() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(EmptyAnnotationTestBean.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
@@ -675,7 +706,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidCron() throws Throwable {
|
||||
void invalidCron() throws Throwable {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(InvalidCronTestBean.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
@@ -685,7 +716,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonEmptyParamList() {
|
||||
void nonEmptyParamList() {
|
||||
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(NonEmptyParamListTestBean.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
@@ -695,26 +726,68 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
|
||||
static class FixedDelayTestBean {
|
||||
static class FixedDelay {
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void fixedDelay() {
|
||||
void fixedDelay() {
|
||||
}
|
||||
}
|
||||
|
||||
static class FixedDelayInSeconds {
|
||||
|
||||
@Scheduled(fixedDelay = 5, timeUnit = TimeUnit.SECONDS)
|
||||
void fixedDelay() {
|
||||
}
|
||||
}
|
||||
|
||||
static class FixedDelayInMinutes {
|
||||
|
||||
@Scheduled(fixedDelay = 3, timeUnit = TimeUnit.MINUTES)
|
||||
void fixedDelay() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class FixedRateTestBean {
|
||||
static class FixedRate {
|
||||
|
||||
@Scheduled(fixedRate = 3000)
|
||||
public void fixedRate() {
|
||||
void fixedRate() {
|
||||
}
|
||||
}
|
||||
|
||||
static class FixedRateInSeconds {
|
||||
|
||||
@Scheduled(fixedRate = 5, timeUnit = TimeUnit.SECONDS)
|
||||
void fixedRate() {
|
||||
}
|
||||
}
|
||||
|
||||
static class FixedRateInMinutes {
|
||||
|
||||
@Scheduled(fixedRate = 3, timeUnit = TimeUnit.MINUTES)
|
||||
void fixedRate() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class FixedRateWithInitialDelayTestBean {
|
||||
static class FixedRateWithInitialDelay {
|
||||
|
||||
@Scheduled(fixedRate = 3000, initialDelay = 1000)
|
||||
public void fixedRate() {
|
||||
void fixedRate() {
|
||||
}
|
||||
}
|
||||
|
||||
static class FixedRateWithInitialDelayInSeconds {
|
||||
|
||||
@Scheduled(fixedRate = 3, initialDelay = 5, timeUnit = TimeUnit.SECONDS)
|
||||
void fixedRate() {
|
||||
}
|
||||
}
|
||||
|
||||
static class FixedRateWithInitialDelayInMinutes {
|
||||
|
||||
@Scheduled(fixedRate = 3, initialDelay = 1, timeUnit = TimeUnit.MINUTES)
|
||||
void fixedRate() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -722,7 +795,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class SeveralFixedRatesWithSchedulesContainerAnnotationTestBean {
|
||||
|
||||
@Schedules({@Scheduled(fixedRate = 4000), @Scheduled(fixedRate = 4000, initialDelay = 2000)})
|
||||
public void fixedRate() {
|
||||
void fixedRate() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,7 +804,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
|
||||
@Scheduled(fixedRate = 4000)
|
||||
@Scheduled(fixedRate = 4000, initialDelay = 2000)
|
||||
public void fixedRate() {
|
||||
void fixedRate() {
|
||||
}
|
||||
|
||||
static SeveralFixedRatesWithRepeatedScheduledAnnotationTestBean nestedProxy() {
|
||||
@@ -748,7 +821,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
|
||||
@Scheduled(fixedRate = 4000)
|
||||
@Scheduled(fixedRate = 4000, initialDelay = 2000)
|
||||
public void fixedRate() {
|
||||
void fixedRate() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,7 +865,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class CronWithInvalidTimezoneTestBean {
|
||||
|
||||
@Scheduled(cron = "0 0 0-4,6-23 * * ?", zone = "FOO")
|
||||
public void cron() throws IOException {
|
||||
void cron() throws IOException {
|
||||
throw new IOException("no no no");
|
||||
}
|
||||
}
|
||||
@@ -803,7 +876,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class ProxiedCronTestBean {
|
||||
|
||||
@Scheduled(cron = "*/7 * * * * ?")
|
||||
public void cron() throws IOException {
|
||||
void cron() throws IOException {
|
||||
throw new IOException("no no no");
|
||||
}
|
||||
}
|
||||
@@ -811,7 +884,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
|
||||
static class ProxiedCronTestBeanDependent {
|
||||
|
||||
public ProxiedCronTestBeanDependent(ProxiedCronTestBean testBean) {
|
||||
ProxiedCronTestBeanDependent(ProxiedCronTestBean testBean) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -819,7 +892,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class NonVoidReturnTypeTestBean {
|
||||
|
||||
@Scheduled(cron = "0 0 9-17 * * MON-FRI")
|
||||
public String cron() {
|
||||
String cron() {
|
||||
return "oops";
|
||||
}
|
||||
}
|
||||
@@ -828,7 +901,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class EmptyAnnotationTestBean {
|
||||
|
||||
@Scheduled
|
||||
public void invalid() {
|
||||
void invalid() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -836,7 +909,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class InvalidCronTestBean {
|
||||
|
||||
@Scheduled(cron = "abc")
|
||||
public void invalid() {
|
||||
void invalid() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -844,7 +917,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class NonEmptyParamListTestBean {
|
||||
|
||||
@Scheduled(fixedRate = 3000)
|
||||
public void invalid(String oops) {
|
||||
void invalid(String oops) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,7 +949,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class MetaAnnotationFixedRateTestBean {
|
||||
|
||||
@EveryFiveSeconds
|
||||
public void checkForUpdates() {
|
||||
void checkForUpdates() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -884,7 +957,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class ComposedAnnotationFixedRateTestBean {
|
||||
|
||||
@WaitASec(fixedRate = 5000)
|
||||
public void checkForUpdates() {
|
||||
void checkForUpdates() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -892,7 +965,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class MetaAnnotationCronTestBean {
|
||||
|
||||
@Hourly
|
||||
public void generateReport() {
|
||||
void generateReport() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -900,23 +973,37 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class PropertyPlaceholderWithCronTestBean {
|
||||
|
||||
@Scheduled(cron = "${schedules.businessHours}")
|
||||
public void x() {
|
||||
void x() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class PropertyPlaceholderWithFixedDelayTestBean {
|
||||
static class PropertyPlaceholderWithFixedDelay {
|
||||
|
||||
@Scheduled(fixedDelayString = "${fixedDelay}", initialDelayString = "${initialDelay}")
|
||||
public void fixedDelay() {
|
||||
void fixedDelay() {
|
||||
}
|
||||
}
|
||||
|
||||
static class PropertyPlaceholderWithFixedDelayInSeconds {
|
||||
|
||||
@Scheduled(fixedDelayString = "${fixedDelay}", initialDelayString = "${initialDelay}", timeUnit = TimeUnit.SECONDS)
|
||||
void fixedDelay() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class PropertyPlaceholderWithFixedRateTestBean {
|
||||
static class PropertyPlaceholderWithFixedRate {
|
||||
|
||||
@Scheduled(fixedRateString = "${fixedRate}", initialDelayString = "${initialDelay}")
|
||||
public void fixedRate() {
|
||||
void fixedRate() {
|
||||
}
|
||||
}
|
||||
|
||||
static class PropertyPlaceholderWithFixedRateInSeconds {
|
||||
|
||||
@Scheduled(fixedRateString = "${fixedRate}", initialDelayString = "${initialDelay}", timeUnit = TimeUnit.SECONDS)
|
||||
void fixedRate() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -924,7 +1011,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class ExpressionWithCronTestBean {
|
||||
|
||||
@Scheduled(cron = "#{schedules.businessHours}")
|
||||
public void x() {
|
||||
void x() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -939,7 +1026,24 @@ public class ScheduledAnnotationBeanPostProcessorTests {
|
||||
static class PropertyPlaceholderMetaAnnotationTestBean {
|
||||
|
||||
@BusinessHours
|
||||
public void y() {
|
||||
void y() {
|
||||
}
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ConvertWith(NameToClass.Converter.class)
|
||||
private @interface NameToClass {
|
||||
class Converter implements ArgumentConverter {
|
||||
@Override
|
||||
public Class<?> convert(Object beanClassName, ParameterContext context) throws ArgumentConversionException {
|
||||
try {
|
||||
String name = getClass().getEnclosingClass().getEnclosingClass().getName() + "$" + beanClassName;
|
||||
return getClass().getClassLoader().loadClass(name);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new ArgumentConversionException("Failed to convert class name to Class", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-14
@@ -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.
|
||||
@@ -41,7 +41,7 @@ import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING;
|
||||
* @author Chris Beams
|
||||
*/
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public class ScriptFactoryPostProcessorTests {
|
||||
class ScriptFactoryPostProcessorTests {
|
||||
|
||||
private static final String MESSAGE_TEXT = "Bingo";
|
||||
|
||||
@@ -79,18 +79,18 @@ public class ScriptFactoryPostProcessorTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testDoesNothingWhenPostProcessingNonScriptFactoryTypeBeforeInstantiation() throws Exception {
|
||||
void testDoesNothingWhenPostProcessingNonScriptFactoryTypeBeforeInstantiation() {
|
||||
assertThat(new ScriptFactoryPostProcessor().postProcessBeforeInstantiation(getClass(), "a.bean")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThrowsExceptionIfGivenNonAbstractBeanFactoryImplementation() throws Exception {
|
||||
void testThrowsExceptionIfGivenNonAbstractBeanFactoryImplementation() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new ScriptFactoryPostProcessor().setBeanFactory(mock(BeanFactory.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeScriptWithRefreshableBeanFunctionality() throws Exception {
|
||||
void testChangeScriptWithRefreshableBeanFunctionality() throws Exception {
|
||||
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
|
||||
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
|
||||
|
||||
@@ -111,7 +111,7 @@ public class ScriptFactoryPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeScriptWithNoRefreshableBeanFunctionality() throws Exception {
|
||||
void testChangeScriptWithNoRefreshableBeanFunctionality() throws Exception {
|
||||
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(false);
|
||||
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
|
||||
|
||||
@@ -131,7 +131,7 @@ public class ScriptFactoryPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRefreshedScriptReferencePropagatesToCollaborators() throws Exception {
|
||||
void testRefreshedScriptReferencePropagatesToCollaborators() throws Exception {
|
||||
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
|
||||
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
|
||||
BeanDefinitionBuilder collaboratorBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultMessengerService.class);
|
||||
@@ -159,7 +159,7 @@ public class ScriptFactoryPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReferencesAcrossAContainerHierarchy() throws Exception {
|
||||
void testReferencesAcrossAContainerHierarchy() throws Exception {
|
||||
GenericApplicationContext businessContext = new GenericApplicationContext();
|
||||
businessContext.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition());
|
||||
businessContext.refresh();
|
||||
@@ -175,13 +175,13 @@ public class ScriptFactoryPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScriptHavingAReferenceToAnotherBean() throws Exception {
|
||||
void testScriptHavingAReferenceToAnotherBean() throws Exception {
|
||||
// just tests that the (singleton) script-backed bean is able to be instantiated with references to its collaborators
|
||||
new ClassPathXmlApplicationContext("org/springframework/scripting/support/groovyReferences.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForRefreshedScriptHavingErrorPickedUpOnFirstCall() throws Exception {
|
||||
void testForRefreshedScriptHavingErrorPickedUpOnFirstCall() throws Exception {
|
||||
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
|
||||
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
|
||||
BeanDefinitionBuilder collaboratorBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultMessengerService.class);
|
||||
@@ -202,13 +202,12 @@ public class ScriptFactoryPostProcessorTests {
|
||||
// needs The Sundays compiler; must NOT throw any exception here...
|
||||
source.setScript("I keep hoping you are the same as me, and I'll send you letters and come to your house for tea");
|
||||
Messenger refreshedMessenger = (Messenger) ctx.getBean(MESSENGER_BEAN_NAME);
|
||||
assertThatExceptionOfType(FatalBeanException.class).isThrownBy(() ->
|
||||
refreshedMessenger.getMessage())
|
||||
assertThatExceptionOfType(FatalBeanException.class).isThrownBy(refreshedMessenger::getMessage)
|
||||
.matches(ex -> ex.contains(ScriptCompilationException.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrototypeScriptedBean() throws Exception {
|
||||
void testPrototypeScriptedBean() throws Exception {
|
||||
GenericApplicationContext ctx = new GenericApplicationContext();
|
||||
ctx.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition());
|
||||
|
||||
@@ -236,7 +235,7 @@ public class ScriptFactoryPostProcessorTests {
|
||||
private static BeanDefinition createScriptFactoryPostProcessor(boolean isRefreshable) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ScriptFactoryPostProcessor.class);
|
||||
if (isRefreshable) {
|
||||
builder.addPropertyValue("defaultRefreshCheckDelay", new Long(1));
|
||||
builder.addPropertyValue("defaultRefreshCheckDelay", 1L);
|
||||
}
|
||||
return builder.getBeanDefinition();
|
||||
}
|
||||
|
||||
+10
-10
@@ -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.
|
||||
@@ -36,17 +36,17 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Stephane Nicoll
|
||||
* @since 07.03.2006
|
||||
*/
|
||||
public class DataBinderFieldAccessTests {
|
||||
class DataBinderFieldAccessTests {
|
||||
|
||||
@Test
|
||||
public void bindingNoErrors() throws Exception {
|
||||
void bindingNoErrors() throws Exception {
|
||||
FieldAccessBean rod = new FieldAccessBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
assertThat(binder.isIgnoreUnknownFields()).isTrue();
|
||||
binder.initDirectFieldAccess();
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue(new PropertyValue("name", "Rod"));
|
||||
pvs.addPropertyValue(new PropertyValue("age", new Integer(32)));
|
||||
pvs.addPropertyValue(new PropertyValue("age", 32));
|
||||
pvs.addPropertyValue(new PropertyValue("nonExisting", "someValue"));
|
||||
|
||||
binder.bind(pvs);
|
||||
@@ -62,21 +62,21 @@ public class DataBinderFieldAccessTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindingNoErrorsNotIgnoreUnknown() throws Exception {
|
||||
void bindingNoErrorsNotIgnoreUnknown() throws Exception {
|
||||
FieldAccessBean rod = new FieldAccessBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
binder.initDirectFieldAccess();
|
||||
binder.setIgnoreUnknownFields(false);
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue(new PropertyValue("name", "Rod"));
|
||||
pvs.addPropertyValue(new PropertyValue("age", new Integer(32)));
|
||||
pvs.addPropertyValue(new PropertyValue("age", 32));
|
||||
pvs.addPropertyValue(new PropertyValue("nonExisting", "someValue"));
|
||||
assertThatExceptionOfType(NotWritablePropertyException.class).isThrownBy(() ->
|
||||
binder.bind(pvs));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindingWithErrors() throws Exception {
|
||||
void bindingWithErrors() throws Exception {
|
||||
FieldAccessBean rod = new FieldAccessBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
binder.initDirectFieldAccess();
|
||||
@@ -105,7 +105,7 @@ public class DataBinderFieldAccessTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nestedBindingWithDefaultConversionNoErrors() throws Exception {
|
||||
void nestedBindingWithDefaultConversionNoErrors() throws Exception {
|
||||
FieldAccessBean rod = new FieldAccessBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
assertThat(binder.isIgnoreUnknownFields()).isTrue();
|
||||
@@ -122,7 +122,7 @@ public class DataBinderFieldAccessTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nestedBindingWithDisabledAutoGrow() throws Exception {
|
||||
void nestedBindingWithDisabledAutoGrow() throws Exception {
|
||||
FieldAccessBean rod = new FieldAccessBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
binder.setAutoGrowNestedPaths(false);
|
||||
@@ -135,7 +135,7 @@ public class DataBinderFieldAccessTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindingWithErrorsAndCustomEditors() throws Exception {
|
||||
void bindingWithErrorsAndCustomEditors() throws Exception {
|
||||
FieldAccessBean rod = new FieldAccessBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
binder.initDirectFieldAccess();
|
||||
|
||||
+102
-102
@@ -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.
|
||||
@@ -77,10 +77,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
* @author Rob Harrop
|
||||
* @author Kazuki Shimizu
|
||||
*/
|
||||
public class DataBinderTests {
|
||||
class DataBinderTests {
|
||||
|
||||
@Test
|
||||
public void testBindingNoErrors() throws BindException {
|
||||
void testBindingNoErrors() throws BindException {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
assertThat(binder.isIgnoreUnknownFields()).isTrue();
|
||||
@@ -115,7 +115,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithDefaultConversionNoErrors() throws BindException {
|
||||
void testBindingWithDefaultConversionNoErrors() throws BindException {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
assertThat(binder.isIgnoreUnknownFields()).isTrue();
|
||||
@@ -131,7 +131,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNestedBindingWithDefaultConversionNoErrors() throws BindException {
|
||||
void testNestedBindingWithDefaultConversionNoErrors() throws BindException {
|
||||
TestBean rod = new TestBean(new TestBean());
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
assertThat(binder.isIgnoreUnknownFields()).isTrue();
|
||||
@@ -147,7 +147,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingNoErrorsNotIgnoreUnknown() {
|
||||
void testBindingNoErrorsNotIgnoreUnknown() {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
binder.setIgnoreUnknownFields(false);
|
||||
@@ -160,7 +160,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingNoErrorsWithInvalidField() {
|
||||
void testBindingNoErrorsWithInvalidField() {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
@@ -171,7 +171,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingNoErrorsWithIgnoreInvalid() {
|
||||
void testBindingNoErrorsWithIgnoreInvalid() {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
binder.setIgnoreInvalidFields(true);
|
||||
@@ -183,7 +183,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithErrors() {
|
||||
void testBindingWithErrors() {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
@@ -245,7 +245,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithSystemFieldError() {
|
||||
void testBindingWithSystemFieldError() {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
@@ -257,7 +257,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithErrorsAndCustomEditors() {
|
||||
void testBindingWithErrorsAndCustomEditors() {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
binder.registerCustomEditor(String.class, "touchy", new PropertyEditorSupport() {
|
||||
@@ -325,7 +325,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithCustomEditorOnObjectField() {
|
||||
void testBindingWithCustomEditorOnObjectField() {
|
||||
BeanWithObjectProperty tb = new BeanWithObjectProperty();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
binder.registerCustomEditor(Integer.class, "object", new CustomNumberEditor(Integer.class, true));
|
||||
@@ -336,7 +336,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithFormatter() {
|
||||
void testBindingWithFormatter() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
FormattingConversionService conversionService = new FormattingConversionService();
|
||||
@@ -349,18 +349,18 @@ public class DataBinderTests {
|
||||
LocaleContextHolder.setLocale(Locale.GERMAN);
|
||||
try {
|
||||
binder.bind(pvs);
|
||||
assertThat(tb.getMyFloat()).isEqualTo(new Float(1.2));
|
||||
assertThat(tb.getMyFloat()).isEqualTo(Float.valueOf(1.2f));
|
||||
assertThat(binder.getBindingResult().getFieldValue("myFloat")).isEqualTo("1,2");
|
||||
|
||||
PropertyEditor editor = binder.getBindingResult().findEditor("myFloat", Float.class);
|
||||
assertThat(editor).isNotNull();
|
||||
editor.setValue(new Float(1.4));
|
||||
editor.setValue(1.4f);
|
||||
assertThat(editor.getAsText()).isEqualTo("1,4");
|
||||
|
||||
editor = binder.getBindingResult().findEditor("myFloat", null);
|
||||
assertThat(editor).isNotNull();
|
||||
editor.setAsText("1,6");
|
||||
assertThat(editor.getValue()).isEqualTo(new Float(1.6));
|
||||
assertThat(editor.getValue()).isEqualTo(1.6f);
|
||||
}
|
||||
finally {
|
||||
LocaleContextHolder.resetLocaleContext();
|
||||
@@ -368,7 +368,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingErrorWithFormatter() {
|
||||
void testBindingErrorWithFormatter() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
FormattingConversionService conversionService = new FormattingConversionService();
|
||||
@@ -381,7 +381,7 @@ public class DataBinderTests {
|
||||
LocaleContextHolder.setLocale(Locale.GERMAN);
|
||||
try {
|
||||
binder.bind(pvs);
|
||||
assertThat(tb.getMyFloat()).isEqualTo(new Float(0.0));
|
||||
assertThat(tb.getMyFloat()).isEqualTo(Float.valueOf(0.0f));
|
||||
assertThat(binder.getBindingResult().getFieldValue("myFloat")).isEqualTo("1x2");
|
||||
assertThat(binder.getBindingResult().hasFieldErrors("myFloat")).isTrue();
|
||||
}
|
||||
@@ -391,7 +391,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingErrorWithParseExceptionFromFormatter() {
|
||||
void testBindingErrorWithParseExceptionFromFormatter() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
FormattingConversionService conversionService = new FormattingConversionService();
|
||||
@@ -419,7 +419,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingErrorWithRuntimeExceptionFromFormatter() {
|
||||
void testBindingErrorWithRuntimeExceptionFromFormatter() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
FormattingConversionService conversionService = new FormattingConversionService();
|
||||
@@ -447,7 +447,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithFormatterAgainstList() {
|
||||
void testBindingWithFormatterAgainstList() {
|
||||
BeanWithIntegerList tb = new BeanWithIntegerList();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
FormattingConversionService conversionService = new FormattingConversionService();
|
||||
@@ -469,7 +469,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingErrorWithFormatterAgainstList() {
|
||||
void testBindingErrorWithFormatterAgainstList() {
|
||||
BeanWithIntegerList tb = new BeanWithIntegerList();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
FormattingConversionService conversionService = new FormattingConversionService();
|
||||
@@ -492,7 +492,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithFormatterAgainstFields() {
|
||||
void testBindingWithFormatterAgainstFields() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
FormattingConversionService conversionService = new FormattingConversionService();
|
||||
@@ -506,18 +506,18 @@ public class DataBinderTests {
|
||||
LocaleContextHolder.setLocale(Locale.GERMAN);
|
||||
try {
|
||||
binder.bind(pvs);
|
||||
assertThat(tb.getMyFloat()).isEqualTo(new Float(1.2));
|
||||
assertThat(tb.getMyFloat()).isEqualTo(Float.valueOf(1.2f));
|
||||
assertThat(binder.getBindingResult().getFieldValue("myFloat")).isEqualTo("1,2");
|
||||
|
||||
PropertyEditor editor = binder.getBindingResult().findEditor("myFloat", Float.class);
|
||||
assertThat(editor).isNotNull();
|
||||
editor.setValue(new Float(1.4));
|
||||
editor.setValue(1.4f);
|
||||
assertThat(editor.getAsText()).isEqualTo("1,4");
|
||||
|
||||
editor = binder.getBindingResult().findEditor("myFloat", null);
|
||||
assertThat(editor).isNotNull();
|
||||
editor.setAsText("1,6");
|
||||
assertThat(editor.getValue()).isEqualTo(new Float(1.6));
|
||||
assertThat(editor.getValue()).isEqualTo(1.6f);
|
||||
}
|
||||
finally {
|
||||
LocaleContextHolder.resetLocaleContext();
|
||||
@@ -525,7 +525,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingErrorWithFormatterAgainstFields() {
|
||||
void testBindingErrorWithFormatterAgainstFields() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
binder.initDirectFieldAccess();
|
||||
@@ -539,7 +539,7 @@ public class DataBinderTests {
|
||||
LocaleContextHolder.setLocale(Locale.GERMAN);
|
||||
try {
|
||||
binder.bind(pvs);
|
||||
assertThat(tb.getMyFloat()).isEqualTo(new Float(0.0));
|
||||
assertThat(tb.getMyFloat()).isEqualTo(Float.valueOf(0.0f));
|
||||
assertThat(binder.getBindingResult().getFieldValue("myFloat")).isEqualTo("1x2");
|
||||
assertThat(binder.getBindingResult().hasFieldErrors("myFloat")).isTrue();
|
||||
}
|
||||
@@ -549,7 +549,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithCustomFormatter() {
|
||||
void testBindingWithCustomFormatter() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
binder.addCustomFormatter(new NumberStyleFormatter(), Float.class);
|
||||
@@ -559,12 +559,12 @@ public class DataBinderTests {
|
||||
LocaleContextHolder.setLocale(Locale.GERMAN);
|
||||
try {
|
||||
binder.bind(pvs);
|
||||
assertThat(tb.getMyFloat()).isEqualTo(new Float(1.2));
|
||||
assertThat(tb.getMyFloat()).isEqualTo(Float.valueOf(1.2f));
|
||||
assertThat(binder.getBindingResult().getFieldValue("myFloat")).isEqualTo("1,2");
|
||||
|
||||
PropertyEditor editor = binder.getBindingResult().findEditor("myFloat", Float.class);
|
||||
assertThat(editor).isNotNull();
|
||||
editor.setValue(new Float(1.4));
|
||||
editor.setValue(1.4f);
|
||||
assertThat(editor.getAsText()).isEqualTo("1,4");
|
||||
|
||||
editor = binder.getBindingResult().findEditor("myFloat", null);
|
||||
@@ -578,7 +578,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingErrorWithCustomFormatter() {
|
||||
void testBindingErrorWithCustomFormatter() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
binder.addCustomFormatter(new NumberStyleFormatter());
|
||||
@@ -588,7 +588,7 @@ public class DataBinderTests {
|
||||
LocaleContextHolder.setLocale(Locale.GERMAN);
|
||||
try {
|
||||
binder.bind(pvs);
|
||||
assertThat(tb.getMyFloat()).isEqualTo(new Float(0.0));
|
||||
assertThat(tb.getMyFloat()).isEqualTo(Float.valueOf(0.0f));
|
||||
assertThat(binder.getBindingResult().getFieldValue("myFloat")).isEqualTo("1x2");
|
||||
assertThat(binder.getBindingResult().hasFieldErrors("myFloat")).isTrue();
|
||||
assertThat(binder.getBindingResult().getFieldError("myFloat").getCode()).isEqualTo("typeMismatch");
|
||||
@@ -599,7 +599,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingErrorWithParseExceptionFromCustomFormatter() {
|
||||
void testBindingErrorWithParseExceptionFromCustomFormatter() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
|
||||
@@ -624,7 +624,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingErrorWithRuntimeExceptionFromCustomFormatter() {
|
||||
void testBindingErrorWithRuntimeExceptionFromCustomFormatter() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
|
||||
@@ -649,7 +649,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConversionWithInappropriateStringEditor() {
|
||||
void testConversionWithInappropriateStringEditor() {
|
||||
DataBinder dataBinder = new DataBinder(null);
|
||||
DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
|
||||
dataBinder.setConversionService(conversionService);
|
||||
@@ -662,7 +662,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithAllowedFields() throws BindException {
|
||||
void testBindingWithAllowedFields() throws BindException {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod);
|
||||
binder.setAllowedFields("name", "myparam");
|
||||
@@ -677,7 +677,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithDisallowedFields() throws BindException {
|
||||
void testBindingWithDisallowedFields() throws BindException {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod);
|
||||
binder.setDisallowedFields("age");
|
||||
@@ -695,7 +695,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithAllowedAndDisallowedFields() throws BindException {
|
||||
void testBindingWithAllowedAndDisallowedFields() throws BindException {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod);
|
||||
binder.setAllowedFields("name", "myparam");
|
||||
@@ -709,12 +709,12 @@ public class DataBinderTests {
|
||||
assertThat(rod.getName().equals("Rod")).as("changed name correctly").isTrue();
|
||||
assertThat(rod.getAge() == 0).as("did not change age").isTrue();
|
||||
String[] disallowedFields = binder.getBindingResult().getSuppressedFields();
|
||||
assertThat(disallowedFields.length).isEqualTo(1);
|
||||
assertThat(disallowedFields).hasSize(1);
|
||||
assertThat(disallowedFields[0]).isEqualTo("age");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithOverlappingAllowedAndDisallowedFields() throws BindException {
|
||||
void testBindingWithOverlappingAllowedAndDisallowedFields() throws BindException {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod);
|
||||
binder.setAllowedFields("name", "age");
|
||||
@@ -728,12 +728,12 @@ public class DataBinderTests {
|
||||
assertThat(rod.getName().equals("Rod")).as("changed name correctly").isTrue();
|
||||
assertThat(rod.getAge() == 0).as("did not change age").isTrue();
|
||||
String[] disallowedFields = binder.getBindingResult().getSuppressedFields();
|
||||
assertThat(disallowedFields.length).isEqualTo(1);
|
||||
assertThat(disallowedFields).hasSize(1);
|
||||
assertThat(disallowedFields[0]).isEqualTo("age");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithAllowedFieldsUsingAsterisks() throws BindException {
|
||||
void testBindingWithAllowedFieldsUsingAsterisks() throws BindException {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
binder.setAllowedFields("nam*", "*ouchy");
|
||||
@@ -750,7 +750,7 @@ public class DataBinderTests {
|
||||
assertThat("Rod".equals(rod.getTouchy())).as("changed touchy correctly").isTrue();
|
||||
assertThat(rod.getAge() == 0).as("did not change age").isTrue();
|
||||
String[] disallowedFields = binder.getBindingResult().getSuppressedFields();
|
||||
assertThat(disallowedFields.length).isEqualTo(1);
|
||||
assertThat(disallowedFields).hasSize(1);
|
||||
assertThat(disallowedFields[0]).isEqualTo("age");
|
||||
|
||||
Map<?,?> m = binder.getBindingResult().getModel();
|
||||
@@ -760,7 +760,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithAllowedAndDisallowedMapFields() throws BindException {
|
||||
void testBindingWithAllowedAndDisallowedMapFields() throws BindException {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod);
|
||||
binder.setAllowedFields("someMap[key1]", "someMap[key2]");
|
||||
@@ -779,7 +779,7 @@ public class DataBinderTests {
|
||||
assertThat(rod.getSomeMap().get("key3")).isNull();
|
||||
assertThat(rod.getSomeMap().get("key4")).isNull();
|
||||
String[] disallowedFields = binder.getBindingResult().getSuppressedFields();
|
||||
assertThat(disallowedFields.length).isEqualTo(2);
|
||||
assertThat(disallowedFields).hasSize(2);
|
||||
assertThat(ObjectUtils.containsElement(disallowedFields, "someMap[key3]")).isTrue();
|
||||
assertThat(ObjectUtils.containsElement(disallowedFields, "someMap[key4]")).isTrue();
|
||||
}
|
||||
@@ -788,7 +788,7 @@ public class DataBinderTests {
|
||||
* Tests for required field, both null, non-existing and empty strings.
|
||||
*/
|
||||
@Test
|
||||
public void testBindingWithRequiredFields() {
|
||||
void testBindingWithRequiredFields() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setSpouse(new TestBean());
|
||||
|
||||
@@ -819,7 +819,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithRequiredMapFields() {
|
||||
void testBindingWithRequiredMapFields() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setSpouse(new TestBean());
|
||||
|
||||
@@ -839,7 +839,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithNestedObjectCreation() {
|
||||
void testBindingWithNestedObjectCreation() {
|
||||
TestBean tb = new TestBean();
|
||||
|
||||
DataBinder binder = new DataBinder(tb, "person");
|
||||
@@ -860,7 +860,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEditorWithOldValueAccess() {
|
||||
void testCustomEditorWithOldValueAccess() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
|
||||
@@ -885,7 +885,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEditorForSingleProperty() {
|
||||
void testCustomEditorForSingleProperty() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setSpouse(new TestBean());
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
@@ -925,7 +925,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEditorForPrimitiveProperty() {
|
||||
void testCustomEditorForPrimitiveProperty() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
|
||||
@@ -949,7 +949,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEditorForAllStringProperties() {
|
||||
void testCustomEditorForAllStringProperties() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
|
||||
@@ -981,7 +981,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomFormatterForSingleProperty() {
|
||||
void testCustomFormatterForSingleProperty() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setSpouse(new TestBean());
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
@@ -1021,7 +1021,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomFormatterForPrimitiveProperty() {
|
||||
void testCustomFormatterForPrimitiveProperty() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
|
||||
@@ -1045,7 +1045,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomFormatterForAllStringProperties() {
|
||||
void testCustomFormatterForAllStringProperties() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
|
||||
@@ -1077,7 +1077,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJavaBeanPropertyConventions() {
|
||||
void testJavaBeanPropertyConventions() {
|
||||
Book book = new Book();
|
||||
DataBinder binder = new DataBinder(book);
|
||||
|
||||
@@ -1101,7 +1101,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionalProperty() {
|
||||
void testOptionalProperty() {
|
||||
OptionalHolder bean = new OptionalHolder();
|
||||
DataBinder binder = new DataBinder(bean);
|
||||
binder.setConversionService(new DefaultConversionService());
|
||||
@@ -1111,7 +1111,7 @@ public class DataBinderTests {
|
||||
pvs.add("name", null);
|
||||
binder.bind(pvs);
|
||||
assertThat(bean.getId()).isEqualTo("1");
|
||||
assertThat(bean.getName().isPresent()).isFalse();
|
||||
assertThat(bean.getName()).isEmpty();
|
||||
|
||||
pvs = new MutablePropertyValues();
|
||||
pvs.add("id", "2");
|
||||
@@ -1122,7 +1122,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidatorNoErrors() throws Exception {
|
||||
void testValidatorNoErrors() throws Exception {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setAge(33);
|
||||
tb.setName("Rod");
|
||||
@@ -1183,7 +1183,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidatorWithErrors() {
|
||||
void testValidatorWithErrors() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setSpouse(new TestBean());
|
||||
|
||||
@@ -1252,7 +1252,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidatorWithErrorsAndCodesPrefix() {
|
||||
void testValidatorWithErrorsAndCodesPrefix() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setSpouse(new TestBean());
|
||||
|
||||
@@ -1324,7 +1324,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidatorWithNestedObjectNull() {
|
||||
void testValidatorWithNestedObjectNull() {
|
||||
TestBean tb = new TestBean();
|
||||
Errors errors = new BeanPropertyBindingResult(tb, "tb");
|
||||
Validator testValidator = new TestBeanValidator();
|
||||
@@ -1343,7 +1343,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNestedValidatorWithoutNestedPath() {
|
||||
void testNestedValidatorWithoutNestedPath() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setName("XXX");
|
||||
Errors errors = new BeanPropertyBindingResult(tb, "tb");
|
||||
@@ -1357,13 +1357,13 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingStringArrayToIntegerSet() {
|
||||
void testBindingStringArrayToIntegerSet() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
binder.registerCustomEditor(Set.class, new CustomCollectionEditor(TreeSet.class) {
|
||||
@Override
|
||||
protected Object convertElement(Object element) {
|
||||
return new Integer(element.toString());
|
||||
return Integer.valueOf(element.toString());
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
@@ -1386,7 +1386,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingNullToEmptyCollection() {
|
||||
void testBindingNullToEmptyCollection() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
binder.registerCustomEditor(Set.class, new CustomCollectionEditor(TreeSet.class, true));
|
||||
@@ -1400,7 +1400,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingToIndexedField() {
|
||||
void testBindingToIndexedField() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
binder.registerCustomEditor(String.class, "array.name", new PropertyEditorSupport() {
|
||||
@@ -1439,7 +1439,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingToNestedIndexedField() {
|
||||
void testBindingToNestedIndexedField() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
tb.getArray()[0].setNestedIndexedBean(new IndexedTestBean());
|
||||
tb.getArray()[1].setNestedIndexedBean(new IndexedTestBean());
|
||||
@@ -1470,7 +1470,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditorForNestedIndexedField() {
|
||||
void testEditorForNestedIndexedField() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
tb.getArray()[0].setNestedIndexedBean(new IndexedTestBean());
|
||||
tb.getArray()[1].setNestedIndexedBean(new IndexedTestBean());
|
||||
@@ -1496,7 +1496,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpecificEditorForNestedIndexedField() {
|
||||
void testSpecificEditorForNestedIndexedField() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
tb.getArray()[0].setNestedIndexedBean(new IndexedTestBean());
|
||||
tb.getArray()[1].setNestedIndexedBean(new IndexedTestBean());
|
||||
@@ -1522,7 +1522,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInnerSpecificEditorForNestedIndexedField() {
|
||||
void testInnerSpecificEditorForNestedIndexedField() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
tb.getArray()[0].setNestedIndexedBean(new IndexedTestBean());
|
||||
tb.getArray()[1].setNestedIndexedBean(new IndexedTestBean());
|
||||
@@ -1548,7 +1548,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDirectBindingToIndexedField() {
|
||||
void testDirectBindingToIndexedField() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
binder.registerCustomEditor(TestBean.class, "array", new PropertyEditorSupport() {
|
||||
@@ -1601,7 +1601,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDirectBindingToEmptyIndexedFieldWithRegisteredSpecificEditor() {
|
||||
void testDirectBindingToEmptyIndexedFieldWithRegisteredSpecificEditor() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
binder.registerCustomEditor(TestBean.class, "map[key0]", new PropertyEditorSupport() {
|
||||
@@ -1632,7 +1632,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDirectBindingToEmptyIndexedFieldWithRegisteredGenericEditor() {
|
||||
void testDirectBindingToEmptyIndexedFieldWithRegisteredGenericEditor() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
binder.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() {
|
||||
@@ -1663,7 +1663,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomEditorWithSubclass() {
|
||||
void testCustomEditorWithSubclass() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
binder.registerCustomEditor(TestBean.class, new PropertyEditorSupport() {
|
||||
@@ -1697,7 +1697,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindToStringArrayWithArrayEditor() {
|
||||
void testBindToStringArrayWithArrayEditor() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
binder.registerCustomEditor(String[].class, "stringArray", new PropertyEditorSupport() {
|
||||
@@ -1717,7 +1717,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindToStringArrayWithComponentEditor() {
|
||||
void testBindToStringArrayWithComponentEditor() {
|
||||
TestBean tb = new TestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
binder.registerCustomEditor(String.class, "stringArray", new PropertyEditorSupport() {
|
||||
@@ -1737,7 +1737,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingErrors() {
|
||||
void testBindingErrors() {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
@@ -1764,7 +1764,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAllErrors() {
|
||||
void testAddAllErrors() {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
@@ -1784,7 +1784,7 @@ public class DataBinderTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testBindingWithResortedList() {
|
||||
void testBindingWithResortedList() {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
@@ -1802,7 +1802,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRejectWithoutDefaultMessage() {
|
||||
void testRejectWithoutDefaultMessage() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setName("myName");
|
||||
tb.setAge(99);
|
||||
@@ -1820,7 +1820,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindExceptionSerializable() throws Exception {
|
||||
void testBindExceptionSerializable() throws Exception {
|
||||
SerializablePerson tb = new SerializablePerson();
|
||||
tb.setName("myName");
|
||||
tb.setAge(99);
|
||||
@@ -1849,7 +1849,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrackDisallowedFields() {
|
||||
void testTrackDisallowedFields() {
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
binder.setAllowedFields("name", "age");
|
||||
@@ -1864,12 +1864,12 @@ public class DataBinderTests {
|
||||
|
||||
assertThat(testBean.getName()).isEqualTo(name);
|
||||
String[] disallowedFields = binder.getBindingResult().getSuppressedFields();
|
||||
assertThat(disallowedFields.length).isEqualTo(1);
|
||||
assertThat(disallowedFields).hasSize(1);
|
||||
assertThat(disallowedFields[0]).isEqualTo("beanName");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoGrowWithinDefaultLimit() {
|
||||
void testAutoGrowWithinDefaultLimit() {
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
|
||||
@@ -1877,11 +1877,11 @@ public class DataBinderTests {
|
||||
mpvs.add("friends[4]", "");
|
||||
binder.bind(mpvs);
|
||||
|
||||
assertThat(testBean.getFriends().size()).isEqualTo(5);
|
||||
assertThat(testBean.getFriends()).hasSize(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoGrowBeyondDefaultLimit() {
|
||||
void testAutoGrowBeyondDefaultLimit() {
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
|
||||
@@ -1894,7 +1894,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoGrowWithinCustomLimit() {
|
||||
void testAutoGrowWithinCustomLimit() {
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
binder.setAutoGrowCollectionLimit(10);
|
||||
@@ -1903,11 +1903,11 @@ public class DataBinderTests {
|
||||
mpvs.add("friends[4]", "");
|
||||
binder.bind(mpvs);
|
||||
|
||||
assertThat(testBean.getFriends().size()).isEqualTo(5);
|
||||
assertThat(testBean.getFriends()).hasSize(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoGrowBeyondCustomLimit() {
|
||||
void testAutoGrowBeyondCustomLimit() {
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
binder.setAutoGrowCollectionLimit(10);
|
||||
@@ -1921,7 +1921,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNestedGrowingList() {
|
||||
void testNestedGrowingList() {
|
||||
Form form = new Form();
|
||||
DataBinder binder = new DataBinder(form, "form");
|
||||
MutablePropertyValues mpv = new MutablePropertyValues();
|
||||
@@ -1937,7 +1937,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFieldErrorAccessVariations() {
|
||||
void testFieldErrorAccessVariations() {
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
assertThat(binder.getBindingResult().getGlobalError()).isNull();
|
||||
@@ -1958,7 +1958,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test // SPR-14888
|
||||
public void testSetAutoGrowCollectionLimit() {
|
||||
void testSetAutoGrowCollectionLimit() {
|
||||
BeanWithIntegerList tb = new BeanWithIntegerList();
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
binder.setAutoGrowCollectionLimit(257);
|
||||
@@ -1968,11 +1968,11 @@ public class DataBinderTests {
|
||||
binder.bind(pvs);
|
||||
assertThat(tb.getIntegerList().size()).isEqualTo(257);
|
||||
assertThat(tb.getIntegerList().get(256)).isEqualTo(Integer.valueOf(1));
|
||||
assertThat(binder.getBindingResult().getFieldValue("integerList[256]")).isEqualTo(Integer.valueOf(1));
|
||||
assertThat(binder.getBindingResult().getFieldValue("integerList[256]")).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test // SPR-14888
|
||||
public void testSetAutoGrowCollectionLimitAfterInitialization() {
|
||||
void testSetAutoGrowCollectionLimitAfterInitialization() {
|
||||
DataBinder binder = new DataBinder(new BeanWithIntegerList());
|
||||
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
@@ -1981,7 +1981,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test // SPR-15009
|
||||
public void testSetCustomMessageCodesResolverBeforeInitializeBindingResultForBeanPropertyAccess() {
|
||||
void testSetCustomMessageCodesResolverBeforeInitializeBindingResultForBeanPropertyAccess() {
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
DefaultMessageCodesResolver messageCodesResolver = new DefaultMessageCodesResolver();
|
||||
@@ -1998,7 +1998,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test // SPR-15009
|
||||
public void testSetCustomMessageCodesResolverBeforeInitializeBindingResultForDirectFieldAccess() {
|
||||
void testSetCustomMessageCodesResolverBeforeInitializeBindingResultForDirectFieldAccess() {
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
DefaultMessageCodesResolver messageCodesResolver = new DefaultMessageCodesResolver();
|
||||
@@ -2013,7 +2013,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test // SPR-15009
|
||||
public void testSetCustomMessageCodesResolverAfterInitializeBindingResult() {
|
||||
void testSetCustomMessageCodesResolverAfterInitializeBindingResult() {
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
binder.initBeanPropertyAccess();
|
||||
@@ -2028,7 +2028,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test // SPR-15009
|
||||
public void testSetMessageCodesResolverIsNullAfterInitializeBindingResult() {
|
||||
void testSetMessageCodesResolverIsNullAfterInitializeBindingResult() {
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
binder.initBeanPropertyAccess();
|
||||
@@ -2042,7 +2042,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test // SPR-15009
|
||||
public void testCallSetMessageCodesResolverTwice() {
|
||||
void testCallSetMessageCodesResolverTwice() {
|
||||
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
@@ -2053,7 +2053,7 @@ public class DataBinderTests {
|
||||
}
|
||||
|
||||
@Test // gh-24347
|
||||
public void overrideBindingResultType() {
|
||||
void overrideBindingResultType() {
|
||||
TestBean testBean = new TestBean();
|
||||
DataBinder binder = new DataBinder(testBean, "testBean");
|
||||
binder.initDirectFieldAccess();
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
description = "Spring Core Coroutines support"
|
||||
|
||||
apply plugin: "kotlin"
|
||||
|
||||
configurations {
|
||||
classesOnlyElements {
|
||||
canBeConsumed = true
|
||||
canBeResolved = false
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
classesOnlyElements(compileKotlin.destinationDir)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile("org.jetbrains.kotlin:kotlin-reflect")
|
||||
compile("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
compile("io.projectreactor:reactor-core")
|
||||
compile("org.jetbrains.kotlinx:kotlinx-coroutines-core")
|
||||
compile("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
|
||||
}
|
||||
|
||||
eclipse {
|
||||
project {
|
||||
buildCommand "org.jetbrains.kotlin.ui.kotlinBuilder"
|
||||
buildCommand "org.eclipse.jdt.core.javabuilder"
|
||||
natures "org.jetbrains.kotlin.core.kotlinNature"
|
||||
natures "org.eclipse.jdt.core.javanature"
|
||||
linkedResource name: "kotlin_bin", type: "2", locationUri: "org.jetbrains.kotlin.core.filesystem:/" + project.name + "/kotlin_bin"
|
||||
}
|
||||
classpath {
|
||||
containers "org.jetbrains.kotlin.core.KOTLIN_CONTAINER"
|
||||
}
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@file:JvmName("CoroutinesUtils")
|
||||
package org.springframework.core
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.reactive.awaitSingleOrNull
|
||||
import kotlinx.coroutines.reactor.asFlux
|
||||
|
||||
import kotlinx.coroutines.reactor.mono
|
||||
import org.reactivestreams.Publisher
|
||||
import reactor.core.publisher.Mono
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.lang.reflect.Method
|
||||
import kotlin.reflect.full.callSuspend
|
||||
import kotlin.reflect.jvm.kotlinFunction
|
||||
|
||||
/**
|
||||
* Convert a [Deferred] instance to a [Mono] one.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
internal fun <T: Any> deferredToMono(source: Deferred<T>) =
|
||||
mono(Dispatchers.Unconfined) { source.await() }
|
||||
|
||||
/**
|
||||
* Convert a [Mono] instance to a [Deferred] one.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
internal fun <T: Any> monoToDeferred(source: Mono<T>) =
|
||||
GlobalScope.async(Dispatchers.Unconfined) { source.awaitSingleOrNull() }
|
||||
|
||||
/**
|
||||
* Invoke a suspending function and converts it to [Mono] or [reactor.core.publisher.Flux].
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun invokeSuspendingFunction(method: Method, target: Any, vararg args: Any?): Publisher<*> {
|
||||
val function = method.kotlinFunction!!
|
||||
val mono = mono(Dispatchers.Unconfined) {
|
||||
function.callSuspend(target, *args.sliceArray(0..(args.size-2))).let { if (it == Unit) null else it }
|
||||
}.onErrorMap(InvocationTargetException::class.java) { it.targetException }
|
||||
return if (function.returnType.classifier == Flow::class) {
|
||||
mono.flatMapMany { (it as Flow<Any>).asFlux() }
|
||||
}
|
||||
else {
|
||||
mono
|
||||
}
|
||||
}
|
||||
@@ -13,20 +13,19 @@ def objenesisVersion = "3.2"
|
||||
configurations {
|
||||
cglib
|
||||
objenesis
|
||||
coroutines
|
||||
}
|
||||
|
||||
task cglibRepackJar(type: ShadowJar) {
|
||||
archiveBaseName = 'spring-cglib-repack'
|
||||
archiveVersion = cglibVersion
|
||||
archiveBaseName.set('spring-cglib-repack')
|
||||
archiveVersion.set(cglibVersion)
|
||||
configurations = [project.configurations.cglib]
|
||||
relocate 'net.sf.cglib', 'org.springframework.cglib'
|
||||
relocate 'org.objectweb.asm', 'org.springframework.asm'
|
||||
}
|
||||
|
||||
task objenesisRepackJar(type: ShadowJar) {
|
||||
archiveBaseName = 'spring-objenesis-repack'
|
||||
archiveVersion = objenesisVersion
|
||||
archiveBaseName.set('spring-objenesis-repack')
|
||||
archiveVersion.set(objenesisVersion)
|
||||
configurations = [project.configurations.objenesis]
|
||||
relocate 'org.objenesis', 'org.springframework.objenesis'
|
||||
}
|
||||
@@ -34,31 +33,31 @@ task objenesisRepackJar(type: ShadowJar) {
|
||||
dependencies {
|
||||
cglib("cglib:cglib:${cglibVersion}@jar")
|
||||
objenesis("org.objenesis:objenesis:${objenesisVersion}@jar")
|
||||
coroutines(project(path: ":kotlin-coroutines", configuration: 'classesOnlyElements'))
|
||||
compile(files(cglibRepackJar))
|
||||
compile(files(objenesisRepackJar))
|
||||
compile(project(":spring-jcl"))
|
||||
compileOnly(project(":kotlin-coroutines"))
|
||||
api(files(cglibRepackJar))
|
||||
api(files(objenesisRepackJar))
|
||||
api(project(":spring-jcl"))
|
||||
compileOnly("io.projectreactor.tools:blockhound")
|
||||
optional("net.sf.jopt-simple:jopt-simple")
|
||||
optional("org.aspectj:aspectjweaver")
|
||||
optional("org.jetbrains.kotlin:kotlin-reflect")
|
||||
optional("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
optional("org.jetbrains.kotlinx:kotlinx-coroutines-core")
|
||||
optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
|
||||
optional("io.projectreactor:reactor-core")
|
||||
optional("io.reactivex:rxjava")
|
||||
optional("io.reactivex:rxjava-reactive-streams")
|
||||
optional("io.reactivex.rxjava2:rxjava")
|
||||
optional("io.reactivex.rxjava3:rxjava")
|
||||
optional("io.smallrye.reactive:mutiny")
|
||||
optional("io.netty:netty-buffer")
|
||||
testCompile("io.projectreactor:reactor-test")
|
||||
testCompile("com.google.code.findbugs:jsr305")
|
||||
testCompile("javax.annotation:javax.annotation-api")
|
||||
testCompile("javax.xml.bind:jaxb-api")
|
||||
testCompile("com.fasterxml.woodstox:woodstox-core")
|
||||
testCompile("org.xmlunit:xmlunit-assertj")
|
||||
testCompile("org.xmlunit:xmlunit-matchers")
|
||||
testCompile(project(":kotlin-coroutines"))
|
||||
testCompile("io.projectreactor.tools:blockhound")
|
||||
testImplementation("io.projectreactor:reactor-test")
|
||||
testImplementation("com.google.code.findbugs:jsr305")
|
||||
testImplementation("javax.annotation:javax.annotation-api")
|
||||
testImplementation("javax.xml.bind:jaxb-api")
|
||||
testImplementation("com.fasterxml.woodstox:woodstox-core")
|
||||
testImplementation("org.xmlunit:xmlunit-assertj")
|
||||
testImplementation("org.xmlunit:xmlunit-matchers")
|
||||
testImplementation("io.projectreactor.tools:blockhound")
|
||||
testFixturesImplementation("io.projectreactor:reactor-test")
|
||||
testFixturesImplementation("com.google.code.findbugs:jsr305")
|
||||
testFixturesImplementation("org.junit.platform:junit-platform-launcher")
|
||||
@@ -90,8 +89,6 @@ jar {
|
||||
from(zipTree(objenesisRepackJar.archivePath)) {
|
||||
include "org/springframework/objenesis/**"
|
||||
}
|
||||
|
||||
from configurations.coroutines
|
||||
}
|
||||
|
||||
test {
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.BenchmarkMode;
|
||||
import org.openjdk.jmh.annotations.Level;
|
||||
import org.openjdk.jmh.annotations.Mode;
|
||||
import org.openjdk.jmh.annotations.Param;
|
||||
import org.openjdk.jmh.annotations.Scope;
|
||||
import org.openjdk.jmh.annotations.Setup;
|
||||
import org.openjdk.jmh.annotations.State;
|
||||
import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
/**
|
||||
* Benchmarks for {@link StringUtils}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
public class StringUtilsBenchmark {
|
||||
|
||||
@Benchmark
|
||||
public void collectionToDelimitedString(DelimitedStringState state, Blackhole bh) {
|
||||
bh.consume(StringUtils.collectionToCommaDelimitedString(state.elements));
|
||||
}
|
||||
|
||||
@State(Scope.Benchmark)
|
||||
public static class DelimitedStringState {
|
||||
|
||||
@Param("10")
|
||||
int elementMinSize;
|
||||
|
||||
@Param("20")
|
||||
int elementMaxSize;
|
||||
|
||||
@Param("10")
|
||||
int elementCount;
|
||||
|
||||
Collection<String> elements;
|
||||
|
||||
@Setup(Level.Iteration)
|
||||
public void setup() {
|
||||
Random random = new Random();
|
||||
this.elements = new ArrayList<>(this.elementCount);
|
||||
int bound = this.elementMaxSize - this.elementMinSize;
|
||||
for (int i = 0; i < this.elementCount; i++) {
|
||||
this.elements.add(String.format("%0" + (random.nextInt(bound) + this.elementMinSize) + "d", 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void cleanPath(CleanPathState state, Blackhole bh) {
|
||||
for (String path : state.paths) {
|
||||
bh.consume(StringUtils.cleanPath(path));
|
||||
}
|
||||
}
|
||||
|
||||
@State(Scope.Benchmark)
|
||||
public static class CleanPathState {
|
||||
|
||||
private static final List<String> SEGMENTS = Arrays.asList("some", "path", ".", "..", "springspring");
|
||||
|
||||
@Param("10")
|
||||
int segmentCount;
|
||||
|
||||
@Param("20")
|
||||
int pathsCount;
|
||||
|
||||
Collection<String> paths;
|
||||
|
||||
@Setup(Level.Iteration)
|
||||
public void setup() {
|
||||
this.paths = new ArrayList<>(this.pathsCount);
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < this.pathsCount; i++) {
|
||||
this.paths.add(createSamplePath(random));
|
||||
}
|
||||
}
|
||||
|
||||
private String createSamplePath(Random random) {
|
||||
String separator = random.nextBoolean() ? "/" : "\\";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("jar:file:///c:");
|
||||
for (int i = 0; i < this.segmentCount; i++) {
|
||||
sb.append(separator);
|
||||
sb.append(SEGMENTS.get(random.nextInt(SEGMENTS.size())));
|
||||
}
|
||||
sb.append(separator);
|
||||
sb.append("the%20file.txt");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,8 +38,8 @@ package org.springframework.asm;
|
||||
public abstract class AnnotationVisitor {
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
@@ -52,8 +52,8 @@ public abstract class AnnotationVisitor {
|
||||
/**
|
||||
* Constructs a new {@link AnnotationVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
public AnnotationVisitor(final int api) {
|
||||
this(api, null);
|
||||
@@ -62,8 +62,8 @@ public abstract class AnnotationVisitor {
|
||||
/**
|
||||
* Constructs a new {@link AnnotationVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param annotationVisitor the annotation visitor to which this visitor must delegate method
|
||||
* calls. May be {@literal null}.
|
||||
*/
|
||||
|
||||
@@ -352,6 +352,9 @@ public class ByteVector {
|
||||
* @param size number of additional bytes that this byte vector should be able to receive.
|
||||
*/
|
||||
private void enlarge(final int size) {
|
||||
if (length > data.length) {
|
||||
throw new AssertionError("Internal error");
|
||||
}
|
||||
int doubleCapacity = 2 * data.length;
|
||||
int minimalCapacity = length + size;
|
||||
byte[] newData = new byte[doubleCapacity > minimalCapacity ? doubleCapacity : minimalCapacity];
|
||||
|
||||
@@ -40,8 +40,8 @@ package org.springframework.asm;
|
||||
public abstract class ClassVisitor {
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
@@ -51,8 +51,8 @@ public abstract class ClassVisitor {
|
||||
/**
|
||||
* Constructs a new {@link ClassVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
public ClassVisitor(final int api) {
|
||||
this(api, null);
|
||||
@@ -61,9 +61,8 @@ public abstract class ClassVisitor {
|
||||
/**
|
||||
* Constructs a new {@link ClassVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param classVisitor the class visitor to which this visitor must delegate method calls. May be
|
||||
* null.
|
||||
*/
|
||||
|
||||
@@ -37,9 +37,8 @@ package org.springframework.asm;
|
||||
public abstract class FieldVisitor {
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
@@ -49,9 +48,8 @@ public abstract class FieldVisitor {
|
||||
/**
|
||||
* Constructs a new {@link FieldVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
public FieldVisitor(final int api) {
|
||||
this(api, null);
|
||||
@@ -60,9 +58,8 @@ public abstract class FieldVisitor {
|
||||
/**
|
||||
* Constructs a new {@link FieldVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7} or {@link
|
||||
* Opcodes#ASM8}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param fieldVisitor the field visitor to which this visitor must delegate method calls. May be
|
||||
* null.
|
||||
*/
|
||||
|
||||
@@ -51,8 +51,8 @@ public abstract class MethodVisitor {
|
||||
private static final String REQUIRES_ASM5 = "This feature requires ASM5";
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
@@ -64,8 +64,8 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Constructs a new {@link MethodVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
public MethodVisitor(final int api) {
|
||||
this(api, null);
|
||||
@@ -74,8 +74,8 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Constructs a new {@link MethodVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param methodVisitor the method visitor to which this visitor must delegate method calls. May
|
||||
* be null.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.JvmClassMappingKt;
|
||||
import kotlin.reflect.KClassifier;
|
||||
import kotlin.reflect.KFunction;
|
||||
import kotlin.reflect.full.KCallables;
|
||||
import kotlin.reflect.jvm.ReflectJvmMapping;
|
||||
import kotlinx.coroutines.BuildersKt;
|
||||
import kotlinx.coroutines.CoroutineStart;
|
||||
import kotlinx.coroutines.Deferred;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
import kotlinx.coroutines.GlobalScope;
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
import kotlinx.coroutines.reactor.MonoKt;
|
||||
import kotlinx.coroutines.reactor.ReactorFlowKt;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* Utilities for working with Kotlin Coroutines.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Phillip Webb
|
||||
* @since 5.2
|
||||
*/
|
||||
public abstract class CoroutinesUtils {
|
||||
|
||||
/**
|
||||
* Convert a {@link Deferred} instance to a {@link Mono}.
|
||||
*/
|
||||
public static <T> Mono<T> deferredToMono(Deferred<T> source) {
|
||||
return MonoKt.mono(Dispatchers.getUnconfined(),
|
||||
(scope, continuation) -> source.await(continuation));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a {@link Mono} instance to a {@link Deferred}.
|
||||
*/
|
||||
public static <T> Deferred<T> monoToDeferred(Mono<T> source) {
|
||||
return BuildersKt.async(GlobalScope.INSTANCE, Dispatchers.getUnconfined(),
|
||||
CoroutineStart.DEFAULT,
|
||||
(scope, continuation) -> MonoKt.awaitSingleOrNull(source, continuation));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke a suspending function and converts it to {@link Mono} or
|
||||
* {@link Flux}.
|
||||
*/
|
||||
public static Publisher<?> invokeSuspendingFunction(Method method, Object target, Object... args) {
|
||||
KFunction<?> function = Objects.requireNonNull(ReflectJvmMapping.getKotlinFunction(method));
|
||||
KClassifier classifier = function.getReturnType().getClassifier();
|
||||
Mono<Object> mono = MonoKt.mono(Dispatchers.getUnconfined(), (scope, continuation) ->
|
||||
KCallables.callSuspend(function, getSuspendedFunctionArgs(target, args), continuation))
|
||||
.filter(result -> !Objects.equals(result, Unit.INSTANCE))
|
||||
.onErrorMap(InvocationTargetException.class, InvocationTargetException::getTargetException);
|
||||
if (classifier != null && classifier.equals(JvmClassMappingKt.getKotlinClass(Flow.class))) {
|
||||
return mono.flatMapMany(CoroutinesUtils::asFlux);
|
||||
}
|
||||
return mono;
|
||||
}
|
||||
|
||||
private static Object[] getSuspendedFunctionArgs(Object target, Object... args) {
|
||||
Object[] functionArgs = new Object[args.length];
|
||||
functionArgs[0] = target;
|
||||
System.arraycopy(args, 0, functionArgs, 1, args.length - 1);
|
||||
return functionArgs;
|
||||
}
|
||||
|
||||
private static Flux<?> asFlux(Object flow) {
|
||||
return ReactorFlowKt.asFlux(((Flow<?>) flow));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,6 +72,8 @@ public class ReactiveAdapterRegistry {
|
||||
|
||||
private static final boolean kotlinCoroutinesPresent;
|
||||
|
||||
private static final boolean mutinyPresent;
|
||||
|
||||
static {
|
||||
ClassLoader classLoader = ReactiveAdapterRegistry.class.getClassLoader();
|
||||
reactorPresent = ClassUtils.isPresent("reactor.core.publisher.Flux", classLoader);
|
||||
@@ -81,6 +83,7 @@ public class ReactiveAdapterRegistry {
|
||||
rxjava3Present = ClassUtils.isPresent("io.reactivex.rxjava3.core.Flowable", classLoader);
|
||||
flowPublisherPresent = ClassUtils.isPresent("java.util.concurrent.Flow.Publisher", classLoader);
|
||||
kotlinCoroutinesPresent = ClassUtils.isPresent("kotlinx.coroutines.reactor.MonoKt", classLoader);
|
||||
mutinyPresent = ClassUtils.isPresent("io.smallrye.mutiny.Multi", classLoader);
|
||||
}
|
||||
|
||||
private final List<ReactiveAdapter> adapters = new ArrayList<>();
|
||||
@@ -121,6 +124,11 @@ public class ReactiveAdapterRegistry {
|
||||
if (reactorPresent && kotlinCoroutinesPresent) {
|
||||
new CoroutinesRegistrar().registerAdapters(this);
|
||||
}
|
||||
|
||||
// SmallRye Mutiny
|
||||
if (mutinyPresent) {
|
||||
new MutinyRegistrar().registerAdapters(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -418,6 +426,28 @@ public class ReactiveAdapterRegistry {
|
||||
}
|
||||
|
||||
|
||||
private static class MutinyRegistrar {
|
||||
|
||||
void registerAdapters(ReactiveAdapterRegistry registry) {
|
||||
registry.registerReactiveType(
|
||||
ReactiveTypeDescriptor.singleOptionalValue(
|
||||
io.smallrye.mutiny.Uni.class,
|
||||
() -> io.smallrye.mutiny.Uni.createFrom().nothing()),
|
||||
uni -> ((io.smallrye.mutiny.Uni<?>) uni).convert().toPublisher(),
|
||||
publisher -> io.smallrye.mutiny.Uni.createFrom().publisher(publisher)
|
||||
);
|
||||
|
||||
registry.registerReactiveType(
|
||||
ReactiveTypeDescriptor.multiValue(
|
||||
io.smallrye.mutiny.Multi.class,
|
||||
() -> io.smallrye.mutiny.Multi.createFrom().empty()),
|
||||
multi -> (io.smallrye.mutiny.Multi<?>) multi,
|
||||
publisher -> io.smallrye.mutiny.Multi.createFrom().publisher(publisher)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@code BlockHoundIntegration} for spring-core classes.
|
||||
* <p>Explicitly allow the following:
|
||||
|
||||
@@ -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.
|
||||
@@ -174,7 +174,7 @@ public class ConcurrentLruCache<K, V> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the the maximum number of entries in the cache
|
||||
* Return the maximum number of entries in the cache
|
||||
* (0 indicates no caching, always generating a new value).
|
||||
* @see #size()
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
@@ -114,7 +114,7 @@ public abstract class ObjectUtils {
|
||||
* Determine whether the given object is empty.
|
||||
* <p>This method supports the following object types.
|
||||
* <ul>
|
||||
* <li>{@code Optional}: considered empty if {@link Optional#empty()}</li>
|
||||
* <li>{@code Optional}: considered empty if not {@link Optional#isPresent()}</li>
|
||||
* <li>{@code Array}: considered empty if its length is zero</li>
|
||||
* <li>{@link CharSequence}: considered empty if its length is zero</li>
|
||||
* <li>{@link Collection}: delegates to {@link Collection#isEmpty()}</li>
|
||||
|
||||
@@ -667,7 +667,9 @@ public abstract class StringUtils {
|
||||
if (!hasLength(path)) {
|
||||
return path;
|
||||
}
|
||||
String pathToUse = replace(path, WINDOWS_FOLDER_SEPARATOR, FOLDER_SEPARATOR);
|
||||
|
||||
String normalizedPath = replace(path, WINDOWS_FOLDER_SEPARATOR, FOLDER_SEPARATOR);
|
||||
String pathToUse = normalizedPath;
|
||||
|
||||
// Shortcut if there is no work to do
|
||||
if (pathToUse.indexOf('.') == -1) {
|
||||
@@ -695,7 +697,8 @@ public abstract class StringUtils {
|
||||
}
|
||||
|
||||
String[] pathArray = delimitedListToStringArray(pathToUse, FOLDER_SEPARATOR);
|
||||
Deque<String> pathElements = new ArrayDeque<>();
|
||||
// we never require more elements than pathArray and in the common case the same number
|
||||
Deque<String> pathElements = new ArrayDeque<>(pathArray.length);
|
||||
int tops = 0;
|
||||
|
||||
for (int i = pathArray.length - 1; i >= 0; i--) {
|
||||
@@ -721,7 +724,7 @@ public abstract class StringUtils {
|
||||
|
||||
// All path elements stayed the same - shortcut
|
||||
if (pathArray.length == pathElements.size()) {
|
||||
return prefix + pathToUse;
|
||||
return normalizedPath;
|
||||
}
|
||||
// Remaining top paths need to be retained.
|
||||
for (int i = 0; i < tops; i++) {
|
||||
@@ -732,7 +735,9 @@ public abstract class StringUtils {
|
||||
pathElements.addFirst(CURRENT_PATH);
|
||||
}
|
||||
|
||||
return prefix + collectionToDelimitedString(pathElements, FOLDER_SEPARATOR);
|
||||
final String joined = collectionToDelimitedString(pathElements, FOLDER_SEPARATOR);
|
||||
// avoid string concatenation with empty prefix
|
||||
return prefix.isEmpty() ? joined : prefix + joined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1294,7 +1299,12 @@ public abstract class StringUtils {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int totalLength = coll.size() * (prefix.length() + suffix.length()) + (coll.size() - 1) * delim.length();
|
||||
for (Object element : coll) {
|
||||
totalLength += element.toString().length();
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder(totalLength);
|
||||
Iterator<?> it = coll.iterator();
|
||||
while (it.hasNext()) {
|
||||
sb.append(prefix).append(it.next()).append(suffix);
|
||||
|
||||
+64
-14
@@ -21,6 +21,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import io.smallrye.mutiny.Multi;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import kotlinx.coroutines.Deferred;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -38,6 +40,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@SuppressWarnings("unchecked")
|
||||
class ReactiveAdapterRegistryTests {
|
||||
|
||||
private static final Duration ONE_SECOND = Duration.ofSeconds(1);
|
||||
|
||||
|
||||
private final ReactiveAdapterRegistry registry = ReactiveAdapterRegistry.getSharedInstance();
|
||||
|
||||
|
||||
@@ -83,7 +88,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Publisher<Integer> source = io.reactivex.rxjava3.core.Flowable.fromIterable(sequence);
|
||||
Object target = getAdapter(Flux.class).fromPublisher(source);
|
||||
assertThat(target instanceof Flux).isTrue();
|
||||
assertThat(((Flux<Integer>) target).collectList().block(Duration.ofMillis(1000))).isEqualTo(sequence);
|
||||
assertThat(((Flux<Integer>) target).collectList().block(ONE_SECOND)).isEqualTo(sequence);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,7 +96,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Publisher<Integer> source = io.reactivex.rxjava3.core.Flowable.fromArray(1, 2, 3);
|
||||
Object target = getAdapter(Mono.class).fromPublisher(source);
|
||||
assertThat(target instanceof Mono).isTrue();
|
||||
assertThat(((Mono<Integer>) target).block(Duration.ofMillis(1000))).isEqualTo(Integer.valueOf(1));
|
||||
assertThat(((Mono<Integer>) target).block(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,7 +113,7 @@ class ReactiveAdapterRegistryTests {
|
||||
future.complete(1);
|
||||
Object target = getAdapter(CompletableFuture.class).toPublisher(future);
|
||||
assertThat(target instanceof Mono).as("Expected Mono Publisher: " + target.getClass().getName()).isTrue();
|
||||
assertThat(((Mono<Integer>) target).block(Duration.ofMillis(1000))).isEqualTo(Integer.valueOf(1));
|
||||
assertThat(((Mono<Integer>) target).block(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +158,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Object source = rx.Observable.from(sequence);
|
||||
Object target = getAdapter(rx.Observable.class).toPublisher(source);
|
||||
assertThat(target instanceof Flux).as("Expected Flux Publisher: " + target.getClass().getName()).isTrue();
|
||||
assertThat(((Flux<Integer>) target).collectList().block(Duration.ofMillis(1000))).isEqualTo(sequence);
|
||||
assertThat(((Flux<Integer>) target).collectList().block(ONE_SECOND)).isEqualTo(sequence);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,7 +166,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Object source = rx.Single.just(1);
|
||||
Object target = getAdapter(rx.Single.class).toPublisher(source);
|
||||
assertThat(target instanceof Mono).as("Expected Mono Publisher: " + target.getClass().getName()).isTrue();
|
||||
assertThat(((Mono<Integer>) target).block(Duration.ofMillis(1000))).isEqualTo(Integer.valueOf(1));
|
||||
assertThat(((Mono<Integer>) target).block(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -169,7 +174,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Object source = rx.Completable.complete();
|
||||
Object target = getAdapter(rx.Completable.class).toPublisher(source);
|
||||
assertThat(target instanceof Mono).as("Expected Mono Publisher: " + target.getClass().getName()).isTrue();
|
||||
((Mono<Void>) target).block(Duration.ofMillis(1000));
|
||||
((Mono<Void>) target).block(ONE_SECOND);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +232,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Object source = io.reactivex.Flowable.fromIterable(sequence);
|
||||
Object target = getAdapter(io.reactivex.Flowable.class).toPublisher(source);
|
||||
assertThat(target instanceof Flux).as("Expected Flux Publisher: " + target.getClass().getName()).isTrue();
|
||||
assertThat(((Flux<Integer>) target).collectList().block(Duration.ofMillis(1000))).isEqualTo(sequence);
|
||||
assertThat(((Flux<Integer>) target).collectList().block(ONE_SECOND)).isEqualTo(sequence);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -236,7 +241,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Object source = io.reactivex.Observable.fromIterable(sequence);
|
||||
Object target = getAdapter(io.reactivex.Observable.class).toPublisher(source);
|
||||
assertThat(target instanceof Flux).as("Expected Flux Publisher: " + target.getClass().getName()).isTrue();
|
||||
assertThat(((Flux<Integer>) target).collectList().block(Duration.ofMillis(1000))).isEqualTo(sequence);
|
||||
assertThat(((Flux<Integer>) target).collectList().block(ONE_SECOND)).isEqualTo(sequence);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -244,7 +249,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Object source = io.reactivex.Single.just(1);
|
||||
Object target = getAdapter(io.reactivex.Single.class).toPublisher(source);
|
||||
assertThat(target instanceof Mono).as("Expected Mono Publisher: " + target.getClass().getName()).isTrue();
|
||||
assertThat(((Mono<Integer>) target).block(Duration.ofMillis(1000))).isEqualTo(Integer.valueOf(1));
|
||||
assertThat(((Mono<Integer>) target).block(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -252,7 +257,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Object source = io.reactivex.Completable.complete();
|
||||
Object target = getAdapter(io.reactivex.Completable.class).toPublisher(source);
|
||||
assertThat(target instanceof Mono).as("Expected Mono Publisher: " + target.getClass().getName()).isTrue();
|
||||
((Mono<Void>) target).block(Duration.ofMillis(1000));
|
||||
((Mono<Void>) target).block(ONE_SECOND);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,7 +315,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Object source = io.reactivex.rxjava3.core.Flowable.fromIterable(sequence);
|
||||
Object target = getAdapter(io.reactivex.rxjava3.core.Flowable.class).toPublisher(source);
|
||||
assertThat(target instanceof Flux).as("Expected Flux Publisher: " + target.getClass().getName()).isTrue();
|
||||
assertThat(((Flux<Integer>) target).collectList().block(Duration.ofMillis(1000))).isEqualTo(sequence);
|
||||
assertThat(((Flux<Integer>) target).collectList().block(ONE_SECOND)).isEqualTo(sequence);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -319,7 +324,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Object source = io.reactivex.rxjava3.core.Observable.fromIterable(sequence);
|
||||
Object target = getAdapter(io.reactivex.rxjava3.core.Observable.class).toPublisher(source);
|
||||
assertThat(target instanceof Flux).as("Expected Flux Publisher: " + target.getClass().getName()).isTrue();
|
||||
assertThat(((Flux<Integer>) target).collectList().block(Duration.ofMillis(1000))).isEqualTo(sequence);
|
||||
assertThat(((Flux<Integer>) target).collectList().block(ONE_SECOND)).isEqualTo(sequence);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -327,7 +332,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Object source = io.reactivex.rxjava3.core.Single.just(1);
|
||||
Object target = getAdapter(io.reactivex.rxjava3.core.Single.class).toPublisher(source);
|
||||
assertThat(target instanceof Mono).as("Expected Mono Publisher: " + target.getClass().getName()).isTrue();
|
||||
assertThat(((Mono<Integer>) target).block(Duration.ofMillis(1000))).isEqualTo(Integer.valueOf(1));
|
||||
assertThat(((Mono<Integer>) target).block(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -335,7 +340,7 @@ class ReactiveAdapterRegistryTests {
|
||||
Object source = io.reactivex.rxjava3.core.Completable.complete();
|
||||
Object target = getAdapter(io.reactivex.rxjava3.core.Completable.class).toPublisher(source);
|
||||
assertThat(target instanceof Mono).as("Expected Mono Publisher: " + target.getClass().getName()).isTrue();
|
||||
((Mono<Void>) target).block(Duration.ofMillis(1000));
|
||||
((Mono<Void>) target).block(ONE_SECOND);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,6 +362,51 @@ class ReactiveAdapterRegistryTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class Mutiny {
|
||||
|
||||
@Test
|
||||
void defaultAdapterRegistrations() {
|
||||
assertThat(getAdapter(io.smallrye.mutiny.Uni.class)).isNotNull();
|
||||
assertThat(getAdapter(io.smallrye.mutiny.Multi.class)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void toUni() {
|
||||
Publisher<Integer> source = Mono.just(1);
|
||||
Object target = getAdapter(Uni.class).fromPublisher(source);
|
||||
assertThat(target).isInstanceOf(Uni.class);
|
||||
assertThat(((Uni<Integer>) target).await().atMost(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromUni() {
|
||||
Uni<Integer> source = Uni.createFrom().item(1);
|
||||
Object target = getAdapter(Uni.class).toPublisher(source);
|
||||
assertThat(target).isInstanceOf(Mono.class);
|
||||
assertThat(((Mono<Integer>) target).block(ONE_SECOND)).isEqualTo(Integer.valueOf(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void toMulti() {
|
||||
List<Integer> sequence = Arrays.asList(1, 2, 3);
|
||||
Publisher<Integer> source = Flux.fromIterable(sequence);
|
||||
Object target = getAdapter(Multi.class).fromPublisher(source);
|
||||
assertThat(target).isInstanceOf(Multi.class);
|
||||
assertThat(((Multi<Integer>) target).collect().asList().await().atMost(ONE_SECOND)).isEqualTo(sequence);
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromMulti() {
|
||||
List<Integer> sequence = Arrays.asList(1, 2, 3);
|
||||
Multi<Integer> source = Multi.createFrom().iterable(sequence);
|
||||
Object target = getAdapter(Multi.class).toPublisher(source);
|
||||
assertThat(target).isInstanceOf(Flux.class);
|
||||
assertThat(((Flux<Integer>) target).blockLast(ONE_SECOND)).isEqualTo(Integer.valueOf(3));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ReactiveAdapter getAdapter(Class<?> reactiveType) {
|
||||
ReactiveAdapter adapter = this.registry.getAdapter(reactiveType);
|
||||
assertThat(adapter).isNotNull();
|
||||
|
||||
@@ -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.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -109,7 +108,7 @@ class ObjectUtilsTests {
|
||||
Set<String> set = new HashSet<>();
|
||||
set.add("foo");
|
||||
assertThat(isEmpty(set)).isFalse();
|
||||
assertThat(isEmpty(Arrays.asList("foo"))).isFalse();
|
||||
assertThat(isEmpty(Collections.singletonList("foo"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -159,7 +158,7 @@ class ObjectUtilsTests {
|
||||
void toObjectArrayWithEmptyPrimitiveArray() {
|
||||
Object[] objects = ObjectUtils.toObjectArray(new byte[] {});
|
||||
assertThat(objects).isNotNull();
|
||||
assertThat(objects.length).isEqualTo(0);
|
||||
assertThat(objects).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,7 +178,7 @@ class ObjectUtilsTests {
|
||||
String[] array = new String[] {"foo", "bar"};
|
||||
String newElement = "baz";
|
||||
Object[] newArray = ObjectUtils.addObjectToArray(array, newElement);
|
||||
assertThat(newArray.length).isEqualTo(3);
|
||||
assertThat(newArray).hasSize(3);
|
||||
assertThat(newArray[2]).isEqualTo(newElement);
|
||||
}
|
||||
|
||||
@@ -188,7 +187,7 @@ class ObjectUtilsTests {
|
||||
String[] array = new String[0];
|
||||
String newElement = "foo";
|
||||
String[] newArray = ObjectUtils.addObjectToArray(array, newElement);
|
||||
assertThat(newArray.length).isEqualTo(1);
|
||||
assertThat(newArray).hasSize(1);
|
||||
assertThat(newArray[0]).isEqualTo(newElement);
|
||||
}
|
||||
|
||||
@@ -198,7 +197,7 @@ class ObjectUtilsTests {
|
||||
String[] array = new String[] {existingElement};
|
||||
String newElement = "bar";
|
||||
String[] newArray = ObjectUtils.addObjectToArray(array, newElement);
|
||||
assertThat(newArray.length).isEqualTo(2);
|
||||
assertThat(newArray).hasSize(2);
|
||||
assertThat(newArray[0]).isEqualTo(existingElement);
|
||||
assertThat(newArray[1]).isEqualTo(newElement);
|
||||
}
|
||||
@@ -208,8 +207,8 @@ class ObjectUtilsTests {
|
||||
String[] array = new String[] {null};
|
||||
String newElement = "bar";
|
||||
String[] newArray = ObjectUtils.addObjectToArray(array, newElement);
|
||||
assertThat(newArray.length).isEqualTo(2);
|
||||
assertThat(newArray[0]).isEqualTo(null);
|
||||
assertThat(newArray).hasSize(2);
|
||||
assertThat(newArray[0]).isNull();
|
||||
assertThat(newArray[1]).isEqualTo(newElement);
|
||||
}
|
||||
|
||||
@@ -217,15 +216,15 @@ class ObjectUtilsTests {
|
||||
void addObjectToNullArray() throws Exception {
|
||||
String newElement = "foo";
|
||||
String[] newArray = ObjectUtils.addObjectToArray(null, newElement);
|
||||
assertThat(newArray.length).isEqualTo(1);
|
||||
assertThat(newArray).hasSize(1);
|
||||
assertThat(newArray[0]).isEqualTo(newElement);
|
||||
}
|
||||
|
||||
@Test
|
||||
void addNullObjectToNullArray() throws Exception {
|
||||
Object[] newArray = ObjectUtils.addObjectToArray(null, null);
|
||||
assertThat(newArray.length).isEqualTo(1);
|
||||
assertThat(newArray[0]).isEqualTo(null);
|
||||
assertThat(newArray).hasSize(1);
|
||||
assertThat(newArray[0]).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -260,7 +259,7 @@ class ObjectUtilsTests {
|
||||
@Deprecated
|
||||
void hashCodeWithFloat() {
|
||||
float flt = 34.8f;
|
||||
int expected = (new Float(flt)).hashCode();
|
||||
int expected = (Float.valueOf(flt)).hashCode();
|
||||
assertThat(ObjectUtils.hashCode(flt)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@@ -268,7 +267,7 @@ class ObjectUtilsTests {
|
||||
@Deprecated
|
||||
void hashCodeWithLong() {
|
||||
long lng = 883L;
|
||||
int expected = (new Long(lng)).hashCode();
|
||||
int expected = (Long.valueOf(lng)).hashCode();
|
||||
assertThat(ObjectUtils.hashCode(lng)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@@ -282,7 +281,7 @@ class ObjectUtilsTests {
|
||||
|
||||
@Test
|
||||
void identityToStringWithNullObject() {
|
||||
assertThat(ObjectUtils.identityToString(null)).isEqualTo("");
|
||||
assertThat(ObjectUtils.identityToString(null)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -402,6 +402,8 @@ class StringUtilsTests {
|
||||
assertThat(StringUtils.cleanPath("file:.././")).isEqualTo("file:../");
|
||||
assertThat(StringUtils.cleanPath("file:/mypath/spring.factories")).isEqualTo("file:/mypath/spring.factories");
|
||||
assertThat(StringUtils.cleanPath("file:///c:/some/../path/the%20file.txt")).isEqualTo("file:///c:/path/the%20file.txt");
|
||||
assertThat(StringUtils.cleanPath("jar:file:///c:\\some\\..\\path\\.\\the%20file.txt")).isEqualTo("jar:file:///c:/path/the%20file.txt");
|
||||
assertThat(StringUtils.cleanPath("jar:file:///c:/some/../path/./the%20file.txt")).isEqualTo("jar:file:///c:/path/the%20file.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core.testfixture;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
||||
|
||||
/**
|
||||
* Utility methods that allow JUnit tests to assume certain conditions hold
|
||||
* {@code true}. If an assumption fails, it means the test should be aborted.
|
||||
*
|
||||
* @author Rob Winch
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
* @since 3.2
|
||||
* @see #notLogging(Log)
|
||||
* @see EnabledForTestGroups @EnabledForTestGroups
|
||||
*/
|
||||
public abstract class Assume {
|
||||
|
||||
/**
|
||||
* Assume that the specified log is not set to Trace or Debug.
|
||||
* @param log the log to test
|
||||
* @throws org.opentest4j.TestAbortedException if the assumption fails
|
||||
*/
|
||||
public static void notLogging(Log log) {
|
||||
assumeFalse(log.isTraceEnabled());
|
||||
assumeFalse(log.isDebugEnabled());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,8 @@ description = "Spring Expression Language (SpEL)"
|
||||
apply plugin: "kotlin"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-core"))
|
||||
testCompile(testFixtures(project(":spring-core")))
|
||||
testCompile("org.jetbrains.kotlin:kotlin-reflect")
|
||||
testCompile("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
api(project(":spring-core"))
|
||||
testImplementation(testFixtures(project(":spring-core")))
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
}
|
||||
|
||||
+19
-18
@@ -57,7 +57,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ConstructorReference extends SpelNodeImpl {
|
||||
|
||||
private boolean isArrayConstructor = false;
|
||||
private final boolean isArrayConstructor;
|
||||
|
||||
@Nullable
|
||||
private SpelNodeImpl[] dimensions;
|
||||
@@ -234,6 +234,7 @@ public class ConstructorReference extends SpelNodeImpl {
|
||||
FormatHelper.formatClassNameForMessage(
|
||||
intendedArrayType != null ? intendedArrayType.getClass() : null));
|
||||
}
|
||||
|
||||
String type = (String) intendedArrayType;
|
||||
Class<?> componentType;
|
||||
TypeCode arrayTypeCode = TypeCode.forName(type);
|
||||
@@ -243,7 +244,8 @@ public class ConstructorReference extends SpelNodeImpl {
|
||||
else {
|
||||
componentType = arrayTypeCode.getType();
|
||||
}
|
||||
Object newArray;
|
||||
|
||||
Object newArray = null;
|
||||
if (!hasInitializer()) {
|
||||
// Confirm all dimensions were specified (for example [3][][5] is missing the 2nd dimension)
|
||||
if (this.dimensions != null) {
|
||||
@@ -252,23 +254,22 @@ public class ConstructorReference extends SpelNodeImpl {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.MISSING_ARRAY_DIMENSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
TypeConverter typeConverter = state.getEvaluationContext().getTypeConverter();
|
||||
|
||||
// Shortcut for 1 dimensional
|
||||
if (this.dimensions.length == 1) {
|
||||
TypedValue o = this.dimensions[0].getTypedValue(state);
|
||||
int arraySize = ExpressionUtils.toInt(typeConverter, o);
|
||||
newArray = Array.newInstance(componentType, arraySize);
|
||||
}
|
||||
else {
|
||||
// Multi-dimensional - hold onto your hat!
|
||||
int[] dims = new int[this.dimensions.length];
|
||||
for (int d = 0; d < this.dimensions.length; d++) {
|
||||
TypedValue o = this.dimensions[d].getTypedValue(state);
|
||||
dims[d] = ExpressionUtils.toInt(typeConverter, o);
|
||||
TypeConverter typeConverter = state.getEvaluationContext().getTypeConverter();
|
||||
if (this.dimensions.length == 1) {
|
||||
// Shortcut for 1-dimensional
|
||||
TypedValue o = this.dimensions[0].getTypedValue(state);
|
||||
int arraySize = ExpressionUtils.toInt(typeConverter, o);
|
||||
newArray = Array.newInstance(componentType, arraySize);
|
||||
}
|
||||
else {
|
||||
// Multi-dimensional - hold onto your hat!
|
||||
int[] dims = new int[this.dimensions.length];
|
||||
for (int d = 0; d < this.dimensions.length; d++) {
|
||||
TypedValue o = this.dimensions[d].getTypedValue(state);
|
||||
dims[d] = ExpressionUtils.toInt(typeConverter, o);
|
||||
}
|
||||
newArray = Array.newInstance(componentType, dims);
|
||||
}
|
||||
newArray = Array.newInstance(componentType, dims);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
+26
-26
@@ -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.
|
||||
@@ -41,11 +41,11 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class IndexingTests {
|
||||
class IndexingTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void indexIntoGenericPropertyContainingMap() {
|
||||
void indexIntoGenericPropertyContainingMap() {
|
||||
Map<String, String> property = new HashMap<>();
|
||||
property.put("foo", "bar");
|
||||
this.property = property;
|
||||
@@ -63,7 +63,7 @@ public class IndexingTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void indexIntoGenericPropertyContainingMapObject() {
|
||||
void indexIntoGenericPropertyContainingMapObject() {
|
||||
Map<String, Map<String, String>> property = new HashMap<>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("foo", "bar");
|
||||
@@ -112,7 +112,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setGenericPropertyContainingMap() {
|
||||
void setGenericPropertyContainingMap() {
|
||||
Map<String, String> property = new HashMap<>();
|
||||
property.put("foo", "bar");
|
||||
this.property = property;
|
||||
@@ -127,7 +127,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setPropertyContainingMap() {
|
||||
void setPropertyContainingMap() {
|
||||
Map<Integer, Integer> property = new HashMap<>();
|
||||
property.put(9, 3);
|
||||
this.parameterizedMap = property;
|
||||
@@ -144,7 +144,7 @@ public class IndexingTests {
|
||||
public Map<Integer, Integer> parameterizedMap;
|
||||
|
||||
@Test
|
||||
public void setPropertyContainingMapAutoGrow() {
|
||||
void setPropertyContainingMapAutoGrow() {
|
||||
SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, false));
|
||||
Expression expression = parser.parseExpression("parameterizedMap");
|
||||
assertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("java.util.Map<java.lang.Integer, java.lang.Integer>");
|
||||
@@ -156,7 +156,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void indexIntoGenericPropertyContainingList() {
|
||||
void indexIntoGenericPropertyContainingList() {
|
||||
List<String> property = new ArrayList<>();
|
||||
property.add("bar");
|
||||
this.property = property;
|
||||
@@ -169,7 +169,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setGenericPropertyContainingList() {
|
||||
void setGenericPropertyContainingList() {
|
||||
List<Integer> property = new ArrayList<>();
|
||||
property.add(3);
|
||||
this.property = property;
|
||||
@@ -184,7 +184,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setGenericPropertyContainingListAutogrow() {
|
||||
void setGenericPropertyContainingListAutogrow() {
|
||||
List<Integer> property = new ArrayList<>();
|
||||
this.property = property;
|
||||
SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
|
||||
@@ -203,7 +203,7 @@ public class IndexingTests {
|
||||
public List<BigDecimal> decimals;
|
||||
|
||||
@Test
|
||||
public void autoGrowListOfElementsWithoutDefaultConstructor() {
|
||||
void autoGrowListOfElementsWithoutDefaultConstructor() {
|
||||
this.decimals = new ArrayList<>();
|
||||
SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
|
||||
parser.parseExpression("decimals[0]").setValue(this, "123.4");
|
||||
@@ -211,7 +211,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void indexIntoPropertyContainingListContainingNullElement() {
|
||||
void indexIntoPropertyContainingListContainingNullElement() {
|
||||
this.decimals = new ArrayList<>();
|
||||
this.decimals.add(null);
|
||||
this.decimals.add(BigDecimal.ONE);
|
||||
@@ -221,7 +221,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void indexIntoPropertyContainingList() {
|
||||
void indexIntoPropertyContainingList() {
|
||||
List<Integer> property = new ArrayList<>();
|
||||
property.add(3);
|
||||
this.parameterizedList = property;
|
||||
@@ -236,7 +236,7 @@ public class IndexingTests {
|
||||
public List<Integer> parameterizedList;
|
||||
|
||||
@Test
|
||||
public void indexIntoPropertyContainingListOfList() {
|
||||
void indexIntoPropertyContainingListOfList() {
|
||||
List<List<Integer>> property = new ArrayList<>();
|
||||
property.add(Arrays.asList(3));
|
||||
this.parameterizedListOfList = property;
|
||||
@@ -251,7 +251,7 @@ public class IndexingTests {
|
||||
public List<List<Integer>> parameterizedListOfList;
|
||||
|
||||
@Test
|
||||
public void setPropertyContainingList() {
|
||||
void setPropertyContainingList() {
|
||||
List<Integer> property = new ArrayList<>();
|
||||
property.add(3);
|
||||
this.parameterizedList = property;
|
||||
@@ -266,7 +266,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void indexIntoGenericPropertyContainingNullList() {
|
||||
void indexIntoGenericPropertyContainingNullList() {
|
||||
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
|
||||
SpelExpressionParser parser = new SpelExpressionParser(configuration);
|
||||
Expression expression = parser.parseExpression("property");
|
||||
@@ -282,7 +282,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void indexIntoGenericPropertyContainingGrowingList() {
|
||||
void indexIntoGenericPropertyContainingGrowingList() {
|
||||
List<String> property = new ArrayList<>();
|
||||
this.property = property;
|
||||
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
|
||||
@@ -300,7 +300,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void indexIntoGenericPropertyContainingGrowingList2() {
|
||||
void indexIntoGenericPropertyContainingGrowingList2() {
|
||||
List<String> property2 = new ArrayList<>();
|
||||
this.property2 = property2;
|
||||
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
|
||||
@@ -320,7 +320,7 @@ public class IndexingTests {
|
||||
public List property2;
|
||||
|
||||
@Test
|
||||
public void indexIntoGenericPropertyContainingArray() {
|
||||
void indexIntoGenericPropertyContainingArray() {
|
||||
String[] property = new String[] { "bar" };
|
||||
this.property = property;
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
@@ -332,7 +332,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyList() {
|
||||
void emptyList() {
|
||||
listOfScalarNotGeneric = new ArrayList();
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
Expression expression = parser.parseExpression("listOfScalarNotGeneric");
|
||||
@@ -342,7 +342,7 @@ public class IndexingTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void resolveCollectionElementType() {
|
||||
void resolveCollectionElementType() {
|
||||
listNotGeneric = new ArrayList(2);
|
||||
listNotGeneric.add(5);
|
||||
listNotGeneric.add(6);
|
||||
@@ -353,7 +353,7 @@ public class IndexingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveCollectionElementTypeNull() {
|
||||
void resolveCollectionElementTypeNull() {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
Expression expression = parser.parseExpression("listNotGeneric");
|
||||
assertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.List<?>");
|
||||
@@ -370,7 +370,7 @@ public class IndexingTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void resolveMapKeyValueTypes() {
|
||||
void resolveMapKeyValueTypes() {
|
||||
mapNotGeneric = new HashMap();
|
||||
mapNotGeneric.put("baseAmount", 3.11);
|
||||
mapNotGeneric.put("bonusAmount", 7.17);
|
||||
@@ -384,12 +384,12 @@ public class IndexingTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testListOfScalar() {
|
||||
void testListOfScalar() {
|
||||
listOfScalarNotGeneric = new ArrayList(1);
|
||||
listOfScalarNotGeneric.add("5");
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
Expression expression = parser.parseExpression("listOfScalarNotGeneric[0]");
|
||||
assertThat(expression.getValue(this, Integer.class)).isEqualTo(new Integer(5));
|
||||
assertThat(expression.getValue(this, Integer.class)).isEqualTo(Integer.valueOf(5));
|
||||
}
|
||||
|
||||
public List listOfScalarNotGeneric;
|
||||
@@ -397,7 +397,7 @@ public class IndexingTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testListsOfMap() {
|
||||
void testListsOfMap() {
|
||||
listOfMapsNotGeneric = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("fruit", "apple");
|
||||
|
||||
+34
-34
@@ -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.
|
||||
@@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Juergen Hoeller
|
||||
* @author Giovanni Dall'Oglio Risso
|
||||
*/
|
||||
public class OperatorTests extends AbstractExpressionTests {
|
||||
class OperatorTests extends AbstractExpressionTests {
|
||||
|
||||
@Test
|
||||
public void testEqual() {
|
||||
void testEqual() {
|
||||
evaluate("3 == 5", false, Boolean.class);
|
||||
evaluate("5 == 3", false, Boolean.class);
|
||||
evaluate("6 == 6", true, Boolean.class);
|
||||
@@ -85,7 +85,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotEqual() {
|
||||
void testNotEqual() {
|
||||
evaluate("3 != 5", true, Boolean.class);
|
||||
evaluate("5 != 3", true, Boolean.class);
|
||||
evaluate("6 != 6", false, Boolean.class);
|
||||
@@ -134,7 +134,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLessThan() {
|
||||
void testLessThan() {
|
||||
evaluate("5 < 5", false, Boolean.class);
|
||||
evaluate("3 < 5", true, Boolean.class);
|
||||
evaluate("5 < 3", false, Boolean.class);
|
||||
@@ -176,7 +176,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLessThanOrEqual() {
|
||||
void testLessThanOrEqual() {
|
||||
evaluate("3 <= 5", true, Boolean.class);
|
||||
evaluate("5 <= 3", false, Boolean.class);
|
||||
evaluate("6 <= 6", true, Boolean.class);
|
||||
@@ -225,7 +225,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGreaterThan() {
|
||||
void testGreaterThan() {
|
||||
evaluate("3 > 5", false, Boolean.class);
|
||||
evaluate("5 > 3", true, Boolean.class);
|
||||
evaluate("3L > 5L", false, Boolean.class);
|
||||
@@ -266,7 +266,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGreaterThanOrEqual() {
|
||||
void testGreaterThanOrEqual() {
|
||||
evaluate("3 >= 5", false, Boolean.class);
|
||||
evaluate("5 >= 3", true, Boolean.class);
|
||||
evaluate("6 >= 6", true, Boolean.class);
|
||||
@@ -315,27 +315,27 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntegerLiteral() {
|
||||
void testIntegerLiteral() {
|
||||
evaluate("3", 3, Integer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRealLiteral() {
|
||||
void testRealLiteral() {
|
||||
evaluate("3.5", 3.5d, Double.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiplyStringInt() {
|
||||
void testMultiplyStringInt() {
|
||||
evaluate("'a' * 5", "aaaaa", String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiplyDoubleDoubleGivesDouble() {
|
||||
void testMultiplyDoubleDoubleGivesDouble() {
|
||||
evaluate("3.0d * 5.0d", 15.0d, Double.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMixedOperandsBigDecimal() {
|
||||
void testMixedOperandsBigDecimal() {
|
||||
evaluate("3 * new java.math.BigDecimal('5')", new BigDecimal("15"), BigDecimal.class);
|
||||
evaluate("3L * new java.math.BigDecimal('5')", new BigDecimal("15"), BigDecimal.class);
|
||||
evaluate("3.0d * new java.math.BigDecimal('5')", new BigDecimal("15.0"), BigDecimal.class);
|
||||
@@ -361,19 +361,19 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMathOperatorAdd02() {
|
||||
void testMathOperatorAdd02() {
|
||||
evaluate("'hello' + ' ' + 'world'", "hello world", String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMathOperatorsInChains() {
|
||||
void testMathOperatorsInChains() {
|
||||
evaluate("1+2+3",6,Integer.class);
|
||||
evaluate("2*3*4",24,Integer.class);
|
||||
evaluate("12-1-2",9,Integer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntegerArithmetic() {
|
||||
void testIntegerArithmetic() {
|
||||
evaluate("2 + 4", "6", Integer.class);
|
||||
evaluate("5 - 4", "1", Integer.class);
|
||||
evaluate("3 * 5", 15, Integer.class);
|
||||
@@ -388,7 +388,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlus() throws Exception {
|
||||
void testPlus() {
|
||||
evaluate("7 + 2", "9", Integer.class);
|
||||
evaluate("3.0f + 5.0f", 8.0f, Float.class);
|
||||
evaluate("3.0d + 5.0d", 8.0d, Double.class);
|
||||
@@ -419,7 +419,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinus() throws Exception {
|
||||
void testMinus() {
|
||||
evaluate("'c' - 2", "a", String.class);
|
||||
evaluate("3.0f - 5.0f", -2.0f, Float.class);
|
||||
evaluateAndCheckError("'ab' - 2", SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
@@ -437,7 +437,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModulus() {
|
||||
void testModulus() {
|
||||
evaluate("3%2",1,Integer.class);
|
||||
evaluate("3L%2L",1L,Long.class);
|
||||
evaluate("3.0f%2.0f",1f,Float.class);
|
||||
@@ -448,7 +448,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDivide() {
|
||||
void testDivide() {
|
||||
evaluate("3.0f / 5.0f", 0.6f, Float.class);
|
||||
evaluate("4L/2L",2L,Long.class);
|
||||
evaluate("3.0f div 5.0f", 0.6f, Float.class);
|
||||
@@ -461,17 +461,17 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMathOperatorDivide_ConvertToDouble() {
|
||||
evaluateAndAskForReturnType("8/4", new Double(2.0), Double.class);
|
||||
void testMathOperatorDivide_ConvertToDouble() {
|
||||
evaluateAndAskForReturnType("8/4", 2.0, Double.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMathOperatorDivide04_ConvertToFloat() {
|
||||
evaluateAndAskForReturnType("8/4", new Float(2.0), Float.class);
|
||||
void testMathOperatorDivide04_ConvertToFloat() {
|
||||
evaluateAndAskForReturnType("8/4", 2.0F, Float.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoubles() {
|
||||
void testDoubles() {
|
||||
evaluate("3.0d == 5.0d", false, Boolean.class);
|
||||
evaluate("3.0d == 3.0d", true, Boolean.class);
|
||||
evaluate("3.0d != 5.0d", true, Boolean.class);
|
||||
@@ -484,7 +484,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBigDecimals() {
|
||||
void testBigDecimals() {
|
||||
evaluate("3 + new java.math.BigDecimal('5')", new BigDecimal("8"), BigDecimal.class);
|
||||
evaluate("3 - new java.math.BigDecimal('5')", new BigDecimal("-2"), BigDecimal.class);
|
||||
evaluate("3 * new java.math.BigDecimal('5')", new BigDecimal("15"), BigDecimal.class);
|
||||
@@ -495,7 +495,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperatorNames() throws Exception {
|
||||
void testOperatorNames() {
|
||||
Operator node = getOperatorNode((SpelExpression)parser.parseExpression("1==3"));
|
||||
assertThat(node.getOperatorName()).isEqualTo("==");
|
||||
|
||||
@@ -534,13 +534,13 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperatorOverloading() {
|
||||
void testOperatorOverloading() {
|
||||
evaluateAndCheckError("'a' * '2'", SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("'a' ^ '2'", SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPower() {
|
||||
void testPower() {
|
||||
evaluate("3^2",9,Integer.class);
|
||||
evaluate("3.0d^2.0d",9.0d,Double.class);
|
||||
evaluate("3L^2L",9L,Long.class);
|
||||
@@ -549,7 +549,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMixedOperands_FloatsAndDoubles() {
|
||||
void testMixedOperands_FloatsAndDoubles() {
|
||||
evaluate("3.0d + 5.0f", 8.0d, Double.class);
|
||||
evaluate("3.0D - 5.0f", -2.0d, Double.class);
|
||||
evaluate("3.0f * 5.0d", 15.0d, Double.class);
|
||||
@@ -558,7 +558,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMixedOperands_DoublesAndInts() {
|
||||
void testMixedOperands_DoublesAndInts() {
|
||||
evaluate("3.0d + 5", 8.0d, Double.class);
|
||||
evaluate("3.0D - 5", -2.0d, Double.class);
|
||||
evaluate("3.0f * 5", 15.0f, Float.class);
|
||||
@@ -569,7 +569,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStrings() {
|
||||
void testStrings() {
|
||||
evaluate("'abc' == 'abc'", true, Boolean.class);
|
||||
evaluate("'abc' == 'def'", false, Boolean.class);
|
||||
evaluate("'abc' != 'abc'", false, Boolean.class);
|
||||
@@ -577,7 +577,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongs() {
|
||||
void testLongs() {
|
||||
evaluate("3L == 4L", false, Boolean.class);
|
||||
evaluate("3L == 3L", true, Boolean.class);
|
||||
evaluate("3L != 4L", true, Boolean.class);
|
||||
@@ -588,7 +588,7 @@ public class OperatorTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBigIntegers() {
|
||||
void testBigIntegers() {
|
||||
evaluate("3 + new java.math.BigInteger('5')", new BigInteger("8"), BigInteger.class);
|
||||
evaluate("3 - new java.math.BigInteger('5')", new BigInteger("-2"), BigInteger.class);
|
||||
evaluate("3 * new java.math.BigInteger('5')", new BigInteger("15"), BigInteger.class);
|
||||
|
||||
+83
-83
@@ -128,7 +128,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void typeReference() throws Exception {
|
||||
void typeReference() {
|
||||
expression = parse("T(String)");
|
||||
assertThat(expression.getValue()).isEqualTo(String.class);
|
||||
assertCanCompile(expression);
|
||||
@@ -196,7 +196,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void operatorInstanceOf() throws Exception {
|
||||
void operatorInstanceOf() {
|
||||
expression = parse("'xyz' instanceof T(String)");
|
||||
assertThat(expression.getValue()).isEqualTo(true);
|
||||
assertCanCompile(expression);
|
||||
@@ -245,7 +245,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void operatorInstanceOf_SPR14250() throws Exception {
|
||||
void operatorInstanceOf_SPR14250() throws Exception {
|
||||
// primitive left operand - should get boxed, return true
|
||||
expression = parse("3 instanceof T(Integer)");
|
||||
assertThat(expression.getValue()).isEqualTo(true);
|
||||
@@ -292,7 +292,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stringLiteral() throws Exception {
|
||||
void stringLiteral() throws Exception {
|
||||
expression = parser.parseExpression("'abcde'");
|
||||
assertThat(expression.getValue(new TestClass1(), String.class)).isEqualTo("abcde");
|
||||
assertCanCompile(expression);
|
||||
@@ -307,18 +307,18 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullLiteral() throws Exception {
|
||||
void nullLiteral() throws Exception {
|
||||
expression = parser.parseExpression("null");
|
||||
Object resultI = expression.getValue(new TestClass1(), Object.class);
|
||||
assertCanCompile(expression);
|
||||
Object resultC = expression.getValue(new TestClass1(), Object.class);
|
||||
assertThat(resultI).isEqualTo(null);
|
||||
assertThat(resultC).isEqualTo(null);
|
||||
assertThat(resultC).isEqualTo(null);
|
||||
assertThat(resultI).isNull();
|
||||
assertThat(resultC).isNull();
|
||||
assertThat(resultC).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void realLiteral() throws Exception {
|
||||
void realLiteral() throws Exception {
|
||||
expression = parser.parseExpression("3.4d");
|
||||
double resultI = expression.getValue(new TestClass1(), Double.TYPE);
|
||||
assertCanCompile(expression);
|
||||
@@ -332,7 +332,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void inlineList() throws Exception {
|
||||
void inlineList() throws Exception {
|
||||
expression = parser.parseExpression("'abcde'.substring({1,3,4}[0])");
|
||||
Object o = expression.getValue();
|
||||
assertThat(o).isEqualTo("bcde");
|
||||
@@ -371,7 +371,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void nestedInlineLists() throws Exception {
|
||||
void nestedInlineLists() throws Exception {
|
||||
Object o = null;
|
||||
|
||||
expression = parser.parseExpression("{{1,2,3},{4,5,6},{7,8,9}}");
|
||||
@@ -446,7 +446,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void intLiteral() throws Exception {
|
||||
void intLiteral() throws Exception {
|
||||
expression = parser.parseExpression("42");
|
||||
int resultI = expression.getValue(new TestClass1(), Integer.TYPE);
|
||||
assertCanCompile(expression);
|
||||
@@ -477,7 +477,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void longLiteral() throws Exception {
|
||||
void longLiteral() throws Exception {
|
||||
expression = parser.parseExpression("99L");
|
||||
long resultI = expression.getValue(new TestClass1(), Long.TYPE);
|
||||
assertCanCompile(expression);
|
||||
@@ -487,24 +487,24 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void booleanLiteral() throws Exception {
|
||||
void booleanLiteral() throws Exception {
|
||||
expression = parser.parseExpression("true");
|
||||
boolean resultI = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultI).isEqualTo(true);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(SpelCompiler.compile(expression)).isTrue();
|
||||
boolean resultC = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultC).isEqualTo(true);
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
expression = parser.parseExpression("false");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultI).isEqualTo(false);
|
||||
assertThat(resultI).isFalse();
|
||||
assertThat(SpelCompiler.compile(expression)).isTrue();
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultC).isEqualTo(false);
|
||||
assertThat(resultC).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void floatLiteral() throws Exception {
|
||||
void floatLiteral() throws Exception {
|
||||
expression = parser.parseExpression("3.4f");
|
||||
float resultI = expression.getValue(new TestClass1(), Float.TYPE);
|
||||
assertCanCompile(expression);
|
||||
@@ -517,42 +517,42 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void opOr() throws Exception {
|
||||
void opOr() throws Exception {
|
||||
Expression expression = parser.parseExpression("false or false");
|
||||
boolean resultI = expression.getValue(1, Boolean.TYPE);
|
||||
SpelCompiler.compile(expression);
|
||||
boolean resultC = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultI).isEqualTo(false);
|
||||
assertThat(resultC).isEqualTo(false);
|
||||
assertThat(resultI).isFalse();
|
||||
assertThat(resultC).isFalse();
|
||||
|
||||
expression = parser.parseExpression("false or true");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
assertCanCompile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultI).isEqualTo(true);
|
||||
assertThat(resultC).isEqualTo(true);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
expression = parser.parseExpression("true or false");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
assertCanCompile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultI).isEqualTo(true);
|
||||
assertThat(resultC).isEqualTo(true);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
expression = parser.parseExpression("true or true");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
assertCanCompile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultI).isEqualTo(true);
|
||||
assertThat(resultC).isEqualTo(true);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
TestClass4 tc = new TestClass4();
|
||||
expression = parser.parseExpression("getfalse() or gettrue()");
|
||||
resultI = expression.getValue(tc, Boolean.TYPE);
|
||||
assertCanCompile(expression);
|
||||
resultC = expression.getValue(tc, Boolean.TYPE);
|
||||
assertThat(resultI).isEqualTo(true);
|
||||
assertThat(resultC).isEqualTo(true);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
// Can't compile this as we aren't going down the getfalse() branch in our evaluation
|
||||
expression = parser.parseExpression("gettrue() or getfalse()");
|
||||
@@ -584,29 +584,29 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
boolean resultI = expression.getValue(1, Boolean.TYPE);
|
||||
SpelCompiler.compile(expression);
|
||||
boolean resultC = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultI).isEqualTo(false);
|
||||
assertThat(resultC).isEqualTo(false);
|
||||
assertThat(resultI).isFalse();
|
||||
assertThat(resultC).isFalse();
|
||||
|
||||
expression = parser.parseExpression("false and true");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
SpelCompiler.compile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultI).isEqualTo(false);
|
||||
assertThat(resultC).isEqualTo(false);
|
||||
assertThat(resultI).isFalse();
|
||||
assertThat(resultC).isFalse();
|
||||
|
||||
expression = parser.parseExpression("true and false");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
SpelCompiler.compile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultI).isEqualTo(false);
|
||||
assertThat(resultC).isEqualTo(false);
|
||||
assertThat(resultI).isFalse();
|
||||
assertThat(resultC).isFalse();
|
||||
|
||||
expression = parser.parseExpression("true and true");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
SpelCompiler.compile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
assertThat(resultI).isEqualTo(true);
|
||||
assertThat(resultC).isEqualTo(true);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
TestClass4 tc = new TestClass4();
|
||||
|
||||
@@ -3481,7 +3481,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertThat(tc8.s).isEqualTo("123");
|
||||
assertThat(tc8.d).isCloseTo(4.0d, within(0.5d));
|
||||
|
||||
assertThat(tc8.z).isEqualTo(true);
|
||||
assertThat(tc8.z).isTrue();
|
||||
|
||||
// no-arg ctor
|
||||
expression = parser.parseExpression("new " + testclass8 + "()");
|
||||
@@ -3507,7 +3507,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodReferenceReflectiveMethodSelectionWithVarargs() throws Exception {
|
||||
void methodReferenceReflectiveMethodSelectionWithVarargs() throws Exception {
|
||||
TestClass10 tc = new TestClass10();
|
||||
|
||||
// Should call the non varargs version of concat
|
||||
@@ -3526,11 +3526,11 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
expression = parser.parseExpression("concat()");
|
||||
assertCantCompile(expression);
|
||||
expression.getValue(tc);
|
||||
assertThat(tc.s).isEqualTo("");
|
||||
assertThat(tc.s).isEmpty();
|
||||
assertCanCompile(expression);
|
||||
tc.reset();
|
||||
expression.getValue(tc);
|
||||
assertThat(tc.s).isEqualTo("");
|
||||
assertThat(tc.s).isEmpty();
|
||||
tc.reset();
|
||||
|
||||
// Should call the non varargs version of concat
|
||||
@@ -3549,27 +3549,27 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
expression = parser.parseExpression("concat2()");
|
||||
assertCantCompile(expression);
|
||||
expression.getValue(tc);
|
||||
assertThat(tc.s).isEqualTo("");
|
||||
assertThat(tc.s).isEmpty();
|
||||
assertCanCompile(expression);
|
||||
tc.reset();
|
||||
expression.getValue(tc);
|
||||
assertThat(tc.s).isEqualTo("");
|
||||
assertThat(tc.s).isEmpty();
|
||||
tc.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodReferenceVarargs() throws Exception {
|
||||
void methodReferenceVarargs() {
|
||||
TestClass5 tc = new TestClass5();
|
||||
|
||||
// varargs string
|
||||
expression = parser.parseExpression("eleven()");
|
||||
assertCantCompile(expression);
|
||||
expression.getValue(tc);
|
||||
assertThat(tc.s).isEqualTo("");
|
||||
assertThat(tc.s).isEmpty();
|
||||
assertCanCompile(expression);
|
||||
tc.reset();
|
||||
expression.getValue(tc);
|
||||
assertThat(tc.s).isEqualTo("");
|
||||
assertThat(tc.s).isEmpty();
|
||||
tc.reset();
|
||||
|
||||
// varargs string
|
||||
@@ -3840,7 +3840,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodReference() throws Exception {
|
||||
void methodReference() {
|
||||
TestClass5 tc = new TestClass5();
|
||||
|
||||
// non-static method, no args, void return
|
||||
@@ -3985,7 +3985,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void errorHandling() throws Exception {
|
||||
void errorHandling() {
|
||||
TestClass5 tc = new TestClass5();
|
||||
|
||||
// changing target
|
||||
@@ -4040,7 +4040,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodReference_staticMethod() throws Exception {
|
||||
void methodReference_staticMethod() {
|
||||
Expression expression = parser.parseExpression("T(Integer).valueOf(42)");
|
||||
int resultI = expression.getValue(new TestClass1(), Integer.TYPE);
|
||||
assertCanCompile(expression);
|
||||
@@ -4050,7 +4050,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodReference_literalArguments_int() throws Exception {
|
||||
void methodReference_literalArguments_int() {
|
||||
Expression expression = parser.parseExpression("'abcd'.substring(1,3)");
|
||||
String resultI = expression.getValue(new TestClass1(), String.class);
|
||||
assertCanCompile(expression);
|
||||
@@ -4060,7 +4060,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodReference_simpleInstanceMethodNoArg() throws Exception {
|
||||
void methodReference_simpleInstanceMethodNoArg() {
|
||||
Expression expression = parser.parseExpression("toString()");
|
||||
String resultI = expression.getValue(42, String.class);
|
||||
assertCanCompile(expression);
|
||||
@@ -4070,7 +4070,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodReference_simpleInstanceMethodNoArgReturnPrimitive() throws Exception {
|
||||
void methodReference_simpleInstanceMethodNoArgReturnPrimitive() {
|
||||
expression = parser.parseExpression("intValue()");
|
||||
int resultI = expression.getValue(42, Integer.TYPE);
|
||||
assertThat(resultI).isEqualTo(42);
|
||||
@@ -4080,7 +4080,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodReference_simpleInstanceMethodOneArgReturnPrimitive1() throws Exception {
|
||||
void methodReference_simpleInstanceMethodOneArgReturnPrimitive1() {
|
||||
Expression expression = parser.parseExpression("indexOf('b')");
|
||||
int resultI = expression.getValue("abc", Integer.TYPE);
|
||||
assertCanCompile(expression);
|
||||
@@ -4090,7 +4090,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodReference_simpleInstanceMethodOneArgReturnPrimitive2() throws Exception {
|
||||
void methodReference_simpleInstanceMethodOneArgReturnPrimitive2() {
|
||||
expression = parser.parseExpression("charAt(2)");
|
||||
char resultI = expression.getValue("abc", Character.TYPE);
|
||||
assertThat(resultI).isEqualTo('c');
|
||||
@@ -4100,7 +4100,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compoundExpression() throws Exception {
|
||||
void compoundExpression() {
|
||||
Payload payload = new Payload();
|
||||
expression = parser.parseExpression("DR[0]");
|
||||
assertThat(expression.getValue(payload).toString()).isEqualTo("instanceof Two");
|
||||
@@ -4137,7 +4137,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mixingItUp_indexerOpEqTernary() throws Exception {
|
||||
void mixingItUp_indexerOpEqTernary() {
|
||||
Map<String, String> m = new HashMap<>();
|
||||
m.put("andy","778");
|
||||
|
||||
@@ -4150,7 +4150,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyReference() throws Exception {
|
||||
void propertyReference() {
|
||||
TestClass6 tc = new TestClass6();
|
||||
|
||||
// non static field
|
||||
@@ -4190,7 +4190,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyReferenceVisibility_SPR12771() {
|
||||
void propertyReferenceVisibility_SPR12771() {
|
||||
StandardEvaluationContext ctx = new StandardEvaluationContext();
|
||||
ctx.setVariable("httpServletRequest", HttpServlet3RequestFactory.getOne());
|
||||
// Without a fix compilation was inserting a checkcast to a private type
|
||||
@@ -4202,7 +4202,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void indexer() throws Exception {
|
||||
void indexer() {
|
||||
String[] sss = new String[] {"a","b","c"};
|
||||
Number[] ns = new Number[] {2,8,9};
|
||||
int[] is = new int[] {8,9,10};
|
||||
@@ -4509,7 +4509,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void plusNeedingCheckcast_SPR12426() {
|
||||
void plusNeedingCheckcast_SPR12426() {
|
||||
expression = parser.parseExpression("object + ' world'");
|
||||
Object v = expression.getValue(new FooObject());
|
||||
assertThat(v).isEqualTo("hello world");
|
||||
@@ -4524,7 +4524,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mixingItUp_propertyAccessIndexerOpLtTernaryRootNull() throws Exception {
|
||||
void mixingItUp_propertyAccessIndexerOpLtTernaryRootNull() {
|
||||
Payload payload = new Payload();
|
||||
|
||||
expression = parser.parseExpression("DR[0].three");
|
||||
@@ -4552,7 +4552,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void variantGetter() throws Exception {
|
||||
void variantGetter() throws Exception {
|
||||
Payload2Holder holder = new Payload2Holder();
|
||||
StandardEvaluationContext ctx = new StandardEvaluationContext();
|
||||
ctx.addPropertyAccessor(new MyAccessor());
|
||||
@@ -4566,7 +4566,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compilerWithGenerics_12040() {
|
||||
void compilerWithGenerics_12040() {
|
||||
expression = parser.parseExpression("payload!=2");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper<>(4), Boolean.class)).isTrue();
|
||||
assertCanCompile(expression);
|
||||
@@ -4675,7 +4675,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
// The new helper class here uses an upper bound on the generic
|
||||
@Test
|
||||
public void compilerWithGenerics_12040_2() {
|
||||
void compilerWithGenerics_12040_2() {
|
||||
expression = parser.parseExpression("payload/2");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(4))).isEqualTo(2);
|
||||
assertCanCompile(expression);
|
||||
@@ -4719,7 +4719,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
// The other numeric operators
|
||||
@Test
|
||||
public void compilerWithGenerics_12040_3() {
|
||||
void compilerWithGenerics_12040_3() {
|
||||
expression = parser.parseExpression("payload >= 2");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(4), Boolean.TYPE)).isTrue();
|
||||
assertCanCompile(expression);
|
||||
@@ -4762,7 +4762,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void indexerMapAccessor_12045() throws Exception {
|
||||
void indexerMapAccessor_12045() throws Exception {
|
||||
SpelParserConfiguration spc = new SpelParserConfiguration(
|
||||
SpelCompilerMode.IMMEDIATE,getClass().getClassLoader());
|
||||
SpelExpressionParser sep = new SpelExpressionParser(spc);
|
||||
@@ -4791,7 +4791,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void elvisOperator_SPR15192() {
|
||||
void elvisOperator_SPR15192() {
|
||||
SpelParserConfiguration configuration = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null);
|
||||
Expression exp;
|
||||
|
||||
@@ -4875,7 +4875,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void elvisOperator_SPR17214() throws Exception {
|
||||
void elvisOperator_SPR17214() {
|
||||
SpelParserConfiguration spc = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null);
|
||||
SpelExpressionParser sep = new SpelExpressionParser(spc);
|
||||
|
||||
@@ -4923,7 +4923,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullComparison_SPR22358() {
|
||||
void testNullComparison_SPR22358() {
|
||||
SpelParserConfiguration configuration = new SpelParserConfiguration(SpelCompilerMode.OFF, null);
|
||||
SpelExpressionParser parser = new SpelExpressionParser(configuration);
|
||||
StandardEvaluationContext ctx = new StandardEvaluationContext();
|
||||
@@ -5004,7 +5004,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ternaryOperator_SPR15192() {
|
||||
void ternaryOperator_SPR15192() {
|
||||
SpelParserConfiguration configuration = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null);
|
||||
Expression exp;
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -5048,9 +5048,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
// null condition
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("3==3?null:4L");
|
||||
assertThat(exp.getValue(context, new Foo(), String.class)).isEqualTo(null);
|
||||
assertThat(exp.getValue(context, new Foo(), String.class)).isNull();
|
||||
assertCanCompile(exp);
|
||||
assertThat(exp.getValue(context, new Foo(), String.class)).isEqualTo(null);
|
||||
assertThat(exp.getValue(context, new Foo(), String.class)).isNull();
|
||||
assertIsCompiled(exp);
|
||||
|
||||
// variable access returning primitive
|
||||
@@ -5078,7 +5078,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repeatedCompilation() throws Exception {
|
||||
void repeatedCompilation() throws Exception {
|
||||
// Verifying that after a number of compilations, the classloaders
|
||||
// used to load the compiled expressions are discarded/replaced.
|
||||
// See SpelCompiler.loadClass()
|
||||
@@ -6204,9 +6204,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
public Reg(int v) {
|
||||
this._value = v;
|
||||
this._valueL = new Long(v);
|
||||
this._valueD = new Double(v);
|
||||
this._valueF = new Float(v);
|
||||
this._valueL = Long.valueOf(v);
|
||||
this._valueD = (double) v;
|
||||
this._valueF = (float) v;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
@@ -6243,16 +6243,16 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
|
||||
public void setValue(Integer value) {
|
||||
_value = value;
|
||||
_valueL = value==null?null:new Long(value);
|
||||
_valueD = value==null?null:new Double(value);
|
||||
_valueF = value==null?null:new Float(value);
|
||||
_valueL = value==null?null:Long.valueOf(value);
|
||||
_valueD = value==null?null:Double.valueOf(value);
|
||||
_valueF = value==null?null:Float.valueOf(value);
|
||||
}
|
||||
|
||||
public void setValue2(Integer value) {
|
||||
_value2 = value;
|
||||
_valueL2 = value==null?null:new Long(value);
|
||||
_valueD2 = value==null?null:new Double(value);
|
||||
_valueF2 = value==null?null:new Float(value);
|
||||
_valueL2 = value==null?null:Long.valueOf(value);
|
||||
_valueD2 = value==null?null:Double.valueOf(value);
|
||||
_valueF2 = value==null?null:Float.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+110
-110
@@ -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.
|
||||
@@ -74,35 +74,35 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class SpelReproTests extends AbstractExpressionTests {
|
||||
class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
@Test
|
||||
public void NPE_SPR5661() {
|
||||
void NPE_SPR5661() {
|
||||
evaluate("joinThreeStrings('a',null,'c')", "anullc", String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SWF1086() {
|
||||
void SWF1086() {
|
||||
evaluate("printDouble(T(java.math.BigDecimal).valueOf(14.35))", "14.35", String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doubleCoercion() {
|
||||
void doubleCoercion() {
|
||||
evaluate("printDouble(14.35)", "14.35", String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doubleArrayCoercion() {
|
||||
void doubleArrayCoercion() {
|
||||
evaluate("printDoubles(getDoublesAsStringList())", "{14.35, 15.45}", String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR5899() {
|
||||
void SPR5899() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new Spr5899Class());
|
||||
Expression expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull(12)");
|
||||
assertThat(expr.getValue(context)).isEqualTo(12);
|
||||
expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull(null)");
|
||||
assertThat(expr.getValue(context)).isEqualTo(null);
|
||||
assertThat(expr.getValue(context)).isNull();
|
||||
expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull2(null)");
|
||||
assertThatExceptionOfType(EvaluationException.class).isThrownBy(
|
||||
expr::getValue);
|
||||
@@ -133,7 +133,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR5905_InnerTypeReferences() {
|
||||
void SPR5905_InnerTypeReferences() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new Spr5899Class());
|
||||
Expression expr = new SpelExpressionParser().parseRaw("T(java.util.Map$Entry)");
|
||||
assertThat(expr.getValue(context)).isEqualTo(Map.Entry.class);
|
||||
@@ -146,7 +146,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR5804() {
|
||||
void SPR5804() {
|
||||
Map<String, String> m = new HashMap<>();
|
||||
m.put("foo", "bar");
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(m); // root is a map instance
|
||||
@@ -156,7 +156,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR5847() {
|
||||
void SPR5847() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new TestProperties());
|
||||
String name = null;
|
||||
Expression expr = null;
|
||||
@@ -192,7 +192,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void NPE_SPR5673() {
|
||||
void NPE_SPR5673() {
|
||||
ParserContext hashes = TemplateExpressionParsingTests.HASH_DELIMITED_PARSER_CONTEXT;
|
||||
ParserContext dollars = TemplateExpressionParsingTests.DEFAULT_TEMPLATE_PARSER_CONTEXT;
|
||||
|
||||
@@ -227,7 +227,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyAccessOnNullTarget_SPR5663() throws AccessException {
|
||||
void propertyAccessOnNullTarget_SPR5663() throws AccessException {
|
||||
PropertyAccessor accessor = new ReflectivePropertyAccessor();
|
||||
EvaluationContext context = TestScenarioCreator.getTestEvaluationContext();
|
||||
assertThat(accessor.canRead(context, null, "abc")).isFalse();
|
||||
@@ -239,7 +239,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nestedProperties_SPR6923() {
|
||||
void nestedProperties_SPR6923() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new Foo());
|
||||
Expression expr = new SpelExpressionParser().parseRaw("resource.resource.server");
|
||||
String name = expr.getValue(context, String.class);
|
||||
@@ -248,7 +248,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
/** Should be accessing Goo.getKey because 'bar' field evaluates to "key" */
|
||||
@Test
|
||||
public void indexingAsAPropertyAccess_SPR6968_1() {
|
||||
void indexingAsAPropertyAccess_SPR6968_1() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new Goo());
|
||||
String name = null;
|
||||
Expression expr = null;
|
||||
@@ -261,7 +261,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
/** Should be accessing Goo.getKey because 'bar' variable evaluates to "key" */
|
||||
@Test
|
||||
public void indexingAsAPropertyAccess_SPR6968_2() {
|
||||
void indexingAsAPropertyAccess_SPR6968_2() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new Goo());
|
||||
context.setVariable("bar", "key");
|
||||
String name = null;
|
||||
@@ -275,7 +275,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
/** $ related identifiers */
|
||||
@Test
|
||||
public void dollarPrefixedIdentifier_SPR7100() {
|
||||
void dollarPrefixedIdentifier_SPR7100() {
|
||||
Holder h = new Holder();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(h);
|
||||
context.addPropertyAccessor(new MapAccessor());
|
||||
@@ -315,7 +315,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
/** Should be accessing Goo.wibble field because 'bar' variable evaluates to "wibble" */
|
||||
@Test
|
||||
public void indexingAsAPropertyAccess_SPR6968_3() {
|
||||
void indexingAsAPropertyAccess_SPR6968_3() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new Goo());
|
||||
context.setVariable("bar", "wibble");
|
||||
String name = null;
|
||||
@@ -333,7 +333,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
* "wibble"
|
||||
*/
|
||||
@Test
|
||||
public void indexingAsAPropertyAccess_SPR6968_4() {
|
||||
void indexingAsAPropertyAccess_SPR6968_4() {
|
||||
Goo g = Goo.instance;
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(g);
|
||||
context.setVariable("bar", "wibble");
|
||||
@@ -348,7 +348,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
/** Should be accessing Goo.setKey field because 'bar' variable evaluates to "key" */
|
||||
@Test
|
||||
public void indexingAsAPropertyAccess_SPR6968_5() {
|
||||
void indexingAsAPropertyAccess_SPR6968_5() {
|
||||
Goo g = Goo.instance;
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(g);
|
||||
Expression expr = null;
|
||||
@@ -360,7 +360,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dollars() {
|
||||
void dollars() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new XX());
|
||||
Expression expr = null;
|
||||
expr = new SpelExpressionParser().parseRaw("m['$foo']");
|
||||
@@ -369,7 +369,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dollars2() {
|
||||
void dollars2() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new XX());
|
||||
Expression expr = null;
|
||||
expr = new SpelExpressionParser().parseRaw("m[$foo]");
|
||||
@@ -421,7 +421,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
};
|
||||
|
||||
@Test
|
||||
public void beanResolution() {
|
||||
void beanResolution() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new XX());
|
||||
Expression expr = null;
|
||||
|
||||
@@ -443,12 +443,12 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
// bean does not exist
|
||||
expr = new SpelExpressionParser().parseRaw("@bar");
|
||||
assertThat(expr.getValue(context, String.class)).isEqualTo(null);
|
||||
assertThat(expr.getValue(context, String.class)).isNull();
|
||||
|
||||
// bean name will cause AccessException
|
||||
expr = new SpelExpressionParser().parseRaw("@goo");
|
||||
try {
|
||||
assertThat(expr.getValue(context, String.class)).isEqualTo(null);
|
||||
assertThat(expr.getValue(context, String.class)).isNull();
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertThat(see.getMessageCode()).isEqualTo(SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION);
|
||||
@@ -472,7 +472,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void elvis_SPR7209_1() {
|
||||
void elvis_SPR7209_1() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new XX());
|
||||
Expression expr = null;
|
||||
|
||||
@@ -482,14 +482,14 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
expr = new SpelExpressionParser().parseRaw("?:'default'");
|
||||
assertThat(expr.getValue()).isEqualTo("default");
|
||||
expr = new SpelExpressionParser().parseRaw("?:");
|
||||
assertThat(expr.getValue()).isEqualTo(null);
|
||||
assertThat(expr.getValue()).isNull();
|
||||
|
||||
// Different parts of ternary expression are null
|
||||
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
|
||||
new SpelExpressionParser().parseRaw("(?'abc':'default')").getValue(context))
|
||||
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.TYPE_CONVERSION_ERROR));
|
||||
expr = new SpelExpressionParser().parseRaw("(false?'abc':null)");
|
||||
assertThat(expr.getValue()).isEqualTo(null);
|
||||
assertThat(expr.getValue()).isNull();
|
||||
|
||||
// Assignment
|
||||
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
|
||||
@@ -498,7 +498,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void elvis_SPR7209_2() {
|
||||
void elvis_SPR7209_2() {
|
||||
Expression expr = null;
|
||||
// Have empty string treated as null for elvis
|
||||
expr = new SpelExpressionParser().parseRaw("?:'default'");
|
||||
@@ -510,7 +510,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapOfMap_SPR7244() {
|
||||
void mapOfMap_SPR7244() {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("uri", "http:");
|
||||
Map<String, String> nameMap = new LinkedHashMap<>();
|
||||
@@ -531,7 +531,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void projectionTypeDescriptors_1() {
|
||||
void projectionTypeDescriptors_1() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new C());
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
String el1 = "ls.![#this.equals('abc')]";
|
||||
@@ -540,11 +540,11 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
// value is list containing [true,false]
|
||||
assertThat(value.get(0).getClass()).isEqualTo(Boolean.class);
|
||||
TypeDescriptor evaluated = exp.getValueTypeDescriptor(context);
|
||||
assertThat(evaluated.getElementTypeDescriptor()).isEqualTo(null);
|
||||
assertThat(evaluated.getElementTypeDescriptor()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void projectionTypeDescriptors_2() {
|
||||
void projectionTypeDescriptors_2() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new C());
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
String el1 = "as.![#this.equals('abc')]";
|
||||
@@ -557,7 +557,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void projectionTypeDescriptors_3() {
|
||||
void projectionTypeDescriptors_3() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new C());
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
String el1 = "ms.![key.equals('abc')]";
|
||||
@@ -566,11 +566,11 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
// value is list containing [true,false]
|
||||
assertThat(value.get(0).getClass()).isEqualTo(Boolean.class);
|
||||
TypeDescriptor evaluated = exp.getValueTypeDescriptor(context);
|
||||
assertThat(evaluated.getElementTypeDescriptor()).isEqualTo(null);
|
||||
assertThat(evaluated.getElementTypeDescriptor()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void greaterThanWithNulls_SPR7840() {
|
||||
void greaterThanWithNulls_SPR7840() {
|
||||
List<D> list = new ArrayList<>();
|
||||
list.add(new D("aaa"));
|
||||
list.add(new D("bbb"));
|
||||
@@ -605,7 +605,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
* than a unboxing conversion.
|
||||
*/
|
||||
@Test
|
||||
public void conversionPriority_SPR8224() throws Exception {
|
||||
void conversionPriority_SPR8224() throws Exception {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
class ConversionPriority1 {
|
||||
@@ -637,7 +637,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
ConversionPriority1 target = new ConversionPriority1();
|
||||
MethodExecutor me = new ReflectiveMethodResolver(true).resolve(emptyEvalContext, target, "getX", args);
|
||||
// MethodInvoker chooses getX(int i) when passing Integer
|
||||
final int actual = (Integer) me.execute(emptyEvalContext, target, new Integer(42)).getValue();
|
||||
final int actual = (Integer) me.execute(emptyEvalContext, target, Integer.valueOf(42)).getValue();
|
||||
// Compiler chooses getX(Number i) when passing Integer
|
||||
final int compiler = target.getX(INTEGER);
|
||||
// Fails!
|
||||
@@ -646,7 +646,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
ConversionPriority2 target2 = new ConversionPriority2();
|
||||
MethodExecutor me2 = new ReflectiveMethodResolver(true).resolve(emptyEvalContext, target2, "getX", args);
|
||||
// MethodInvoker chooses getX(int i) when passing Integer
|
||||
int actual2 = (Integer) me2.execute(emptyEvalContext, target2, new Integer(42)).getValue();
|
||||
int actual2 = (Integer) me2.execute(emptyEvalContext, target2, Integer.valueOf(42)).getValue();
|
||||
// Compiler chooses getX(Number i) when passing Integer
|
||||
int compiler2 = target2.getX(INTEGER);
|
||||
// Fails!
|
||||
@@ -659,7 +659,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
* method accepting 'long' is ok.
|
||||
*/
|
||||
@Test
|
||||
public void wideningPrimitiveConversion_SPR8224() throws Exception {
|
||||
void wideningPrimitiveConversion_SPR8224() throws Exception {
|
||||
|
||||
class WideningPrimitiveConversion {
|
||||
public int getX(long i) {
|
||||
@@ -667,7 +667,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
}
|
||||
|
||||
final Integer INTEGER_VALUE = Integer.valueOf(7);
|
||||
final Integer INTEGER_VALUE = 7;
|
||||
WideningPrimitiveConversion target = new WideningPrimitiveConversion();
|
||||
EvaluationContext emptyEvalContext = new StandardEvaluationContext();
|
||||
|
||||
@@ -682,7 +682,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void varargsAgainstProxy_SPR16122() {
|
||||
void varargsAgainstProxy_SPR16122() {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
Expression expr = parser.parseExpression("process('a', 'b')");
|
||||
|
||||
@@ -696,7 +696,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompiledExpressionForProxy_SPR16191() {
|
||||
void testCompiledExpressionForProxy_SPR16191() {
|
||||
SpelExpressionParser expressionParser =
|
||||
new SpelExpressionParser(new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null));
|
||||
Expression expression = expressionParser.parseExpression("#target.process(#root)");
|
||||
@@ -715,7 +715,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void varargsAndPrimitives_SPR8174() throws Exception {
|
||||
void varargsAndPrimitives_SPR8174() throws Exception {
|
||||
EvaluationContext emptyEvalContext = new StandardEvaluationContext();
|
||||
List<TypeDescriptor> args = new ArrayList<>();
|
||||
|
||||
@@ -763,7 +763,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reservedWords_SPR8228() {
|
||||
void reservedWords_SPR8228() {
|
||||
|
||||
// "DIV","EQ","GE","GT","LE","LT","MOD","NE","NOT"
|
||||
@SuppressWarnings("unused")
|
||||
@@ -814,7 +814,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reservedWordProperties_SPR9862() {
|
||||
void reservedWordProperties_SPR9862() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
SpelExpression expression = parser.parseRaw("T(org.springframework.expression.spel.testresources.le.div.mod.reserved.Reserver).CONST");
|
||||
@@ -829,7 +829,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
* in evaluation of SPEL expressions for a given context.
|
||||
*/
|
||||
@Test
|
||||
public void propertyAccessorOrder_SPR8211() {
|
||||
void propertyAccessorOrder_SPR8211() {
|
||||
ExpressionParser expressionParser = new SpelExpressionParser();
|
||||
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new ContextObject());
|
||||
|
||||
@@ -849,7 +849,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
* determines the set of methods for a type.
|
||||
*/
|
||||
@Test
|
||||
public void customStaticFunctions_SPR9038() {
|
||||
void customStaticFunctions_SPR9038() {
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
List<MethodResolver> methodResolvers = new ArrayList<>();
|
||||
@@ -873,7 +873,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void array() {
|
||||
void array() {
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
Expression expression = null;
|
||||
@@ -902,7 +902,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatFunctionResolver() {
|
||||
void SPR9486_floatFunctionResolver() {
|
||||
Number expectedResult = Math.abs(-10.2f);
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
SPR9486_FunctionsClass testObject = new SPR9486_FunctionsClass();
|
||||
@@ -914,7 +914,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_addFloatWithDouble() {
|
||||
void SPR9486_addFloatWithDouble() {
|
||||
Number expectedNumber = 10.21f + 10.2;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -924,7 +924,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_addFloatWithFloat() {
|
||||
void SPR9486_addFloatWithFloat() {
|
||||
Number expectedNumber = 10.21f + 10.2f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -934,7 +934,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_subtractFloatWithDouble() {
|
||||
void SPR9486_subtractFloatWithDouble() {
|
||||
Number expectedNumber = 10.21f - 10.2;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -944,7 +944,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_subtractFloatWithFloat() {
|
||||
void SPR9486_subtractFloatWithFloat() {
|
||||
Number expectedNumber = 10.21f - 10.2f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -954,7 +954,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_multiplyFloatWithDouble() {
|
||||
void SPR9486_multiplyFloatWithDouble() {
|
||||
Number expectedNumber = 10.21f * 10.2;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -964,7 +964,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_multiplyFloatWithFloat() {
|
||||
void SPR9486_multiplyFloatWithFloat() {
|
||||
Number expectedNumber = 10.21f * 10.2f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -974,7 +974,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatDivideByFloat() {
|
||||
void SPR9486_floatDivideByFloat() {
|
||||
Number expectedNumber = -10.21f / -10.2f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -984,7 +984,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatDivideByDouble() {
|
||||
void SPR9486_floatDivideByDouble() {
|
||||
Number expectedNumber = -10.21f / -10.2;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -994,7 +994,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatEqFloatUnaryMinus() {
|
||||
void SPR9486_floatEqFloatUnaryMinus() {
|
||||
Boolean expectedResult = -10.21f == -10.2f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1004,7 +1004,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatEqDoubleUnaryMinus() {
|
||||
void SPR9486_floatEqDoubleUnaryMinus() {
|
||||
Boolean expectedResult = -10.21f == -10.2;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1014,7 +1014,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatEqFloat() {
|
||||
void SPR9486_floatEqFloat() {
|
||||
Boolean expectedResult = 10.215f == 10.2109f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1024,7 +1024,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatEqDouble() {
|
||||
void SPR9486_floatEqDouble() {
|
||||
Boolean expectedResult = 10.215f == 10.2109;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1034,7 +1034,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatNotEqFloat() {
|
||||
void SPR9486_floatNotEqFloat() {
|
||||
Boolean expectedResult = 10.215f != 10.2109f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1044,7 +1044,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatNotEqDouble() {
|
||||
void SPR9486_floatNotEqDouble() {
|
||||
Boolean expectedResult = 10.215f != 10.2109;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1054,7 +1054,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatLessThanFloat() {
|
||||
void SPR9486_floatLessThanFloat() {
|
||||
Boolean expectedNumber = -10.21f < -10.2f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1064,7 +1064,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatLessThanDouble() {
|
||||
void SPR9486_floatLessThanDouble() {
|
||||
Boolean expectedNumber = -10.21f < -10.2;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1074,7 +1074,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatLessThanOrEqualFloat() {
|
||||
void SPR9486_floatLessThanOrEqualFloat() {
|
||||
Boolean expectedNumber = -10.21f <= -10.22f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1084,7 +1084,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatLessThanOrEqualDouble() {
|
||||
void SPR9486_floatLessThanOrEqualDouble() {
|
||||
Boolean expectedNumber = -10.21f <= -10.2;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1094,7 +1094,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatGreaterThanFloat() {
|
||||
void SPR9486_floatGreaterThanFloat() {
|
||||
Boolean expectedNumber = -10.21f > -10.2f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1104,7 +1104,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatGreaterThanDouble() {
|
||||
void SPR9486_floatGreaterThanDouble() {
|
||||
Boolean expectedResult = -10.21f > -10.2;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1114,7 +1114,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatGreaterThanOrEqualFloat() {
|
||||
void SPR9486_floatGreaterThanOrEqualFloat() {
|
||||
Boolean expectedNumber = -10.21f >= -10.2f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1124,7 +1124,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatGreaterThanEqualDouble() {
|
||||
void SPR9486_floatGreaterThanEqualDouble() {
|
||||
Boolean expectedResult = -10.21f >= -10.2;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1134,7 +1134,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatModulusFloat() {
|
||||
void SPR9486_floatModulusFloat() {
|
||||
Number expectedResult = 10.21f % 10.2f;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1144,7 +1144,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatModulusDouble() {
|
||||
void SPR9486_floatModulusDouble() {
|
||||
Number expectedResult = 10.21f % 10.2;
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1154,7 +1154,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatPowerFloat() {
|
||||
void SPR9486_floatPowerFloat() {
|
||||
Number expectedResult = Math.pow(10.21f, -10.2f);
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1164,7 +1164,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9486_floatPowerDouble() {
|
||||
void SPR9486_floatPowerDouble() {
|
||||
Number expectedResult = Math.pow(10.21f, 10.2);
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
@@ -1174,7 +1174,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9994_bridgeMethods() throws Exception {
|
||||
void SPR9994_bridgeMethods() throws Exception {
|
||||
ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
GenericImplementation target = new GenericImplementation();
|
||||
@@ -1187,7 +1187,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR10162_onlyBridgeMethod() throws Exception {
|
||||
void SPR10162_onlyBridgeMethod() throws Exception {
|
||||
ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
Object target = new OnlyBridgeMethod();
|
||||
@@ -1197,7 +1197,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR10091_simpleTestValueType() {
|
||||
void SPR10091_simpleTestValueType() {
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
|
||||
Class<?> valueType = parser.parseExpression("simpleProperty").getValueType(evaluationContext);
|
||||
@@ -1205,7 +1205,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR10091_simpleTestValue() {
|
||||
void SPR10091_simpleTestValue() {
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
|
||||
Object value = parser.parseExpression("simpleProperty").getValue(evaluationContext);
|
||||
@@ -1213,7 +1213,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR10091_primitiveTestValueType() {
|
||||
void SPR10091_primitiveTestValueType() {
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
|
||||
Class<?> valueType = parser.parseExpression("primitiveProperty").getValueType(evaluationContext);
|
||||
@@ -1221,7 +1221,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR10091_primitiveTestValue() {
|
||||
void SPR10091_primitiveTestValue() {
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
|
||||
Object value = parser.parseExpression("primitiveProperty").getValue(evaluationContext);
|
||||
@@ -1229,7 +1229,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR16123() {
|
||||
void SPR16123() {
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
parser.parseExpression("simpleProperty").setValue(new BooleanHolder(), null);
|
||||
assertThatExceptionOfType(EvaluationException.class).isThrownBy(() ->
|
||||
@@ -1237,7 +1237,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR10146_malformedExpressions() {
|
||||
void SPR10146_malformedExpressions() {
|
||||
doTestSpr10146("/foo", "EL1070E: Problem parsing left operand");
|
||||
doTestSpr10146("*foo", "EL1070E: Problem parsing left operand");
|
||||
doTestSpr10146("%foo", "EL1070E: Problem parsing left operand");
|
||||
@@ -1255,7 +1255,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR10125() {
|
||||
void SPR10125() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
String fromInterface = parser.parseExpression("T(" + StaticFinalImpl1.class.getName() + ").VALUE").getValue(
|
||||
context, String.class);
|
||||
@@ -1266,7 +1266,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR10210() {
|
||||
void SPR10210() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.setVariable("bridgeExample", new org.springframework.expression.spel.spr10210.D());
|
||||
Expression parseExpression = parser.parseExpression("#bridgeExample.bridgeMethod()");
|
||||
@@ -1274,14 +1274,14 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR10328() {
|
||||
void SPR10328() {
|
||||
assertThatExceptionOfType(SpelParseException.class).isThrownBy(() ->
|
||||
parser.parseExpression("$[]"))
|
||||
.withMessageContaining("EL1071E: A required selection expression has not been specified");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR10452() {
|
||||
void SPR10452() {
|
||||
SpelParserConfiguration configuration = new SpelParserConfiguration(false, false);
|
||||
ExpressionParser parser = new SpelExpressionParser(configuration);
|
||||
|
||||
@@ -1306,7 +1306,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9495() {
|
||||
void SPR9495() {
|
||||
SpelParserConfiguration configuration = new SpelParserConfiguration(false, false);
|
||||
ExpressionParser parser = new SpelExpressionParser(configuration);
|
||||
|
||||
@@ -1347,7 +1347,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR10486() {
|
||||
void SPR10486() {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
Spr10486 rootObject = new Spr10486();
|
||||
@@ -1358,7 +1358,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR11142() {
|
||||
void SPR11142() {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
Spr11142 rootObject = new Spr11142();
|
||||
@@ -1369,7 +1369,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9194() {
|
||||
void SPR9194() {
|
||||
TestClass2 one = new TestClass2("abc");
|
||||
TestClass2 two = new TestClass2("abc");
|
||||
Map<String, TestClass2> map = new HashMap<>();
|
||||
@@ -1382,7 +1382,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR11348() {
|
||||
void SPR11348() {
|
||||
Collection<String> coll = new LinkedHashSet<>();
|
||||
coll.add("one");
|
||||
coll.add("two");
|
||||
@@ -1399,14 +1399,14 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR11445_simple() {
|
||||
void SPR11445_simple() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new Spr11445Class());
|
||||
Expression expr = new SpelExpressionParser().parseRaw("echo(parameter())");
|
||||
assertThat(expr.getValue(context)).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR11445_beanReference() {
|
||||
void SPR11445_beanReference() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.setBeanResolver(new Spr11445Class());
|
||||
Expression expr = new SpelExpressionParser().parseRaw("@bean.echo(@bean.parameter())");
|
||||
@@ -1415,14 +1415,14 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void SPR11494() {
|
||||
void SPR11494() {
|
||||
Expression exp = new SpelExpressionParser().parseExpression("T(java.util.Arrays).asList('a','b')");
|
||||
List<String> list = (List<String>) exp.getValue();
|
||||
assertThat(list).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR11609() {
|
||||
void SPR11609() {
|
||||
StandardEvaluationContext sec = new StandardEvaluationContext();
|
||||
sec.addPropertyAccessor(new MapAccessor());
|
||||
Expression exp = new SpelExpressionParser().parseExpression(
|
||||
@@ -1431,7 +1431,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR9735() {
|
||||
void SPR9735() {
|
||||
Item item = new Item();
|
||||
item.setName("parent");
|
||||
|
||||
@@ -1453,7 +1453,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR12502() {
|
||||
void SPR12502() {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
Expression expression = parser.parseExpression("#root.getClass().getName()");
|
||||
assertThat(expression.getValue(new UnnamedUser())).isEqualTo(UnnamedUser.class.getName());
|
||||
@@ -1462,7 +1462,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void SPR12522() {
|
||||
void SPR12522() {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
Expression expression = parser.parseExpression("T(java.util.Arrays).asList('')");
|
||||
Object value = expression.getValue();
|
||||
@@ -1471,7 +1471,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR12803() {
|
||||
void SPR12803() {
|
||||
StandardEvaluationContext sec = new StandardEvaluationContext();
|
||||
sec.setVariable("iterable", Collections.emptyList());
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
@@ -1480,7 +1480,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR12808() {
|
||||
void SPR12808() {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
Expression expression = parser.parseExpression("T(org.springframework.expression.spel.SpelReproTests.DistanceEnforcer).from(#no)");
|
||||
StandardEvaluationContext sec = new StandardEvaluationContext();
|
||||
@@ -1496,7 +1496,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void SPR13055() {
|
||||
void SPR13055() {
|
||||
List<Map<String, Object>> myPayload = new ArrayList<>();
|
||||
|
||||
Map<String, Object> v1 = new HashMap<>();
|
||||
@@ -1527,7 +1527,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void AccessingFactoryBean_spr9511() {
|
||||
void AccessingFactoryBean_spr9511() {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.setBeanResolver(new MyBeanResolver());
|
||||
Expression expr = new SpelExpressionParser().parseRaw("@foo");
|
||||
@@ -1551,7 +1551,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR12035() {
|
||||
void SPR12035() {
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
|
||||
Expression expression1 = parser.parseExpression("list.?[ value>2 ].size()!=0");
|
||||
@@ -1562,7 +1562,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR13055_maps() {
|
||||
void SPR13055_maps() {
|
||||
EvaluationContext context = new StandardEvaluationContext();
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
|
||||
@@ -1578,7 +1578,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void SPR10417() {
|
||||
void SPR10417() {
|
||||
List list1 = new ArrayList();
|
||||
list1.add("a");
|
||||
list1.add("b");
|
||||
@@ -1619,7 +1619,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void SPR10417_maps() {
|
||||
void SPR10417_maps() {
|
||||
Map map1 = new HashMap();
|
||||
map1.put("A", 65);
|
||||
map1.put("B", 66);
|
||||
@@ -1642,7 +1642,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR13918() {
|
||||
void SPR13918() {
|
||||
EvaluationContext context = new StandardEvaluationContext();
|
||||
context.setVariable("encoding", "UTF-8");
|
||||
|
||||
@@ -1652,7 +1652,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR16032() {
|
||||
void SPR16032() {
|
||||
EvaluationContext context = new StandardEvaluationContext();
|
||||
context.setVariable("str", "a\0b");
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ description = "Spring JDBC"
|
||||
apply plugin: "kotlin"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-tx"))
|
||||
api(project(":spring-beans"))
|
||||
api(project(":spring-core"))
|
||||
api(project(":spring-tx"))
|
||||
optional(project(":spring-context")) // for JndiDataSourceLookup
|
||||
optional("javax.transaction:javax.transaction-api")
|
||||
optional("org.hsqldb:hsqldb")
|
||||
@@ -14,6 +14,6 @@ dependencies {
|
||||
optional("org.apache.derby:derbyclient")
|
||||
optional("org.jetbrains.kotlin:kotlin-reflect")
|
||||
optional("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
testCompile(testFixtures(project(":spring-beans")))
|
||||
testCompile(testFixtures(project(":spring-core")))
|
||||
testImplementation(testFixtures(project(":spring-beans")))
|
||||
testImplementation(testFixtures(project(":spring-core")))
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
description = "Spring JMS"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-messaging"))
|
||||
compile(project(":spring-tx"))
|
||||
api(project(":spring-beans"))
|
||||
api(project(":spring-core"))
|
||||
api(project(":spring-messaging"))
|
||||
api(project(":spring-tx"))
|
||||
compileOnly("javax.jms:javax.jms-api")
|
||||
optional(project(":spring-aop"))
|
||||
optional(project(":spring-context"))
|
||||
@@ -12,8 +12,8 @@ dependencies {
|
||||
optional("javax.resource:javax.resource-api")
|
||||
optional("javax.transaction:javax.transaction-api")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind")
|
||||
testCompile(testFixtures(project(":spring-beans")))
|
||||
testCompile(testFixtures(project(":spring-tx")))
|
||||
testCompile("org.apache.activemq:activemq-broker")
|
||||
testImplementation(testFixtures(project(":spring-beans")))
|
||||
testImplementation(testFixtures(project(":spring-tx")))
|
||||
testImplementation("org.apache.activemq:activemq-broker")
|
||||
testImplementation("javax.jms:javax.jms-api")
|
||||
}
|
||||
|
||||
+2
-1
@@ -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.
|
||||
@@ -92,6 +92,7 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B
|
||||
private ClassLoader beanClassLoader;
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation") // on Jackson 2.13: configure(MapperFeature, boolean)
|
||||
public MappingJackson2MessageConverter() {
|
||||
this.objectMapper = new ObjectMapper();
|
||||
this.objectMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);
|
||||
|
||||
+26
-30
@@ -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.
|
||||
@@ -32,7 +32,6 @@ import javax.jms.Session;
|
||||
import javax.jms.TextMessage;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.jms.support.converter.MessageConversionException;
|
||||
@@ -51,7 +50,7 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class MessageListenerAdapterTests {
|
||||
class MessageListenerAdapterTests {
|
||||
|
||||
private static final String TEXT = "I fancy a good cuppa right now";
|
||||
|
||||
@@ -65,7 +64,7 @@ public class MessageListenerAdapterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithMessageContentsDelegateForTextMessage() throws Exception {
|
||||
void testWithMessageContentsDelegateForTextMessage() throws Exception {
|
||||
TextMessage textMessage = mock(TextMessage.class);
|
||||
// TextMessage contents must be unwrapped...
|
||||
given(textMessage.getText()).willReturn(TEXT);
|
||||
@@ -79,17 +78,14 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithMessageContentsDelegateForBytesMessage() throws Exception {
|
||||
void testWithMessageContentsDelegateForBytesMessage() throws Exception {
|
||||
BytesMessage bytesMessage = mock(BytesMessage.class);
|
||||
// BytesMessage contents must be unwrapped...
|
||||
given(bytesMessage.getBodyLength()).willReturn(new Long(TEXT.getBytes().length));
|
||||
given(bytesMessage.readBytes(any(byte[].class))).willAnswer(new Answer<Integer>() {
|
||||
@Override
|
||||
public Integer answer(InvocationOnMock invocation) throws Throwable {
|
||||
byte[] bytes = (byte[]) invocation.getArguments()[0];
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(TEXT.getBytes());
|
||||
return inputStream.read(bytes);
|
||||
}
|
||||
given(bytesMessage.getBodyLength()).willReturn(Long.valueOf(TEXT.getBytes().length));
|
||||
given(bytesMessage.readBytes(any(byte[].class))).willAnswer((Answer<Integer>) invocation -> {
|
||||
byte[] bytes = (byte[]) invocation.getArguments()[0];
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(TEXT.getBytes());
|
||||
return inputStream.read(bytes);
|
||||
});
|
||||
|
||||
MessageContentsDelegate delegate = mock(MessageContentsDelegate.class);
|
||||
@@ -101,7 +97,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithMessageContentsDelegateForObjectMessage() throws Exception {
|
||||
void testWithMessageContentsDelegateForObjectMessage() throws Exception {
|
||||
ObjectMessage objectMessage = mock(ObjectMessage.class);
|
||||
given(objectMessage.getObject()).willReturn(NUMBER);
|
||||
|
||||
@@ -114,7 +110,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithMessageContentsDelegateForObjectMessageWithPlainObject() throws Exception {
|
||||
void testWithMessageContentsDelegateForObjectMessageWithPlainObject() throws Exception {
|
||||
ObjectMessage objectMessage = mock(ObjectMessage.class);
|
||||
given(objectMessage.getObject()).willReturn(OBJECT);
|
||||
|
||||
@@ -127,7 +123,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithMessageDelegate() throws Exception {
|
||||
void testWithMessageDelegate() throws Exception {
|
||||
TextMessage textMessage = mock(TextMessage.class);
|
||||
|
||||
MessageDelegate delegate = mock(MessageDelegate.class);
|
||||
@@ -141,7 +137,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWhenTheAdapterItselfIsTheDelegate() throws Exception {
|
||||
void testWhenTheAdapterItselfIsTheDelegate() throws Exception {
|
||||
TextMessage textMessage = mock(TextMessage.class);
|
||||
// TextMessage contents must be unwrapped...
|
||||
given(textMessage.getText()).willReturn(TEXT);
|
||||
@@ -152,7 +148,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRainyDayWithNoApplicableHandlingMethods() throws Exception {
|
||||
void testRainyDayWithNoApplicableHandlingMethods() throws Exception {
|
||||
TextMessage textMessage = mock(TextMessage.class);
|
||||
// TextMessage contents must be unwrapped...
|
||||
given(textMessage.getText()).willReturn(TEXT);
|
||||
@@ -164,7 +160,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatAnExceptionThrownFromTheHandlingMethodIsSimplySwallowedByDefault() throws Exception {
|
||||
void testThatAnExceptionThrownFromTheHandlingMethodIsSimplySwallowedByDefault() throws Exception {
|
||||
final IllegalArgumentException exception = new IllegalArgumentException();
|
||||
|
||||
TextMessage textMessage = mock(TextMessage.class);
|
||||
@@ -189,7 +185,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter() throws Exception {
|
||||
void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter() throws Exception {
|
||||
MessageListenerAdapter adapter = new MessageListenerAdapter();
|
||||
assertThat(adapter.getMessageConverter()).as("The default [MessageConverter] must never be null.").isNotNull();
|
||||
boolean condition = adapter.getMessageConverter() instanceof SimpleMessageConverter;
|
||||
@@ -197,19 +193,19 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatWhenNoDelegateIsSuppliedTheDelegateIsAssumedToBeTheMessageListenerAdapterItself() throws Exception {
|
||||
void testThatWhenNoDelegateIsSuppliedTheDelegateIsAssumedToBeTheMessageListenerAdapterItself() throws Exception {
|
||||
MessageListenerAdapter adapter = new MessageListenerAdapter();
|
||||
assertThat(adapter.getDelegate()).isSameAs(adapter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatTheDefaultMessageHandlingMethodNameIsTheConstantDefault() throws Exception {
|
||||
void testThatTheDefaultMessageHandlingMethodNameIsTheConstantDefault() throws Exception {
|
||||
MessageListenerAdapter adapter = new MessageListenerAdapter();
|
||||
assertThat(adapter.getDefaultListenerMethod()).isEqualTo(MessageListenerAdapter.ORIGINAL_DEFAULT_LISTENER_METHOD);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
|
||||
void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
|
||||
TextMessage textMessage = mock(TextMessage.class);
|
||||
ResponsiveMessageDelegate delegate = mock(ResponsiveMessageDelegate.class);
|
||||
given(delegate.handleMessage(textMessage)).willReturn(TEXT);
|
||||
@@ -221,7 +217,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||
void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||
Queue destination = mock(Queue.class);
|
||||
TextMessage sentTextMessage = mock(TextMessage.class);
|
||||
// correlation ID is queried when response is being created...
|
||||
@@ -256,7 +252,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||
void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||
Queue destination = mock(Queue.class);
|
||||
TextMessage sentTextMessage = mock(TextMessage.class);
|
||||
// correlation ID is queried when response is being created...
|
||||
@@ -289,7 +285,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||
void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||
final TextMessage sentTextMessage = mock(TextMessage.class);
|
||||
// correlation ID is queried when response is being created...
|
||||
given(sentTextMessage.getJMSCorrelationID()).willReturn(CORRELATION_ID);
|
||||
@@ -318,7 +314,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
|
||||
void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
|
||||
Queue destination = mock(Queue.class);
|
||||
|
||||
final TextMessage sentTextMessage = mock(TextMessage.class);
|
||||
@@ -354,7 +350,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
|
||||
void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
|
||||
final TextMessage message = mock(TextMessage.class);
|
||||
final QueueSession session = mock(QueueSession.class);
|
||||
|
||||
@@ -372,7 +368,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithResponsiveMessageDelegateWhenReturnTypeIsNotAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
|
||||
void testWithResponsiveMessageDelegateWhenReturnTypeIsNotAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
|
||||
final TextMessage sentTextMessage = mock(TextMessage.class);
|
||||
final Session session = mock(Session.class);
|
||||
ResponsiveMessageDelegate delegate = mock(ResponsiveMessageDelegate.class);
|
||||
@@ -391,7 +387,7 @@ public class MessageListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithResponsiveMessageDelegateWhenReturnTypeIsAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
|
||||
void testWithResponsiveMessageDelegateWhenReturnTypeIsAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
|
||||
Queue destination = mock(Queue.class);
|
||||
final TextMessage sentTextMessage = mock(TextMessage.class);
|
||||
// correlation ID is queried when response is being created...
|
||||
|
||||
+18
-24
@@ -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.
|
||||
@@ -31,7 +31,6 @@ import javax.jms.TextMessage;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
@@ -49,7 +48,7 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Dave Syer
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class MappingJackson2MessageConverterTests {
|
||||
class MappingJackson2MessageConverterTests {
|
||||
|
||||
private MappingJackson2MessageConverter converter;
|
||||
|
||||
@@ -66,7 +65,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void toBytesMessage() throws Exception {
|
||||
void toBytesMessage() throws Exception {
|
||||
BytesMessage bytesMessageMock = mock(BytesMessage.class);
|
||||
Date toBeMarshalled = new Date();
|
||||
|
||||
@@ -80,7 +79,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromBytesMessage() throws Exception {
|
||||
void fromBytesMessage() throws Exception {
|
||||
BytesMessage bytesMessageMock = mock(BytesMessage.class);
|
||||
Map<String, String> unmarshalled = Collections.singletonMap("foo", "bar");
|
||||
|
||||
@@ -89,21 +88,16 @@ public class MappingJackson2MessageConverterTests {
|
||||
|
||||
given(bytesMessageMock.getStringProperty("__typeid__")).willReturn(Object.class.getName());
|
||||
given(bytesMessageMock.propertyExists("__encoding__")).willReturn(false);
|
||||
given(bytesMessageMock.getBodyLength()).willReturn(new Long(bytes.length));
|
||||
given(bytesMessageMock.getBodyLength()).willReturn(Long.valueOf(bytes.length));
|
||||
given(bytesMessageMock.readBytes(any(byte[].class))).willAnswer(
|
||||
new Answer<Integer>() {
|
||||
@Override
|
||||
public Integer answer(InvocationOnMock invocation) throws Throwable {
|
||||
return byteStream.read((byte[]) invocation.getArguments()[0]);
|
||||
}
|
||||
});
|
||||
(Answer<Integer>) invocation -> byteStream.read((byte[]) invocation.getArguments()[0]));
|
||||
|
||||
Object result = converter.fromMessage(bytesMessageMock);
|
||||
assertThat(unmarshalled).as("Invalid result").isEqualTo(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toTextMessageWithObject() throws Exception {
|
||||
void toTextMessageWithObject() throws Exception {
|
||||
converter.setTargetType(MessageType.TEXT);
|
||||
TextMessage textMessageMock = mock(TextMessage.class);
|
||||
Date toBeMarshalled = new Date();
|
||||
@@ -115,7 +109,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toTextMessageWithMap() throws Exception {
|
||||
void toTextMessageWithMap() throws Exception {
|
||||
converter.setTargetType(MessageType.TEXT);
|
||||
TextMessage textMessageMock = mock(TextMessage.class);
|
||||
Map<String, String> toBeMarshalled = new HashMap<>();
|
||||
@@ -128,7 +122,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromTextMessage() throws Exception {
|
||||
void fromTextMessage() throws Exception {
|
||||
TextMessage textMessageMock = mock(TextMessage.class);
|
||||
MyBean unmarshalled = new MyBean("bar");
|
||||
|
||||
@@ -141,7 +135,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromTextMessageWithUnknownProperty() throws Exception {
|
||||
void fromTextMessageWithUnknownProperty() throws Exception {
|
||||
TextMessage textMessageMock = mock(TextMessage.class);
|
||||
MyBean unmarshalled = new MyBean("bar");
|
||||
|
||||
@@ -154,7 +148,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromTextMessageAsObject() throws Exception {
|
||||
void fromTextMessageAsObject() throws Exception {
|
||||
TextMessage textMessageMock = mock(TextMessage.class);
|
||||
Map<String, String> unmarshalled = Collections.singletonMap("foo", "bar");
|
||||
|
||||
@@ -167,7 +161,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromTextMessageAsMap() throws Exception {
|
||||
void fromTextMessageAsMap() throws Exception {
|
||||
TextMessage textMessageMock = mock(TextMessage.class);
|
||||
Map<String, String> unmarshalled = Collections.singletonMap("foo", "bar");
|
||||
|
||||
@@ -180,7 +174,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toTextMessageWithReturnType() throws JMSException, NoSuchMethodException {
|
||||
void toTextMessageWithReturnType() throws JMSException, NoSuchMethodException {
|
||||
Method method = this.getClass().getDeclaredMethod("summary");
|
||||
MethodParameter returnType = new MethodParameter(method, -1);
|
||||
testToTextMessageWithReturnType(returnType);
|
||||
@@ -188,13 +182,13 @@ public class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toTextMessageWithNullReturnType() throws JMSException, NoSuchMethodException {
|
||||
void toTextMessageWithNullReturnType() throws JMSException, NoSuchMethodException {
|
||||
testToTextMessageWithReturnType(null);
|
||||
verify(sessionMock).createTextMessage("{\"name\":\"test\",\"description\":\"lengthy description\"}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toTextMessageWithReturnTypeAndNoJsonView() throws JMSException, NoSuchMethodException {
|
||||
void toTextMessageWithReturnTypeAndNoJsonView() throws JMSException, NoSuchMethodException {
|
||||
Method method = this.getClass().getDeclaredMethod("none");
|
||||
MethodParameter returnType = new MethodParameter(method, -1);
|
||||
|
||||
@@ -203,7 +197,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toTextMessageWithReturnTypeAndMultipleJsonViews() throws JMSException, NoSuchMethodException {
|
||||
void toTextMessageWithReturnTypeAndMultipleJsonViews() throws JMSException, NoSuchMethodException {
|
||||
Method method = this.getClass().getDeclaredMethod("invalid");
|
||||
MethodParameter returnType = new MethodParameter(method, -1);
|
||||
|
||||
@@ -222,7 +216,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toTextMessageWithJsonViewClass() throws JMSException {
|
||||
void toTextMessageWithJsonViewClass() throws JMSException {
|
||||
converter.setTargetType(MessageType.TEXT);
|
||||
TextMessage textMessageMock = mock(TextMessage.class);
|
||||
|
||||
@@ -236,7 +230,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toTextMessageWithAnotherJsonViewClass() throws JMSException {
|
||||
void toTextMessageWithAnotherJsonViewClass() throws JMSException {
|
||||
converter.setTargetType(MessageType.TEXT);
|
||||
TextMessage textMessageMock = mock(TextMessage.class);
|
||||
|
||||
|
||||
@@ -4,9 +4,8 @@ apply plugin: "kotlin"
|
||||
apply plugin: "kotlinx-serialization"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
compileOnly(project(":kotlin-coroutines"))
|
||||
api(project(":spring-beans"))
|
||||
api(project(":spring-core"))
|
||||
optional(project(":spring-context"))
|
||||
optional(project(":spring-oxm"))
|
||||
optional("io.projectreactor.netty:reactor-netty-http")
|
||||
@@ -19,25 +18,24 @@ dependencies {
|
||||
optional("com.google.protobuf:protobuf-java-util")
|
||||
optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
|
||||
optional("org.jetbrains.kotlinx:kotlinx-serialization-json")
|
||||
testCompile(project(":kotlin-coroutines"))
|
||||
testCompile(testFixtures(project(":spring-core")))
|
||||
testCompile("javax.inject:javax.inject-tck")
|
||||
testCompile("javax.servlet:javax.servlet-api")
|
||||
testCompile("javax.validation:validation-api")
|
||||
testCompile("com.thoughtworks.xstream:xstream")
|
||||
testCompile("org.apache.activemq:activemq-broker")
|
||||
testCompile("org.apache.activemq:activemq-kahadb-store")
|
||||
testCompile("org.apache.activemq:activemq-stomp")
|
||||
testCompile("io.projectreactor:reactor-test")
|
||||
testCompile "io.reactivex.rxjava3:rxjava"
|
||||
testCompile("org.jetbrains.kotlin:kotlin-reflect")
|
||||
testCompile("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
testCompile("org.xmlunit:xmlunit-assertj")
|
||||
testCompile("org.xmlunit:xmlunit-matchers")
|
||||
testRuntime("com.sun.activation:javax.activation")
|
||||
testRuntime("com.sun.xml.bind:jaxb-core")
|
||||
testRuntime("com.sun.xml.bind:jaxb-impl")
|
||||
testRuntime("javax.json:javax.json-api")
|
||||
testRuntime("org.apache.johnzon:johnzon-jsonb")
|
||||
testRuntime(project(":spring-context"))
|
||||
testImplementation(testFixtures(project(":spring-core")))
|
||||
testImplementation("javax.inject:javax.inject-tck")
|
||||
testImplementation("javax.servlet:javax.servlet-api")
|
||||
testImplementation("javax.validation:validation-api")
|
||||
testImplementation("com.thoughtworks.xstream:xstream")
|
||||
testImplementation("org.apache.activemq:activemq-broker")
|
||||
testImplementation("org.apache.activemq:activemq-kahadb-store")
|
||||
testImplementation("org.apache.activemq:activemq-stomp")
|
||||
testImplementation("io.projectreactor:reactor-test")
|
||||
testImplementation("io.reactivex.rxjava3:rxjava")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
testImplementation("org.xmlunit:xmlunit-assertj")
|
||||
testImplementation("org.xmlunit:xmlunit-matchers")
|
||||
testRuntimeOnly("com.sun.activation:javax.activation")
|
||||
testRuntimeOnly("com.sun.xml.bind:jaxb-core")
|
||||
testRuntimeOnly("com.sun.xml.bind:jaxb-impl")
|
||||
testRuntimeOnly("javax.json:javax.json-api")
|
||||
testRuntimeOnly("org.apache.johnzon:johnzon-jsonb")
|
||||
testRuntimeOnly(project(":spring-context"))
|
||||
}
|
||||
|
||||
+2
-1
@@ -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.
|
||||
@@ -88,6 +88,7 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation") // on Jackson 2.13: configure(MapperFeature, boolean)
|
||||
private ObjectMapper initObjectMapper() {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);
|
||||
|
||||
+5
-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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -87,6 +88,7 @@ public class HandlerMethod {
|
||||
this.beanType = ClassUtils.getUserClass(bean);
|
||||
this.method = method;
|
||||
this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
|
||||
ReflectionUtils.makeAccessible(this.bridgedMethod);
|
||||
this.parameters = initMethodParameters();
|
||||
}
|
||||
|
||||
@@ -102,6 +104,7 @@ public class HandlerMethod {
|
||||
this.beanType = ClassUtils.getUserClass(bean);
|
||||
this.method = bean.getClass().getMethod(methodName, parameterTypes);
|
||||
this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(this.method);
|
||||
ReflectionUtils.makeAccessible(this.bridgedMethod);
|
||||
this.parameters = initMethodParameters();
|
||||
}
|
||||
|
||||
@@ -123,6 +126,7 @@ public class HandlerMethod {
|
||||
this.beanType = ClassUtils.getUserClass(beanType);
|
||||
this.method = method;
|
||||
this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
|
||||
ReflectionUtils.makeAccessible(this.bridgedMethod);
|
||||
this.parameters = initMethodParameters();
|
||||
}
|
||||
|
||||
|
||||
+8
-4
@@ -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.
|
||||
@@ -53,6 +53,7 @@ import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.util.concurrent.ListenableFutureCallback;
|
||||
|
||||
@@ -319,9 +320,12 @@ public abstract class AbstractMethodMessageHandler<T>
|
||||
}
|
||||
|
||||
private String formatMappings(Class<?> userType, Map<Method, T> methods) {
|
||||
String formattedType = Arrays.stream(ClassUtils.getPackageName(userType).split("\\."))
|
||||
.map(p -> p.substring(0, 1))
|
||||
.collect(Collectors.joining(".", "", "." + userType.getSimpleName()));
|
||||
String packageName = ClassUtils.getPackageName(userType);
|
||||
String formattedType = (StringUtils.hasText(packageName) ?
|
||||
Arrays.stream(packageName.split("\\."))
|
||||
.map(packageSegment -> packageSegment.substring(0, 1))
|
||||
.collect(Collectors.joining(".", "", "." + userType.getSimpleName())) :
|
||||
userType.getSimpleName());
|
||||
Function<Method, String> methodFormatter = method -> Arrays.stream(method.getParameterTypes())
|
||||
.map(Class::getSimpleName)
|
||||
.collect(Collectors.joining(",", "(", ")"));
|
||||
|
||||
+1
-3
@@ -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.
|
||||
@@ -29,7 +29,6 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.HandlerMethod;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Extension of {@link HandlerMethod} that invokes the underlying method with
|
||||
@@ -166,7 +165,6 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
*/
|
||||
@Nullable
|
||||
protected Object doInvoke(Object... args) throws Exception {
|
||||
ReflectionUtils.makeAccessible(getBridgedMethod());
|
||||
try {
|
||||
return getBridgedMethod().invoke(getBean(), args);
|
||||
}
|
||||
|
||||
+8
-4
@@ -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.
|
||||
@@ -54,6 +54,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.RouteMatcher;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Abstract base class for reactive HandlerMethod-based message handling.
|
||||
@@ -341,9 +342,12 @@ public abstract class AbstractMethodMessageHandler<T>
|
||||
}
|
||||
|
||||
private String formatMappings(Class<?> userType, Map<Method, T> methods) {
|
||||
String formattedType = Arrays.stream(ClassUtils.getPackageName(userType).split("\\."))
|
||||
.map(p -> p.substring(0, 1))
|
||||
.collect(Collectors.joining(".", "", "." + userType.getSimpleName()));
|
||||
String packageName = ClassUtils.getPackageName(userType);
|
||||
String formattedType = (StringUtils.hasText(packageName) ?
|
||||
Arrays.stream(packageName.split("\\."))
|
||||
.map(packageSegment -> packageSegment.substring(0, 1))
|
||||
.collect(Collectors.joining(".", "", "." + userType.getSimpleName())) :
|
||||
userType.getSimpleName());
|
||||
Function<Method, String> methodFormatter = method -> Arrays.stream(method.getParameterTypes())
|
||||
.map(Class::getSimpleName)
|
||||
.collect(Collectors.joining(",", "(", ")"));
|
||||
|
||||
+1
-3
@@ -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.
|
||||
@@ -38,7 +38,6 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.HandlerMethod;
|
||||
import org.springframework.messaging.handler.invocation.MethodArgumentResolutionException;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Extension of {@link HandlerMethod} that invokes the underlying method with
|
||||
@@ -130,7 +129,6 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
boolean isSuspendingFunction = false;
|
||||
try {
|
||||
Method method = getBridgedMethod();
|
||||
ReflectionUtils.makeAccessible(method);
|
||||
if (KotlinDetector.isSuspendingFunction(method)) {
|
||||
isSuspendingFunction = true;
|
||||
value = CoroutinesUtils.invokeSuspendingFunction(method, getBean(), args);
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ import org.springframework.validation.Validator;
|
||||
* </ul>
|
||||
*
|
||||
* <p>{@link #brokerChannel} delivers messages from within the application to the
|
||||
* the respective message handlers. {@link #brokerMessagingTemplate} can be injected
|
||||
* respective message handlers. {@link #brokerMessagingTemplate} can be injected
|
||||
* into any application component to send messages.
|
||||
*
|
||||
* <p>Subclasses are responsible for the parts of the configuration that feed messages
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
description = "Spring Object/Relational Mapping"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-jdbc"))
|
||||
compile(project(":spring-tx"))
|
||||
api(project(":spring-beans"))
|
||||
api(project(":spring-core"))
|
||||
api(project(":spring-jdbc"))
|
||||
api(project(":spring-tx"))
|
||||
optional(project(":spring-aop"))
|
||||
optional(project(":spring-context"))
|
||||
optional(project(":spring-web"))
|
||||
optional("org.eclipse.persistence:org.eclipse.persistence.jpa")
|
||||
optional("org.hibernate:hibernate-core")
|
||||
optional("javax.servlet:javax.servlet-api:3.1.0")
|
||||
testCompile(testFixtures(project(":spring-beans")))
|
||||
testCompile(testFixtures(project(":spring-context")))
|
||||
testCompile(testFixtures(project(":spring-core")))
|
||||
testCompile(testFixtures(project(":spring-web")))
|
||||
testCompile("org.aspectj:aspectjweaver")
|
||||
testCompile("org.hsqldb:hsqldb")
|
||||
testRuntime("javax.xml.bind:jaxb-api")
|
||||
optional("javax.servlet:javax.servlet-api")
|
||||
testImplementation(testFixtures(project(":spring-beans")))
|
||||
testImplementation(testFixtures(project(":spring-context")))
|
||||
testImplementation(testFixtures(project(":spring-core")))
|
||||
testImplementation(testFixtures(project(":spring-web")))
|
||||
testImplementation("org.aspectj:aspectjweaver")
|
||||
testImplementation("org.hsqldb:hsqldb")
|
||||
testRuntimeOnly("javax.xml.bind:jaxb-api")
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ dependencies {
|
||||
xjc {
|
||||
xjcVersion = '2.2'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
test {
|
||||
xjcTargetPackage = 'org.springframework.oxm.jaxb.test'
|
||||
@@ -23,23 +24,23 @@ sourceSets {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
api(project(":spring-beans"))
|
||||
api(project(":spring-core"))
|
||||
optional("javax.xml.bind:jaxb-api")
|
||||
optional("javax.activation:javax.activation-api")
|
||||
optional("com.thoughtworks.xstream:xstream")
|
||||
optional("org.jibx:jibx-run")
|
||||
testCompile(project(":spring-context"))
|
||||
testCompile(testFixtures(project(":spring-core")))
|
||||
testCompile("org.ogce:xpp3")
|
||||
testCompile("org.codehaus.jettison:jettison") {
|
||||
testImplementation(project(":spring-context"))
|
||||
testImplementation(testFixtures(project(":spring-core")))
|
||||
testImplementation("org.ogce:xpp3")
|
||||
testImplementation("org.codehaus.jettison:jettison") {
|
||||
exclude group: "stax", module: "stax-api"
|
||||
}
|
||||
//testCompile(files(genJaxb.classesDir).builtBy(genJaxb))
|
||||
testCompile("org.xmlunit:xmlunit-assertj")
|
||||
testCompile("org.xmlunit:xmlunit-matchers")
|
||||
testRuntime("com.sun.xml.bind:jaxb-core")
|
||||
testRuntime("com.sun.xml.bind:jaxb-impl")
|
||||
//testImplementation(files(genJaxb.classesDir).builtBy(genJaxb))
|
||||
testImplementation("org.xmlunit:xmlunit-assertj")
|
||||
testImplementation("org.xmlunit:xmlunit-matchers")
|
||||
testRuntimeOnly("com.sun.xml.bind:jaxb-core")
|
||||
testRuntimeOnly("com.sun.xml.bind:jaxb-impl")
|
||||
}
|
||||
|
||||
// JiBX compiler is currently not compatible with JDK 9+.
|
||||
@@ -55,7 +56,7 @@ if ((JavaVersion.current() == JavaVersion.VERSION_1_8) && !project.hasProperty("
|
||||
classpath: configurations.jibx.asPath)
|
||||
|
||||
jibx(verbose: false, load: true, binding: bindingXml) {
|
||||
classpathset(dir: sourceSets.test.java.outputDir) {
|
||||
classpathset(dir: sourceSets.test.java.classesDirectory.get().getAsFile()) {
|
||||
include(name: "**/jibx/**/*")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -63,6 +63,8 @@ import com.thoughtworks.xstream.io.xml.XppDriver;
|
||||
import com.thoughtworks.xstream.mapper.CannotResolveClassException;
|
||||
import com.thoughtworks.xstream.mapper.Mapper;
|
||||
import com.thoughtworks.xstream.mapper.MapperWrapper;
|
||||
import com.thoughtworks.xstream.security.ForbiddenClassException;
|
||||
import com.thoughtworks.xstream.security.TypePermission;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
@@ -106,7 +108,7 @@ import org.springframework.util.xml.StaxUtils;
|
||||
* Therefore, it has limited namespace support. As such, it is rather unsuitable for
|
||||
* usage within Web Services.
|
||||
*
|
||||
* <p>This marshaller requires XStream 1.4.5 or higher, as of Spring 4.3.
|
||||
* <p>This marshaller requires XStream 1.4.7 or higher, as of Spring 5.2.17.
|
||||
* Note that {@link XStream} construction has been reworked in 4.0, with the
|
||||
* stream driver and the class loader getting passed into XStream itself now.
|
||||
*
|
||||
@@ -146,6 +148,9 @@ public class XStreamMarshaller extends AbstractMarshaller implements BeanClassLo
|
||||
@Nullable
|
||||
private ConverterMatcher[] converters;
|
||||
|
||||
@Nullable
|
||||
private TypePermission[] typePermissions;
|
||||
|
||||
@Nullable
|
||||
private MarshallingStrategy marshallingStrategy;
|
||||
|
||||
@@ -268,6 +273,20 @@ public class XStreamMarshaller extends AbstractMarshaller implements BeanClassLo
|
||||
this.converters = converters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set XStream type permissions such as
|
||||
* {@link com.thoughtworks.xstream.security.AnyTypePermission},
|
||||
* {@link com.thoughtworks.xstream.security.ExplicitTypePermission} etc,
|
||||
* as an alternative to overriding the {@link #customizeXStream} method.
|
||||
* <p>Note: As of XStream 1.4.18, the default type permissions are
|
||||
* restricted to well-known core JDK types. For any custom types,
|
||||
* explicit type permissions need to be registered.
|
||||
* @since 5.2.17
|
||||
*/
|
||||
public void setTypePermissions(TypePermission... typePermissions) {
|
||||
this.typePermissions = typePermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom XStream {@link MarshallingStrategy} to use.
|
||||
* @since 4.0
|
||||
@@ -407,7 +426,7 @@ public class XStreamMarshaller extends AbstractMarshaller implements BeanClassLo
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
// no-op due to use of SingletonSupplier for the XStream field.
|
||||
// no-op due to use of SingletonSupplier for the XStream field
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -479,6 +498,12 @@ public class XStreamMarshaller extends AbstractMarshaller implements BeanClassLo
|
||||
}
|
||||
}
|
||||
|
||||
if (this.typePermissions != null) {
|
||||
for (TypePermission permission : this.typePermissions) {
|
||||
xstream.addPermission(permission);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.marshallingStrategy != null) {
|
||||
xstream.setMarshallingStrategy(this.marshallingStrategy);
|
||||
}
|
||||
@@ -844,7 +869,7 @@ public class XStreamMarshaller extends AbstractMarshaller implements BeanClassLo
|
||||
*/
|
||||
protected XmlMappingException convertXStreamException(Exception ex, boolean marshalling) {
|
||||
if (ex instanceof StreamException || ex instanceof CannotResolveClassException ||
|
||||
ex instanceof ConversionException) {
|
||||
ex instanceof ForbiddenClassException || ex instanceof ConversionException) {
|
||||
if (marshalling) {
|
||||
return new MarshallingFailureException("XStream marshalling exception", ex);
|
||||
}
|
||||
|
||||
+8
-4
@@ -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.
|
||||
@@ -43,6 +43,7 @@ import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
|
||||
import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
|
||||
import com.thoughtworks.xstream.io.json.JsonWriter;
|
||||
import com.thoughtworks.xstream.security.AnyTypePermission;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InOrder;
|
||||
@@ -67,18 +68,21 @@ import static org.mockito.Mockito.mock;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
class XStreamMarshallerTests {
|
||||
|
||||
private static final String EXPECTED_STRING = "<flight><flightNumber>42</flightNumber></flight>";
|
||||
|
||||
private final XStreamMarshaller marshaller = new XStreamMarshaller();
|
||||
|
||||
private final Flight flight = new Flight();
|
||||
|
||||
private XStreamMarshaller marshaller;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
void createMarshaller() {
|
||||
marshaller = new XStreamMarshaller();
|
||||
marshaller.setTypePermissions(AnyTypePermission.ANY);
|
||||
marshaller.setAliases(Collections.singletonMap("flight", Flight.class.getName()));
|
||||
flight.setFlightNumber(42L);
|
||||
}
|
||||
@@ -143,7 +147,7 @@ class XStreamMarshallerTests {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
StreamResult result = new StreamResult(os);
|
||||
marshaller.marshal(flight, result);
|
||||
String s = new String(os.toByteArray(), "UTF-8");
|
||||
String s = os.toString("UTF-8");
|
||||
assertThat(XmlContent.of(s)).isSimilarTo(EXPECTED_STRING);
|
||||
}
|
||||
|
||||
|
||||
+18
-10
@@ -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.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.oxm.xstream;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -29,6 +30,7 @@ import javax.xml.transform.Source;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import com.thoughtworks.xstream.security.AnyTypePermission;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -40,6 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class XStreamUnmarshallerTests {
|
||||
|
||||
@@ -47,21 +50,16 @@ public class XStreamUnmarshallerTests {
|
||||
|
||||
private XStreamMarshaller unmarshaller;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void createUnmarshaller() throws Exception {
|
||||
public void createUnmarshaller() {
|
||||
unmarshaller = new XStreamMarshaller();
|
||||
unmarshaller.setTypePermissions(AnyTypePermission.ANY);
|
||||
Map<String, Class<?>> aliases = new HashMap<>();
|
||||
aliases.put("flight", Flight.class);
|
||||
unmarshaller.setAliases(aliases);
|
||||
}
|
||||
|
||||
private void testFlight(Object o) {
|
||||
boolean condition = o instanceof Flight;
|
||||
assertThat(condition).as("Unmarshalled object is not Flights").isTrue();
|
||||
Flight flight = (Flight) o;
|
||||
assertThat(flight).as("Flight is null").isNotNull();
|
||||
assertThat(flight.getFlightNumber()).as("Number is invalid").isEqualTo(42L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unmarshalDomSource() throws Exception {
|
||||
@@ -83,7 +81,7 @@ public class XStreamUnmarshallerTests {
|
||||
|
||||
@Test
|
||||
public void unmarshalStreamSourceInputStream() throws Exception {
|
||||
StreamSource source = new StreamSource(new ByteArrayInputStream(INPUT_STRING.getBytes("UTF-8")));
|
||||
StreamSource source = new StreamSource(new ByteArrayInputStream(INPUT_STRING.getBytes(StandardCharsets.UTF_8)));
|
||||
Object flights = unmarshaller.unmarshal(source);
|
||||
testFlight(flights);
|
||||
}
|
||||
@@ -94,5 +92,15 @@ public class XStreamUnmarshallerTests {
|
||||
Object flights = unmarshaller.unmarshal(source);
|
||||
testFlight(flights);
|
||||
}
|
||||
|
||||
|
||||
private void testFlight(Object o) {
|
||||
boolean condition = o instanceof Flight;
|
||||
assertThat(condition).as("Unmarshalled object is not Flights").isTrue();
|
||||
Flight flight = (Flight) o;
|
||||
assertThat(flight).as("Flight is null").isNotNull();
|
||||
assertThat(flight.getFlightNumber()).as("Number is invalid").isEqualTo(42L);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user