diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 00000000..b901097f --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author 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 + * + * http://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. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index 5fd4d502..2cc7d4a5 100644 Binary files a/.mvn/wrapper/maven-wrapper.jar and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 56bb0164..642d572c 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1,2 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip \ No newline at end of file +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/docs/pom.xml b/docs/pom.xml index 984c27d9..d12a192d 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -8,7 +8,7 @@ org.springframework.cloud spring-cloud-commons-parent - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT jar Spring Cloud Commons Docs diff --git a/docs/src/main/asciidoc/_configprops.adoc b/docs/src/main/asciidoc/_configprops.adoc index d747168a..462b70fe 100644 --- a/docs/src/main/asciidoc/_configprops.adoc +++ b/docs/src/main/asciidoc/_configprops.adoc @@ -1,7 +1,7 @@ |=== |Name | Default | Description -|spring.cloud.compatibility-verifier.compatible-boot-versions | | Default accepted versions for the Spring Boot dependency. You can set {@code x} for the patch version if you don't want to specify a concrete value. Example: {@code 3.4.x} +|spring.cloud.compatibility-verifier.compatible-boot-versions | `2.6.x` | Default accepted versions for the Spring Boot dependency. You can set {@code x} for the patch version if you don't want to specify a concrete value. Example: {@code 3.4.x} |spring.cloud.compatibility-verifier.enabled | `false` | Enables creation of Spring Cloud compatibility verification. |spring.cloud.config.allow-override | `true` | Flag to indicate that {@link #isOverrideSystemProperties() systemPropertiesOverride} can be used. Set to false to prevent users from changing the default accidentally. Default true. |spring.cloud.config.override-none | `false` | Flag to indicate that when {@link #setAllowOverride(boolean) allowOverride} is true, external properties should take lowest priority and should not override any existing property sources (including local config files). Default false. diff --git a/docs/src/main/asciidoc/index.adoc b/docs/src/main/asciidoc/index.adoc deleted file mode 120000 index 583ddeb0..00000000 --- a/docs/src/main/asciidoc/index.adoc +++ /dev/null @@ -1 +0,0 @@ -spring-cloud-commons.adoc \ No newline at end of file diff --git a/docs/src/main/asciidoc/index.adoc b/docs/src/main/asciidoc/index.adoc new file mode 100644 index 00000000..0e73a468 --- /dev/null +++ b/docs/src/main/asciidoc/index.adoc @@ -0,0 +1 @@ +include::spring-cloud-commons.adoc[] diff --git a/mvnw b/mvnw index a08b219e..41c0f0c2 100755 --- a/mvnw +++ b/mvnw @@ -8,7 +8,7 @@ # "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 +# http://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 @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script +# Maven Start Up Batch script # # Required ENV vars: # ------------------ @@ -54,38 +54,16 @@ case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true - # - # Look for the Apple JDKs first to preserve the existing behaviour, and then look - # for the new JDKs provided by Oracle. - # - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then - # - # Oracle JDKs - # - export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then - # - # Apple JDKs - # - export JAVA_HOME=`/usr/libexec/java_home` - fi - ;; + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; esac if [ -z "$JAVA_HOME" ] ; then @@ -130,13 +108,12 @@ if $cygwin ; then CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi -# For Migwn, ensure paths are in UNIX format before anything is touched +# For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then [ -n "$M2_HOME" ] && M2_HOME="`(cd "$M2_HOME"; pwd)`" [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? fi if [ -z "$JAVA_HOME" ]; then @@ -184,27 +161,28 @@ fi CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` -fi - # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { - local basedir=$(pwd) - local wdir=$(pwd) + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" while [ "$wdir" != '/' ] ; do if [ -d "$wdir"/.mvn ] ; then basedir=$wdir break fi - wdir=$(cd "$wdir/.."; pwd) + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround done echo "${basedir}" } @@ -216,9 +194,108 @@ concat_lines() { fi } -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" @@ -226,28 +303,8 @@ export MAVEN_CMD_LINE_ARGS WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -echo "Running version check" -VERSION=$( sed '\!//' -e 's!.*$!!' ) -echo "The found version is [${VERSION}]" - -if echo $VERSION | egrep -q 'M|RC'; then - echo Activating \"milestone\" profile for version=\"$VERSION\" - echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone" -else - echo Deactivating \"milestone\" profile for version=\"$VERSION\" - echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//') -fi - -if echo $VERSION | egrep -q 'RELEASE'; then - echo Activating \"central\" profile for version=\"$VERSION\" - echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pcentral" -else - echo Deactivating \"central\" profile for version=\"$VERSION\" - echo $MAVEN_ARGS | grep -q central && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pcentral//') -fi - exec "$JAVACMD" \ $MAVEN_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@" + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd index 7ecd01d8..86115719 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -7,7 +7,7 @@ @REM "License"); you may not use this file except in compliance @REM with the License. You may obtain a copy of the License at @REM -@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM http://www.apache.org/licenses/LICENSE-2.0 @REM @REM Unless required by applicable law or agreed to in writing, @REM software distributed under the License is distributed on an @@ -18,7 +18,7 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script +@REM Maven Start Up Batch script @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @@ -26,7 +26,7 @@ @REM Optional ENV vars @REM M2_HOME - location of maven2's installed home dir @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven @REM e.g. to debug Maven itself, use @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -35,7 +35,9 @@ @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% @REM set %HOME% to equivalent of $HOME @@ -80,8 +82,6 @@ goto error :init -set MAVEN_CMD_LINE_ARGS=%* - @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". @REM Fallback to current working directory if not found. @@ -117,11 +117,48 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s :endReadAdditionalConfig SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end diff --git a/pom.xml b/pom.xml index 9c63e76a..c89bdb63 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.springframework.cloud spring-cloud-commons-parent - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT pom Spring Cloud Commons Parent Spring Cloud Commons Parent @@ -13,7 +13,7 @@ org.springframework.cloud spring-cloud-build - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT @@ -155,6 +155,16 @@ org.springframework.security.oauth.boot spring-security-oauth2-autoconfigure ${spring-security-oauth2-autoconfigure.version} + + + org.springframework.boot + spring-boot + + + org.springframework.boot + spring-boot-autoconfigure + + diff --git a/spring-cloud-commons-dependencies/pom.xml b/spring-cloud-commons-dependencies/pom.xml index b62e89c1..49fb99bc 100644 --- a/spring-cloud-commons-dependencies/pom.xml +++ b/spring-cloud-commons-dependencies/pom.xml @@ -6,11 +6,11 @@ spring-cloud-dependencies-parent org.springframework.cloud - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT spring-cloud-commons-dependencies - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT pom spring-cloud-commons-dependencies Spring Cloud Commons Dependencies diff --git a/spring-cloud-commons/pom.xml b/spring-cloud-commons/pom.xml index 3920a9f3..846c65b2 100644 --- a/spring-cloud-commons/pom.xml +++ b/spring-cloud-commons/pom.xml @@ -7,7 +7,7 @@ org.springframework.cloud spring-cloud-commons-parent - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT .. spring-cloud-commons diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/CompatibilityVerifierProperties.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/CompatibilityVerifierProperties.java index 21d0fb75..b12c49c1 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/CompatibilityVerifierProperties.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/CompatibilityVerifierProperties.java @@ -37,7 +37,7 @@ public class CompatibilityVerifierProperties { * the patch version if you don't want to specify a concrete value. Example: * {@code 3.4.x} */ - private List compatibleBootVersions = Arrays.asList("2.4.x", "2.5.x"); + private List compatibleBootVersions = Arrays.asList("2.6.x"); public boolean isEnabled() { return this.enabled; diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java index c4a78f65..fc2fddbd 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java @@ -35,8 +35,7 @@ class SpringBootVersionVerifier implements CompatibilityVerifier { final Map ACCEPTED_VERSIONS = new HashMap() { { - this.put("2.4", is2_4()); - this.put("2.5", is2_5()); + this.put("2.6", is2_6()); } }; @@ -71,42 +70,19 @@ class SpringBootVersionVerifier implements CompatibilityVerifier { return SpringBootVersion.getVersion(); } - CompatibilityPredicate is2_4() { + CompatibilityPredicate is2_6() { return new CompatibilityPredicate() { @Override public String toString() { - return "Predicate for Boot 2.4"; + return "Predicate for Boot 2.6"; } @Override public boolean isCompatible() { try { - // since 2.4 - Class.forName("org.springframework.boot.Bootstrapper"); - return true; - } - catch (ClassNotFoundException e) { - return false; - } - - } - }; - } - - CompatibilityPredicate is2_5() { - return new CompatibilityPredicate() { - - @Override - public String toString() { - return "Predicate for Boot 2.5"; - } - - @Override - public boolean isCompatible() { - try { - // since 2.4 - Class.forName("org.springframework.boot.context.properties.bind.Bindable.BindRestriction"); + // since 2.6 + Class.forName("org.springframework.boot.autoconfigure.data.redis.ClientResourcesBuilderCustomizer"); return true; } catch (ClassNotFoundException e) { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/CommonsClientAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/CommonsClientAutoConfigurationTests.java index 12b97677..96d04f36 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/CommonsClientAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/CommonsClientAutoConfigurationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigurations; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessorTests.java index d2155fb0..a319673f 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessorTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.SpringApplication; import org.springframework.core.env.ConfigurableEnvironment; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfigurationTests.java index 0e424e05..4922b980 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfigurationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.FilteredClassLoader; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/actuator/FeaturesEndpointTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/actuator/FeaturesEndpointTests.java index 0998a648..22b399ca 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/actuator/FeaturesEndpointTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/actuator/FeaturesEndpointTests.java @@ -19,9 +19,9 @@ package org.springframework.cloud.client.actuator; import java.util.ArrayList; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; @@ -39,14 +39,14 @@ public class FeaturesEndpointTests { private AnnotationConfigApplicationContext context; - @Before + @BeforeEach public void setup() { this.context = new AnnotationConfigApplicationContext(); this.context.register(JacksonAutoConfiguration.class, FeaturesConfig.class, Config.class); this.context.refresh(); } - @After + @AfterEach public void close() { if (this.context != null) { this.context.close(); diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/circuitbreaker/CustomizerTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/circuitbreaker/CustomizerTests.java index 80b399b6..5462abbe 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/circuitbreaker/CustomizerTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/circuitbreaker/CustomizerTests.java @@ -19,7 +19,7 @@ package org.springframework.cloud.client.circuitbreaker; import java.util.concurrent.atomic.AtomicInteger; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CustomizerTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/AutoRegisterPropertyFalseTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/AutoRegisterPropertyFalseTests.java index cf3bf270..a2ad236e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/AutoRegisterPropertyFalseTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/AutoRegisterPropertyFalseTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.client.discovery; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -27,14 +26,12 @@ import org.springframework.cloud.client.serviceregistry.AutoServiceRegistration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(properties = { "spring.cloud.service-registry.auto-registration.enabled: false" }) public class AutoRegisterPropertyFalseTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientAutoRegisterFalseTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientAutoRegisterFalseTests.java index 34845c69..9aeca7f2 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientAutoRegisterFalseTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientAutoRegisterFalseTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.client.discovery; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -27,14 +26,12 @@ import org.springframework.cloud.client.serviceregistry.AutoServiceRegistration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest public class EnableDiscoveryClientAutoRegisterFalseTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientMissingImplTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientMissingImplTests.java index 28badd15..3176cb8b 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientMissingImplTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientMissingImplTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client.discovery; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java index 328d1528..f2000500 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java @@ -18,8 +18,7 @@ package org.springframework.cloud.client.discovery.composite; import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -29,7 +28,6 @@ import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; @@ -39,7 +37,6 @@ import static org.assertj.core.api.BDDAssertions.then; * @author Biju Kunjummen */ -@RunWith(SpringRunner.class) @SpringBootTest public class CompositeDiscoveryClientAutoConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientOrderTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientOrderTest.java index 084de0ed..2905b3ee 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientOrderTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientOrderTest.java @@ -18,14 +18,12 @@ package org.springframework.cloud.client.discovery.composite; import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; import static org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClientTestsConfig.CUSTOM_DISCOVERY_CLIENT; @@ -39,7 +37,6 @@ import static org.springframework.cloud.client.discovery.composite.CompositeDisc * * @author Olga Maciaszek-Sharma */ -@RunWith(SpringRunner.class) @SpringBootTest(properties = "spring.cloud.discovery.client.simple.order:2", classes = { CompositeDiscoveryClientTestsConfig.class }) public class CompositeDiscoveryClientOrderTest { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java index fe4f774f..530fb869 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java @@ -18,14 +18,12 @@ package org.springframework.cloud.client.discovery.composite; import java.net.URI; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; import static org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClientTestsConfig.CUSTOM_SERVICE_ID; @@ -36,7 +34,6 @@ import static org.springframework.cloud.client.discovery.composite.CompositeDisc * @author Biju Kunjummen */ -@RunWith(SpringRunner.class) @SpringBootTest( properties = { "spring.application.name=service0", "spring.cloud.discovery.client.simple.instances.service1[0].uri=http://s11:8080", diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/event/HeartbeatMonitorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/event/HeartbeatMonitorTests.java index 17476bea..7536a6ba 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/event/HeartbeatMonitorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/event/HeartbeatMonitorTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client.discovery.event; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.BDDAssertions.then; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryClientHealthIndicatorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryClientHealthIndicatorTests.java index b1aa4bc4..5836107e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryClientHealthIndicatorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryClientHealthIndicatorTests.java @@ -18,8 +18,7 @@ package org.springframework.cloud.client.discovery.health; import java.util.Arrays; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.health.CompositeHealthContributor; @@ -34,7 +33,6 @@ import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; import static org.mockito.BDDMockito.given; @@ -43,7 +41,6 @@ import static org.mockito.Mockito.mock; /** * @author Spencer Gibb */ -@RunWith(SpringRunner.class) // @checkstyle:off @SpringBootTest(classes = { DiscoveryClientHealthIndicatorTests.Config.class, CommonsClientAutoConfiguration.class }, properties = "spring.cloud.discovery.client.health-indicator.include-description:true") diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthContributorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthContributorTests.java index e0a96841..325c1b85 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthContributorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthContributorTests.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthContributor; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/DiscoveryClientAutoConfigurationDefaultTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/DiscoveryClientAutoConfigurationDefaultTests.java index 15fed0af..16bc9a06 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/DiscoveryClientAutoConfigurationDefaultTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/DiscoveryClientAutoConfigurationDefaultTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.client.discovery.simple; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -25,7 +24,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; @@ -34,7 +32,6 @@ import static org.assertj.core.api.BDDAssertions.then; * * @author Biju Kunjummen */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = DiscoveryClientAutoConfigurationDefaultTests.Config.class) public class DiscoveryClientAutoConfigurationDefaultTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ReactiveSimpleDiscoveryPropertiesAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ReactiveSimpleDiscoveryPropertiesAutoConfigurationTests.java index 7b90a4e5..4c0c0205 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ReactiveSimpleDiscoveryPropertiesAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ReactiveSimpleDiscoveryPropertiesAutoConfigurationTests.java @@ -16,22 +16,19 @@ package org.springframework.cloud.client.discovery.simple; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = ReactiveSimpleDiscoveryPropertiesAutoConfigurationTests.Config.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = "spring.main.web-application-type=reactive") diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ServletSimpleDiscoveryPropertiesAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ServletSimpleDiscoveryPropertiesAutoConfigurationTests.java index 53feda84..68cd500e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ServletSimpleDiscoveryPropertiesAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ServletSimpleDiscoveryPropertiesAutoConfigurationTests.java @@ -16,22 +16,19 @@ package org.springframework.cloud.client.discovery.simple; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = ServletSimpleDiscoveryPropertiesAutoConfigurationTests.Config.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ServletSimpleDiscoveryPropertiesAutoConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java index 3d1a4188..8530fbdf 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java @@ -18,15 +18,13 @@ package org.springframework.cloud.client.discovery.simple; import java.net.URI; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.ServiceInstance; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; @@ -36,7 +34,6 @@ import static org.assertj.core.api.BDDAssertions.then; * @author Biju Kunjummen */ -@RunWith(SpringRunner.class) @SpringBootTest(properties = { "spring.application.name=service0", "spring.cloud.discovery.client.simple.instances.service1[0].uri=http://s11:8080", "spring.cloud.discovery.client.simple.instances.service1[1].uri=https://s12:8443", diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientTests.java index 00f84cc9..82944a11 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientTests.java @@ -22,8 +22,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.ServiceInstance; @@ -38,7 +38,7 @@ public class SimpleDiscoveryClientTests { private SimpleDiscoveryClient simpleDiscoveryClient; - @Before + @BeforeEach public void setUp() { SimpleDiscoveryProperties simpleDiscoveryProperties = new SimpleDiscoveryProperties(); diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/CloudHypermediaAutoConfigurationIntegrationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/CloudHypermediaAutoConfigurationIntegrationTests.java index 0de4896c..10b38141 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/CloudHypermediaAutoConfigurationIntegrationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/CloudHypermediaAutoConfigurationIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client.hypermedia; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/AsyncLoadBalancerAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/AsyncLoadBalancerAutoConfigurationTests.java index 252a4b61..af07292d 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/AsyncLoadBalancerAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/AsyncLoadBalancerAutoConfigurationTests.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.Map; import java.util.Random; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.WebApplicationType; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/ClientHttpResponseStatusCodeExceptionTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/ClientHttpResponseStatusCodeExceptionTest.java index 1bccb927..19607e80 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/ClientHttpResponseStatusCodeExceptionTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/ClientHttpResponseStatusCodeExceptionTest.java @@ -20,9 +20,9 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpHeaders; import org.springframework.http.client.AbstractClientHttpResponse; @@ -34,7 +34,7 @@ import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ClientHttpResponseStatusCodeExceptionTest { @Test diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/InterceptorRetryPolicyTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/InterceptorRetryPolicyTest.java index 3301b525..e30ec30b 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/InterceptorRetryPolicyTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/InterceptorRetryPolicyTest.java @@ -16,11 +16,11 @@ package org.springframework.cloud.client.loadbalancer; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpRequest; import org.springframework.retry.RetryContext; @@ -36,7 +36,7 @@ import static org.mockito.Mockito.when; * @author Ryan Baxter * @author Olga Maciaszek-Sharma */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class InterceptorRetryPolicyTest { private HttpRequest request; @@ -47,7 +47,7 @@ public class InterceptorRetryPolicyTest { private String serviceName; - @Before + @BeforeEach public void setup() { request = mock(HttpRequest.class); policy = mock(LoadBalancedRetryPolicy.class); @@ -55,7 +55,7 @@ public class InterceptorRetryPolicyTest { serviceName = "foo"; } - @After + @AfterEach public void teardown() { request = null; policy = null; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRetryContextTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRetryContextTest.java index e99ab74f..d5c277cf 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRetryContextTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRetryContextTest.java @@ -16,11 +16,11 @@ package org.springframework.cloud.client.loadbalancer; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.cloud.client.ServiceInstance; import org.springframework.http.HttpRequest; @@ -32,20 +32,20 @@ import static org.mockito.Mockito.mock; /** * @author Ryan Baxter */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class LoadBalancedRetryContextTest { private RetryContext context; private HttpRequest request; - @Before + @BeforeEach public void setUp() throws Exception { this.context = mock(RetryContext.class); this.request = mock(HttpRequest.class); } - @After + @AfterEach public void tearDown() throws Exception { this.context = null; this.request = null; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryConfigurationTests.java index f072c25f..08e5edc3 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryConfigurationTests.java @@ -16,12 +16,12 @@ package org.springframework.cloud.client.loadbalancer; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.boot.WebApplicationType; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -42,7 +42,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class LoadBalancerRequestFactoryConfigurationTests { @Mock @@ -68,7 +68,7 @@ public class LoadBalancerRequestFactoryConfigurationTests { private LoadBalancerRequest lbRequest; - @Before + @BeforeEach public void setup() { this.httpRequestCaptor = ArgumentCaptor.forClass(HttpRequest.class); } diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryTests.java index 28426eb0..8d450a3e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryTests.java @@ -20,12 +20,12 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.cloud.client.ServiceInstance; import org.springframework.http.HttpRequest; @@ -38,7 +38,7 @@ import static org.mockito.Mockito.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class LoadBalancerRequestFactoryTests { @Mock @@ -69,7 +69,7 @@ public class LoadBalancerRequestFactoryTests { private ArgumentCaptor httpRequestCaptor; - @Before + @BeforeEach public void setup() { this.httpRequestCaptor = ArgumentCaptor.forClass(HttpRequest.class); } diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerAutoConfigurationTests.java index 501bb75e..2f1336e6 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerAutoConfigurationTests.java @@ -18,7 +18,7 @@ package org.springframework.cloud.client.loadbalancer; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.http.client.ClientHttpRequestInterceptor; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerInterceptorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerInterceptorTests.java index 3a8126c9..94ad3f8e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerInterceptorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerInterceptorTests.java @@ -27,12 +27,13 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatchers; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.ServiceInstance; @@ -68,7 +69,7 @@ import static org.mockito.Mockito.when; * @author Olga Maciaszek-Sharma */ @SuppressWarnings({ "unchecked", "rawtypes" }) -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class RetryLoadBalancerInterceptorTests { private LoadBalancerClient client; @@ -82,7 +83,7 @@ public class RetryLoadBalancerInterceptorTests { private ReactiveLoadBalancer.Factory lbFactory; - @Before + @BeforeEach public void setUp() { client = mock(LoadBalancerClient.class); lbRequestFactory = mock(LoadBalancerRequestFactory.class); @@ -90,12 +91,12 @@ public class RetryLoadBalancerInterceptorTests { lbFactory = mock(ReactiveLoadBalancer.Factory.class); } - @After + @AfterEach public void tearDown() { client = null; } - @Test(expected = IOException.class) + @Test public void interceptDisableRetry() throws Throwable { HttpRequest request = mock(HttpRequest.class); when(request.getURI()).thenReturn(new URI("http://foo")); @@ -111,11 +112,13 @@ public class RetryLoadBalancerInterceptorTests { when(lbRequestFactory.createRequest(any(), any(), any())).thenReturn(mock(LoadBalancerRequest.class)); - interceptor.intercept(request, body, execution); + Assertions.assertThrows(IOException.class, () -> { + interceptor.intercept(request, body, execution); + }); verify(lbRequestFactory).createRequest(request, body, execution); } - @Test(expected = IllegalStateException.class) + @Test public void interceptInvalidHost() throws Throwable { HttpRequest request = mock(HttpRequest.class); when(request.getURI()).thenReturn(new URI("http://foo_underscore")); @@ -124,7 +127,9 @@ public class RetryLoadBalancerInterceptorTests { lbRequestFactory, loadBalancedRetryFactory, lbFactory); byte[] body = new byte[] {}; ClientHttpRequestExecution execution = mock(ClientHttpRequestExecution.class); - interceptor.intercept(request, body, execution); + Assertions.assertThrows(IllegalStateException.class, () -> { + interceptor.intercept(request, body, execution); + }); } @Test @@ -258,7 +263,7 @@ public class RetryLoadBalancerInterceptorTests { then(backOffPolicy.getBackoffAttempts()).isEqualTo(1); } - @Test(expected = IOException.class) + @Test public void interceptFailedRetry() throws Exception { HttpRequest request = mock(HttpRequest.class); when(request.getURI()).thenReturn(new URI("http://foo")); @@ -275,7 +280,9 @@ public class RetryLoadBalancerInterceptorTests { lbRequestFactory, new MyLoadBalancedRetryFactory(policy), lbFactory); byte[] body = new byte[] {}; ClientHttpRequestExecution execution = mock(ClientHttpRequestExecution.class); - interceptor.intercept(request, body, execution); + Assertions.assertThrows(IOException.class, () -> { + interceptor.intercept(request, body, execution); + }); verify(lbRequestFactory).createRequest(request, body, execution); } @@ -337,7 +344,7 @@ public class RetryLoadBalancerInterceptorTests { then(backOffPolicy.getBackoffAttempts()).isEqualTo(1); } - @Test(expected = TerminatedRetryException.class) + @Test public void retryListenerTestNoRetry() throws Throwable { HttpRequest request = mock(HttpRequest.class); when(request.getURI()).thenReturn(new URI("http://noRetry")); @@ -355,7 +362,9 @@ public class RetryLoadBalancerInterceptorTests { new MyLoadBalancedRetryFactory(policy, backOffPolicy, new RetryListener[] { myRetryListener }), lbFactory); ClientHttpRequestExecution execution = mock(ClientHttpRequestExecution.class); - interceptor.intercept(request, new byte[] {}, execution); + Assertions.assertThrows(TerminatedRetryException.class, () -> { + interceptor.intercept(request, new byte[] {}, execution); + }); } @Test diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/reactive/ReactorLoadBalancerExchangeFilterFunctionTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/reactive/ReactorLoadBalancerExchangeFilterFunctionTests.java index 5ddcf7a8..963403d6 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/reactive/ReactorLoadBalancerExchangeFilterFunctionTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/reactive/ReactorLoadBalancerExchangeFilterFunctionTests.java @@ -47,7 +47,7 @@ import org.springframework.cloud.client.loadbalancer.Response; import org.springframework.cloud.client.loadbalancer.ResponseData; import org.springframework.context.annotation.Bean; import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; @@ -160,12 +160,12 @@ class ReactorLoadBalancerExchangeFilterFunctionTests { @RestController static class Config { - @RequestMapping("/hello") + @GetMapping("/hello") public String hello() { return "Hello World"; } - @RequestMapping("/callback") + @GetMapping("/callback") String callbackTestResult() { return "callbackTestResult"; } diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationMgmtDisabledTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationMgmtDisabledTests.java index 830372a2..734ac98e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationMgmtDisabledTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationMgmtDisabledTests.java @@ -21,15 +21,13 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import org.assertj.core.api.BDDAssertions; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @@ -37,7 +35,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen * @author Spencer Gibb * @author Tim Ysewyn */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = AbstractAutoServiceRegistrationMgmtDisabledTests.Config.class, properties = { "management.port=0", "spring.cloud.service-registry.auto-registration.register-management=false" }, diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationTests.java index f5f820f4..87f3b1bd 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationTests.java @@ -20,8 +20,7 @@ import java.net.URI; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort; @@ -33,7 +32,6 @@ import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @@ -42,7 +40,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen * @author Spencer Gibb * @author Tim Ysewyn */ -@RunWith(SpringRunner.class) // @checkstyle:off @SpringBootTest(classes = AbstractAutoServiceRegistrationTests.Config.class, properties = "management.port=0", webEnvironment = RANDOM_PORT) diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointNoRegistrationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointNoRegistrationTests.java index 11e889af..7e91a616 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointNoRegistrationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointNoRegistrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.client.serviceregistry.endpoint; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; @@ -31,7 +30,6 @@ import org.springframework.cloud.client.serviceregistry.endpoint.ServiceRegistry import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -41,7 +39,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. /** * @author Spencer Gibb */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = ServiceRegistryEndpointNoRegistrationTests.TestConfiguration.class) @AutoConfigureMockMvc public class ServiceRegistryEndpointNoRegistrationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointTests.java index f1cc7adb..8605f311 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointTests.java @@ -22,8 +22,7 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringBootConfiguration; @@ -35,7 +34,6 @@ import org.springframework.cloud.client.serviceregistry.Registration; import org.springframework.cloud.client.serviceregistry.ServiceRegistry; import org.springframework.context.annotation.Bean; import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import static org.assertj.core.api.BDDAssertions.then; @@ -49,7 +47,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * @author Spencer Gibb * @author Tim Ysewyn */ -@RunWith(SpringRunner.class) // @checkstyle:off @SpringBootTest(classes = ServiceRegistryEndpointTests.TestConfiguration.class, properties = "management.endpoints.web.exposure.include=*") diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientBuilderConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientBuilderConfigurationTests.java index b7aed99d..8373856d 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientBuilderConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientBuilderConfigurationTests.java @@ -17,8 +17,7 @@ package org.springframework.cloud.commons.httpclient; import org.apache.http.impl.client.HttpClientBuilder; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; @@ -27,14 +26,12 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = CustomHttpClientBuilderApplication.class) public class CustomHttpClientBuilderConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientConfigurationTests.java index 693b9216..1a62d562 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientConfigurationTests.java @@ -23,8 +23,7 @@ import okhttp3.OkHttpClient; import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.impl.client.HttpClientBuilder; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; @@ -32,14 +31,12 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = CustomApplication.class, properties = { "spring.cloud.httpclient.ok.enabled: true" }) public class CustomHttpClientConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomOkHttpClientBuilderConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomOkHttpClientBuilderConfigurationTests.java index 2b0d2b1f..6bd2eeef 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomOkHttpClientBuilderConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomOkHttpClientBuilderConfigurationTests.java @@ -20,8 +20,7 @@ import java.lang.reflect.Field; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; @@ -29,7 +28,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.BDDAssertions.then; @@ -37,7 +35,6 @@ import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = CustomOkHttpClientBuilderApplication.class) public class CustomOkHttpClientBuilderConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientFactoryTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientFactoryTests.java index 2c7a4907..2147ca0f 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientFactoryTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientFactoryTests.java @@ -25,7 +25,7 @@ import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.assertj.core.api.BDDAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ReflectionUtils; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultHttpClientConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultHttpClientConfigurationTests.java index c5517cb4..0327779f 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultHttpClientConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultHttpClientConfigurationTests.java @@ -16,22 +16,19 @@ package org.springframework.cloud.commons.httpclient; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = MyApplication.class, properties = { "spring.cloud.httpclient.ok.enabled: true" }) public class DefaultHttpClientConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientConnectionPoolFactoryTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientConnectionPoolFactoryTest.java index cbe75687..99f2e4f0 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientConnectionPoolFactoryTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientConnectionPoolFactoryTest.java @@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit; import okhttp3.ConnectionPool; import okhttp3.internal.connection.RealConnectionPool; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ReflectionUtils; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientFactoryTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientFactoryTest.java index 89111ce9..eb69a234 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientFactoryTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientFactoryTest.java @@ -23,7 +23,7 @@ import javax.net.ssl.HostnameVerifier; import okhttp3.ConnectionPool; import okhttp3.OkHttpClient; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ReflectionUtils; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/publisher/FluxFirstNonEmptyEmittingTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/publisher/FluxFirstNonEmptyEmittingTests.java index 13edac62..0d7ac759 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/publisher/FluxFirstNonEmptyEmittingTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/publisher/FluxFirstNonEmptyEmittingTests.java @@ -19,7 +19,7 @@ package org.springframework.cloud.commons.publisher; import java.time.Duration; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/ResourceServerTokenRelayAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/ResourceServerTokenRelayAutoConfigurationTests.java index dfe1b5af..1d8c90b0 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/ResourceServerTokenRelayAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/ResourceServerTokenRelayAutoConfigurationTests.java @@ -16,8 +16,8 @@ package org.springframework.cloud.commons.security; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso; @@ -49,7 +49,7 @@ public class ResourceServerTokenRelayAutoConfigurationTests { private ConfigurableApplicationContext context; - @After + @AfterEach public void close() { if (this.context != null) { this.context.close(); diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/tokenrelay/ResourceServerTokenRelayTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/tokenrelay/ResourceServerTokenRelayTests.java index 52913d86..f24bfc05 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/tokenrelay/ResourceServerTokenRelayTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/tokenrelay/ResourceServerTokenRelayTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.commons.security.tokenrelay; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -41,7 +40,6 @@ import org.springframework.security.oauth2.client.OAuth2RestTemplate; import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -56,7 +54,6 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat * @author Peter Szanto (spring@szantocsalad.hu) * */ -@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "security.oauth2.resource.jwt.keyValue=secret", "spring.cloud.mvc.token-relay.enabled=true", "spring.autoconfigure.exclude=" }) diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/IdUtilsTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/IdUtilsTests.java index c90022dd..29adf3f5 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/IdUtilsTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/IdUtilsTests.java @@ -16,9 +16,9 @@ package org.springframework.cloud.commons.util; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.env.MockEnvironment; @@ -33,12 +33,12 @@ public class IdUtilsTests { private MockEnvironment env; - @Before + @BeforeEach public void setup() { this.env = new MockEnvironment(); } - @After + @AfterEach public void destroy() { this.env = null; } diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/InetUtilsTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/InetUtilsTests.java index dbae581f..36eb3aee 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/InetUtilsTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/InetUtilsTests.java @@ -20,7 +20,7 @@ import java.net.InetAddress; import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cloud.commons.util.InetUtils.HostInfo; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/SpringFactoryImportSelectorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/SpringFactoryImportSelectorTests.java index 185590e2..2f2a156e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/SpringFactoryImportSelectorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/SpringFactoryImportSelectorTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.commons.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.BDDAssertions.then; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierAutoConfigurationTests.java index 19cfb13c..70350322 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierAutoConfigurationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.configuration; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringBootVersion; @@ -25,7 +24,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -35,7 +33,6 @@ import static org.springframework.cloud.configuration.SpringBootVersionVerifier. /** * @author Marcin Grzejszczak */ -@RunWith(SpringRunner.class) @SpringBootTest public class CompatibilityVerifierAutoConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierDisabledAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierDisabledAutoConfigurationTests.java index 37ac9592..4b8c346c 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierDisabledAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierDisabledAutoConfigurationTests.java @@ -16,21 +16,18 @@ package org.springframework.cloud.configuration; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Marcin Grzejszczak */ -@RunWith(SpringRunner.class) @SpringBootTest(properties = "spring.cloud.compatibility-verifier.enabled=false") public class CompatibilityVerifierDisabledAutoConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierFailureAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierFailureAutoConfigurationTests.java index 8aa39a26..95c220c4 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierFailureAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierFailureAutoConfigurationTests.java @@ -17,13 +17,11 @@ package org.springframework.cloud.configuration; import org.assertj.core.api.BDDAssertions; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.system.OutputCaptureRule; import org.springframework.context.annotation.Configuration; import org.springframework.core.NestedExceptionUtils; @@ -34,9 +32,6 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class CompatibilityVerifierFailureAutoConfigurationTests { - @Rule - public OutputCaptureRule outputCapture = new OutputCaptureRule(); - @Test public void contextFailsToLoad() { try { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierTests.java index 4e13d987..52171cf4 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierTests.java @@ -20,29 +20,28 @@ import java.util.ArrayList; import java.util.List; import org.assertj.core.api.BDDAssertions; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.boot.test.system.OutputCaptureRule; +import org.springframework.boot.test.system.CapturedOutput; +import org.springframework.boot.test.system.OutputCaptureExtension; import static org.assertj.core.api.BDDAssertions.then; /** * @author Marcin Grzejszczak */ +@ExtendWith(OutputCaptureExtension.class) public class CompatibilityVerifierTests { - @Rule - public OutputCaptureRule outputCapture = new OutputCaptureRule(); - @Test - public void should_not_print_the_report_when_no_errors_were_found() { + public void should_not_print_the_report_when_no_errors_were_found(CapturedOutput output) { CompositeCompatibilityVerifier verifier = new CompositeCompatibilityVerifier( new ArrayList()); verifier.verifyDependencies(); - then(this.outputCapture.toString()).doesNotContain("SPRING CLOUD VERIFICATION FAILED"); + then(output).doesNotContain("SPRING CLOUD VERIFICATION FAILED"); } @Test diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SSHContextFactoryTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SSHContextFactoryTests.java index f831f168..12ef299d 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SSHContextFactoryTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SSHContextFactoryTests.java @@ -27,9 +27,9 @@ import java.security.cert.Certificate; import javax.net.ssl.SSLContext; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; @@ -52,7 +52,7 @@ public class SSHContextFactoryTests { private TlsProperties properties; - @BeforeClass + @BeforeAll public static void createKeyStoreAndTrustStore() throws Exception { KeyTool tool = new KeyTool(); @@ -82,7 +82,7 @@ public class SSHContextFactoryTests { return result; } - @Before + @BeforeEach public void createProperties() { properties = new TlsProperties(); diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java index c8f489a4..b6613aca 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.BDDAssertions.then; @@ -176,14 +176,14 @@ public class SpringBootDependencyTests { @Test public void should_match_against_current_manifest() { try { - verifyCurrentVersionFromManifest("2.4"); - verifyCurrentVersionFromManifest("2.4.x"); + verifyCurrentVersionFromManifest("2.6"); + verifyCurrentVersionFromManifest("2.6.x"); } catch (AssertionError e) { - if (e.getMessage() != null && e.getMessage().contains("2.5.")) { - // we're likely running a boot 2.5 compatibility test, try 2.5 - verifyCurrentVersionFromManifest("2.5"); - verifyCurrentVersionFromManifest("2.5.x"); + if (e.getMessage() != null && e.getMessage().contains("2.7.")) { + // we're likely running a boot 2.7 compatibility test, try 2.7 + verifyCurrentVersionFromManifest("2.7"); + verifyCurrentVersionFromManifest("2.7.x"); } else { throw e; @@ -204,7 +204,7 @@ public class SpringBootDependencyTests { @Test public void should_match_against_current_predicate() { - List acceptedVersions = Collections.singletonList("2.4"); + List acceptedVersions = Collections.singletonList("2.6"); SpringBootVersionVerifier versionVerifier = new SpringBootVersionVerifier(acceptedVersions) { @Override String getVersionFromManifest() { @@ -212,7 +212,7 @@ public class SpringBootDependencyTests { } }; versionVerifier.ACCEPTED_VERSIONS.clear(); - versionVerifier.ACCEPTED_VERSIONS.put("2.4", versionVerifier.is2_4()); + versionVerifier.ACCEPTED_VERSIONS.put("2.6", versionVerifier.is2_6()); VerificationResult verificationResult = versionVerifier.verify(); @@ -222,7 +222,7 @@ public class SpringBootDependencyTests { @Test public void should_match_against_current_predicate_with_version_ending_with_x() { - List acceptedVersions = Collections.singletonList("2.4.x"); + List acceptedVersions = Collections.singletonList("2.6.x"); SpringBootVersionVerifier versionVerifier = new SpringBootVersionVerifier(acceptedVersions) { @Override String getVersionFromManifest() { @@ -230,7 +230,7 @@ public class SpringBootDependencyTests { } }; versionVerifier.ACCEPTED_VERSIONS.clear(); - versionVerifier.ACCEPTED_VERSIONS.put("2.4", versionVerifier.is2_4()); + versionVerifier.ACCEPTED_VERSIONS.put("2.6", versionVerifier.is2_6()); VerificationResult verificationResult = versionVerifier.verify(); diff --git a/spring-cloud-context-integration-tests/pom.xml b/spring-cloud-context-integration-tests/pom.xml index d0eedb67..3fc33f8d 100644 --- a/spring-cloud-context-integration-tests/pom.xml +++ b/spring-cloud-context-integration-tests/pom.xml @@ -7,7 +7,7 @@ org.springframework.cloud spring-cloud-commons-parent - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT .. spring-cloud-context-integration-tests @@ -60,11 +60,6 @@ spring-boot-configuration-processor true - - org.junit.vintage - junit-vintage-engine - test - diff --git a/spring-cloud-context-integration-tests/src/test/java/org/springframework/cloud/context/integration/JdbcConfigurationTests.java b/spring-cloud-context-integration-tests/src/test/java/org/springframework/cloud/context/integration/JdbcConfigurationTests.java index ada3a53a..f33294f1 100644 --- a/spring-cloud-context-integration-tests/src/test/java/org/springframework/cloud/context/integration/JdbcConfigurationTests.java +++ b/spring-cloud-context-integration-tests/src/test/java/org/springframework/cloud/context/integration/JdbcConfigurationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.context.integration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.WebApplicationType; diff --git a/spring-cloud-context-integration-tests/src/test/java/org/springframework/cloud/context/integration/RefreshScopeIntegrationTests.java b/spring-cloud-context-integration-tests/src/test/java/org/springframework/cloud/context/integration/RefreshScopeIntegrationTests.java index 098db40a..be8bb6c0 100644 --- a/spring-cloud-context-integration-tests/src/test/java/org/springframework/cloud/context/integration/RefreshScopeIntegrationTests.java +++ b/spring-cloud-context-integration-tests/src/test/java/org/springframework/cloud/context/integration/RefreshScopeIntegrationTests.java @@ -18,10 +18,10 @@ package org.springframework.cloud.context.integration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.scope.ScopedProxyUtils; @@ -41,11 +41,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) @SuppressWarnings("Duplicates") public class RefreshScopeIntegrationTests { @@ -59,13 +57,13 @@ public class RefreshScopeIntegrationTests { @Autowired private org.springframework.cloud.context.scope.refresh.RefreshScope scope; - @Before + @BeforeEach public void init() { then(ExampleService.getInitCount()).isEqualTo(1); ExampleService.reset(); } - @After + @AfterEach public void close() { ExampleService.reset(); } @@ -121,10 +119,12 @@ public class RefreshScopeIntegrationTests { } // see gh-349 - @Test(expected = ServiceException.class) + @Test @DirtiesContext public void testCheckedException() throws Exception { - this.service.throwsException(); + Assertions.assertThrows(ServiceException.class, () -> { + this.service.throwsException(); + }); } public interface Service { diff --git a/spring-cloud-context-webflux-integration-tests/pom.xml b/spring-cloud-context-webflux-integration-tests/pom.xml index 56981005..54909e04 100644 --- a/spring-cloud-context-webflux-integration-tests/pom.xml +++ b/spring-cloud-context-webflux-integration-tests/pom.xml @@ -7,7 +7,7 @@ org.springframework.cloud spring-cloud-commons-parent - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT .. spring-cloud-context-webflux-integration-tests @@ -42,11 +42,6 @@ spring-boot-configuration-processor true - - org.junit.vintage - junit-vintage-engine - test - diff --git a/spring-cloud-context-webflux-integration-tests/src/test/java/org/springframework/cloud/context/integration/webflux/RefreshEndpointIntegrationTests.java b/spring-cloud-context-webflux-integration-tests/src/test/java/org/springframework/cloud/context/integration/webflux/RefreshEndpointIntegrationTests.java index d393f693..98301b62 100644 --- a/spring-cloud-context-webflux-integration-tests/src/test/java/org/springframework/cloud/context/integration/webflux/RefreshEndpointIntegrationTests.java +++ b/spring-cloud-context-webflux-integration-tests/src/test/java/org/springframework/cloud/context/integration/webflux/RefreshEndpointIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.integration.webflux; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -27,7 +26,6 @@ import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @@ -36,7 +34,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen * @author Dave Syer * */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = RefreshEndpointIntegrationTests.ClientApp.class, properties = { "management.endpoints.web.exposure.include=*" }, webEnvironment = RANDOM_PORT) public class RefreshEndpointIntegrationTests { diff --git a/spring-cloud-context/pom.xml b/spring-cloud-context/pom.xml index f5b8bf9d..47c11488 100644 --- a/spring-cloud-context/pom.xml +++ b/spring-cloud-context/pom.xml @@ -7,7 +7,7 @@ org.springframework.cloud spring-cloud-commons-parent - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT .. spring-cloud-context diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/LifecycleMvcAutoConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/LifecycleMvcAutoConfigurationTests.java index b995d724..cf3af23d 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/LifecycleMvcAutoConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/LifecycleMvcAutoConfigurationTests.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.function.Function; import org.assertj.core.util.Lists; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/RefreshAutoConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/RefreshAutoConfigurationTests.java index e7b4f30d..04bf003c 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/RefreshAutoConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/RefreshAutoConfigurationTests.java @@ -18,8 +18,8 @@ package org.springframework.cloud.autoconfigure; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -27,7 +27,8 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.system.OutputCaptureRule; +import org.springframework.boot.test.system.CapturedOutput; +import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.cloud.context.refresh.ContextRefresher; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Configuration; @@ -38,11 +39,9 @@ import static org.assertj.core.api.BDDAssertions.then; /** * @author Dave Syer */ +@ExtendWith(OutputCaptureExtension.class) public class RefreshAutoConfigurationTests { - @Rule - public OutputCaptureRule output = new OutputCaptureRule(); - private static ConfigurableApplicationContext getApplicationContext(WebApplicationType type, Class configuration, String... properties) { return new SpringApplicationBuilder(configuration).web(type).properties(properties).properties("server.port=0") @@ -50,10 +49,10 @@ public class RefreshAutoConfigurationTests { } @Test - public void noWarnings() { + public void noWarnings(CapturedOutput output) { try (ConfigurableApplicationContext context = getApplicationContext(WebApplicationType.NONE, Config.class)) { then(context.containsBean("refreshScope")).isTrue(); - then(this.output.toString()).doesNotContain("WARN"); + then(output.toString()).doesNotContain("WARN"); } } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapDisabledAutoConfigurationIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapDisabledAutoConfigurationIntegrationTests.java index e5afe584..a3ba747d 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapDisabledAutoConfigurationIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapDisabledAutoConfigurationIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.bootstrap; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -25,11 +24,9 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.bootstrap.BootstrapDisabledAutoConfigurationIntegrationTests.Application; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = "spring.cloud.bootstrap.enabled:false") public class BootstrapDisabledAutoConfigurationIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java index e594156e..cbedca47 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.bootstrap; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -26,11 +25,9 @@ import org.springframework.cloud.bootstrap.BootstrapOrderingAutoConfigurationInt import org.springframework.context.annotation.Configuration; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = { "encrypt.key:deadbeef", "spring.config.use-legacy-processing=true" }) @ActiveProfiles("encrypt") diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests.java index fe9a5a4e..002af5ab 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests.java @@ -21,8 +21,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -35,12 +34,10 @@ import org.springframework.core.env.Environment; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; -import org.springframework.test.context.junit4.SpringRunner; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = { "spring.config.use-legacy-processing=true", "spring.cloud.bootstrap.name:ordering" }) public class BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java index c29b7296..ad236854 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java @@ -20,8 +20,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -34,11 +33,9 @@ import org.springframework.core.env.Environment; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.PropertySource; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = { "encrypt.key:deadbeef", "spring.cloud.bootstrap.name:custom", "spring.config.use-legacy-processing=true" }) @ActiveProfiles("encrypt") diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingSpringApplicationJsonIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingSpringApplicationJsonIntegrationTests.java index 1cdd4ac7..a7a142c8 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingSpringApplicationJsonIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingSpringApplicationJsonIntegrationTests.java @@ -16,10 +16,9 @@ package org.springframework.cloud.bootstrap; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -27,23 +26,21 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.bootstrap.BootstrapOrderingSpringApplicationJsonIntegrationTests.Application; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = "spring.cloud.bootstrap.name:json") public class BootstrapOrderingSpringApplicationJsonIntegrationTests { @Autowired private ConfigurableEnvironment environment; - @BeforeClass + @BeforeAll public static void spikeJson() { System.setProperty("SPRING_APPLICATION_JSON", "{\"message\":\"From JSON\"}"); } - @AfterClass + @AfterAll public static void unspikeJson() { System.clearProperty("SPRING_APPLICATION_JSON"); } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapSourcesOrderingTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapSourcesOrderingTests.java index 6ff2f885..11b9d6cd 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapSourcesOrderingTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapSourcesOrderingTests.java @@ -16,19 +16,16 @@ package org.springframework.cloud.bootstrap; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.bootstrap.BootstrapOrderingSpringApplicationJsonIntegrationTests.Application; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; import static org.springframework.cloud.bootstrap.TestHigherPriorityBootstrapConfiguration.firstToBeCreated; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = "spring.config.use-legacy-processing=true") public class BootstrapSourcesOrderingTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/MessageSourceConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/MessageSourceConfigurationTests.java index 168f3b01..faaf810a 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/MessageSourceConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/MessageSourceConfigurationTests.java @@ -23,8 +23,7 @@ package org.springframework.cloud.bootstrap; import java.util.Locale; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -32,11 +31,9 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.bootstrap.MessageSourceConfigurationTests.TestApplication; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestApplication.class, properties = "debug=true") public class MessageSourceConfigurationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java index 1194f78c..7d9228ae 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java @@ -21,11 +21,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.boot.WebApplicationType; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -53,14 +52,11 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class BootstrapConfigurationTests { - @Rule - public ExpectedException expected = ExpectedException.none(); - private ConfigurableApplicationContext context; private ConfigurableApplicationContext sibling; - @After + @AfterEach public void close() { // Expected.* is bound to the PropertySourceConfiguration below System.clearProperty("expected.name"); @@ -127,7 +123,7 @@ public class BootstrapConfigurationTests { /** * Running the test from maven will start from a different directory then starting it * from intellij - * @return + * @return external properties resource location */ private String getExternalProperties() { String externalPropertiesPath = "classpath:external-properties/bootstrap.properties"; @@ -148,9 +144,11 @@ public class BootstrapConfigurationTests { @Test public void failsOnPropertySource() { System.setProperty("expected.fail", "true"); - this.expected.expectMessage("Planned"); - this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE) - .properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class).run(); + Throwable throwable = Assertions.assertThrows(RuntimeException.class, () -> { + this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE) + .properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class).run(); + }); + then(throwable.getMessage().equals("Planned")); } @Test @@ -336,7 +334,7 @@ public class BootstrapConfigurationTests { } @Test - @Ignore // FIXME: legacy + @Disabled // FIXME: legacy public void differentProfileInChild() { PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar"); // Profiles are always merged with the child diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java index 4f117164..9c2b0b0c 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.bootstrap.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfigurationTests.java index a9d7b71b..c078fdd0 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfigurationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.bootstrap.encrypt; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.WebApplicationType; import org.springframework.boot.builder.SpringApplicationBuilder; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java index 08ba3ae0..926f44ab 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.bootstrap.encrypt; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptorFactoryTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptorFactoryTests.java index af42c2af..faa7c940 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptorFactoryTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptorFactoryTests.java @@ -18,7 +18,8 @@ package org.springframework.cloud.bootstrap.encrypt; import java.nio.charset.Charset; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.cloud.context.encrypt.EncryptorFactory; import org.springframework.core.io.ClassPathResource; @@ -44,11 +45,13 @@ public class EncryptorFactoryTests { then(encryptor.decrypt(encrypted)).isEqualTo(toEncrypt); } - @Test(expected = RuntimeException.class) + @Test public void testWithInvalidRsaPrivateKey() { String key = "-----BEGIN RSA PRIVATE KEY-----\n" + "MIIEowIBAAKCAQEAwClFgrRa/PUHPIJr9gvIPL6g6Rjp/TVZmVNOf2fL96DYbkj5\n"; - new EncryptorFactory().create(key); + Assertions.assertThrows(RuntimeException.class, () -> { + new EncryptorFactory().create(key); + }); } } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java index 2fb1bdac..b8a8f670 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java @@ -21,10 +21,11 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.boot.test.system.OutputCaptureRule; +import org.springframework.boot.test.system.CapturedOutput; +import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.test.util.TestPropertyValues.Type; import org.springframework.context.ApplicationContext; @@ -53,14 +54,12 @@ import static org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptAppl * @author Biju Kunjummen * @author Tim Ysewyn */ +@ExtendWith(OutputCaptureExtension.class) public class EnvironmentDecryptApplicationInitializerTests { private EnvironmentDecryptApplicationInitializer listener = new EnvironmentDecryptApplicationInitializer( Encryptors.noOpText()); - @Rule - public OutputCaptureRule outputCapture = new OutputCaptureRule(); - @Test public void decryptCipherKey() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(); @@ -89,7 +88,7 @@ public class EnvironmentDecryptApplicationInitializerTests { } @Test - public void errorOnDecrypt() { + public void errorOnDecrypt(CapturedOutput output) { this.listener = new EnvironmentDecryptApplicationInitializer(Encryptors.text("deadbeef", "AFFE37")); ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(); TestPropertyValues.of("spring.cloud.bootstrap.enabled=true", "foo: {cipher}bar").applyTo(context); @@ -101,19 +100,19 @@ public class EnvironmentDecryptApplicationInitializerTests { then(e).isInstanceOf(IllegalStateException.class); } // Assert logs contain warning even when exception thrown - String sysOutput = this.outputCapture.toString(); + String sysOutput = output.toString(); then(sysOutput).contains("Cannot decrypt: key=foo"); } @Test - public void errorOnDecryptWithEmpty() { + public void errorOnDecryptWithEmpty(CapturedOutput output) { this.listener = new EnvironmentDecryptApplicationInitializer(Encryptors.text("deadbeef", "AFFE37")); this.listener.setFailOnError(false); ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(); TestPropertyValues.of("spring.cloud.bootstrap.enabled=true", "foo: {cipher}bar").applyTo(context); this.listener.initialize(context); // Assert logs contain warning - String sysOutput = this.outputCapture.toString(); + String sysOutput = output.toString(); then(sysOutput).contains("Cannot decrypt: key=foo"); // Empty is safest fallback for undecryptable cipher then(context.getEnvironment().getProperty("foo")).isEqualTo(""); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerIntegrationTests.java index d27eab76..87c970ca 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerIntegrationTests.java @@ -24,8 +24,7 @@ import javax.servlet.ServletException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; @@ -40,7 +39,6 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import static org.assertj.core.api.Assertions.fail; @@ -50,7 +48,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = { "management.endpoints.web.exposure.include=*", "management.endpoint.env.post.enabled=true" }) @AutoConfigureMockMvc diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerTest.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerTest.java index d9b5d882..f826e9c6 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerTest.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerTest.java @@ -16,7 +16,7 @@ package org.springframework.cloud.context.environment; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.springframework.context.ApplicationEvent; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/named/NamedContextFactoryTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/named/NamedContextFactoryTests.java index 1e7ddc5d..4ae630ac 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/named/NamedContextFactoryTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/named/NamedContextFactoryTests.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.Map; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderIntegrationTests.java index b0a7ffa2..eea089a3 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderIntegrationTests.java @@ -19,8 +19,7 @@ package org.springframework.cloud.context.properties; import javax.annotation.PostConstruct; import org.aopalliance.intercept.MethodInterceptor; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -39,11 +38,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = "spring.config.use-legacy-processing=true") @ActiveProfiles("config") public class ConfigurationPropertiesRebinderIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderLifecycleIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderLifecycleIntegrationTests.java index 9fa505d9..1a898eba 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderLifecycleIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderLifecycleIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.properties; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -35,11 +34,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class ConfigurationPropertiesRebinderLifecycleIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderListIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderListIntegrationTests.java index 58434f77..b786728a 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderListIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderListIntegrationTests.java @@ -21,9 +21,8 @@ import java.util.Map; import javax.annotation.PostConstruct; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; @@ -40,11 +39,9 @@ import org.springframework.context.annotation.Import; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.PropertySource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = "messages=one,two") public class ConfigurationPropertiesRebinderListIntegrationTests { @@ -68,7 +65,7 @@ public class ConfigurationPropertiesRebinderListIntegrationTests { @Test @DirtiesContext - @Ignore("Can't rebind to list and re-initialize it (need refresh scope for this to work)") + @Disabled("Can't rebind to list and re-initialize it (need refresh scope for this to work)") public void testReplaceProperties() throws Exception { then("[one, two]").isEqualTo(this.properties.getMessages().toString()); Map map = findTestProperties(); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderProxyIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderProxyIntegrationTests.java index d25cfe76..b4322033 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderProxyIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderProxyIntegrationTests.java @@ -21,8 +21,7 @@ import java.util.Map; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.aop.AopAutoConfiguration; @@ -39,11 +38,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = { "messages.expiry.one=168", "messages.expiry.two=76" }) public class ConfigurationPropertiesRebinderProxyIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderRefreshScopeIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderRefreshScopeIntegrationTests.java index ed5e8ea2..4bf42ee0 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderRefreshScopeIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderRefreshScopeIntegrationTests.java @@ -18,8 +18,7 @@ package org.springframework.cloud.context.properties; import javax.annotation.PostConstruct; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; @@ -36,11 +35,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = "spring.config.use-legacy-processing=true") public class ConfigurationPropertiesRebinderRefreshScopeIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherIntegrationTests.java index 1a8e1a24..0c00c3a4 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.refresh; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -31,11 +30,9 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = { "spring.datasource.hikari.read-only=false", "spring.config.use-legacy-processing=true" }) public class ContextRefresherIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherOrderingIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherOrderingIntegrationTests.java index 11407e37..7fde8ea8 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherOrderingIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherOrderingIntegrationTests.java @@ -21,10 +21,9 @@ import java.util.Collection; import java.util.Collections; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringBootConfiguration; @@ -38,12 +37,10 @@ import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) @SpringBootTest(properties = "spring.config.use-legacy-processing=true") @DirtiesContext public class ContextRefresherOrderingIntegrationTests { @@ -56,14 +53,14 @@ public class ContextRefresherOrderingIntegrationTests { private static String original; - @BeforeClass + @BeforeAll public static void beforeClass() { original = System.getProperty("spring.cloud.bootstrap.sources"); System.setProperty("spring.cloud.bootstrap.sources", "org.springframework.cloud.context.refresh.ContextRefresherOrderingIntegrationTests.PropertySourceConfiguration"); } - @AfterClass + @AfterAll public static void afterClass() { if (original != null) { System.setProperty("spring.cloud.bootstrap.sources", original); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java index 76619d7b..da69559b 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java @@ -22,9 +22,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.boot.SpringApplication; @@ -52,14 +52,14 @@ public class ContextRefresherTests { private RefreshScope scope = Mockito.mock(RefreshScope.class); - @After + @AfterEach public void close() { System.clearProperty(LoggingSystem.SYSTEM_PROPERTY); TestLoggingSystem.count = 0; } @Test - @Ignore // FIXME: legacy config + @Disabled // FIXME: legacy config public void orderNewPropertiesConsistentWithNewContext() { try (ConfigurableApplicationContext context = SpringApplication.run(Empty.class, "--spring.config.use-legacy-processing=true", "--spring.main.web-application-type=none", diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/restart/RestartIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/restart/RestartIntegrationTests.java index 33605c08..c53702c8 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/restart/RestartIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/restart/RestartIntegrationTests.java @@ -16,8 +16,8 @@ package org.springframework.cloud.context.restart; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -35,7 +35,7 @@ public class RestartIntegrationTests { SpringApplication.run(TestConfiguration.class, args); } - @After + @AfterEach public void close() { if (this.context != null) { this.context.close(); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java index 18b75bfa..2eee178f 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.scope.refresh; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.aop.scope.ScopedProxyUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -28,11 +27,9 @@ import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.context.scope.refresh.ImportRefreshScopeIntegrationTests.TestConfiguration; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class ImportRefreshScopeIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/MoreRefreshScopeIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/MoreRefreshScopeIntegrationTests.java index dd6cd2b5..2513cea5 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/MoreRefreshScopeIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/MoreRefreshScopeIntegrationTests.java @@ -18,10 +18,9 @@ package org.springframework.cloud.context.scope.refresh; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.BeanCreationException; @@ -40,12 +39,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.fail; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class MoreRefreshScopeIntegrationTests { @@ -58,13 +55,13 @@ public class MoreRefreshScopeIntegrationTests { @Autowired private ConfigurableEnvironment environment; - @Before + @BeforeEach public void init() { then(TestService.getInitCount()).isEqualTo(1); TestService.reset(); } - @After + @AfterEach public void close() { TestService.reset(); } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java index b916bc61..20b8e9f7 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java @@ -21,8 +21,7 @@ import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; @@ -39,8 +38,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.RequestEntity; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.BDDAssertions.then; @@ -50,7 +48,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen * @author Dave Syer * */ -@RunWith(SpringRunner.class) + @SpringBootTest(classes = ClientApp.class, properties = { "management.endpoints.web.exposure.include=*", "management.endpoint.env.post.enabled=true" }, webEnvironment = RANDOM_PORT) @@ -109,7 +107,7 @@ public class RefreshEndpointIntegrationTests { this.message = message; } - @RequestMapping("/") + @GetMapping("/") public String hello() { return this.message; } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConcurrencyTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConcurrencyTests.java index e380bfd1..06a96cc9 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConcurrencyTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConcurrencyTests.java @@ -25,8 +25,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -45,11 +44,9 @@ import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Repeat; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class RefreshScopeConcurrencyTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationScaleTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationScaleTests.java index 78d96d23..60eb2b20 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationScaleTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationScaleTests.java @@ -27,8 +27,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -47,12 +46,10 @@ import org.springframework.context.annotation.Import; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Repeat; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.ObjectUtils; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = { "logging.level.org.springframework.cloud.context.scope.refresh.RefreshScopeConfigurationScaleTests=DEBUG" }) public class RefreshScopeConfigurationScaleTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java index 709e6c78..e2c8a868 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java @@ -16,10 +16,8 @@ package org.springframework.cloud.context.scope.refresh; -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.scope.ScopedProxyUtils; import org.springframework.beans.factory.annotation.Value; @@ -33,7 +31,7 @@ import org.springframework.cloud.context.scope.refresh.RefreshScopeConfiguration import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.BDDAssertions.then; @@ -44,12 +42,9 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class RefreshScopeConfigurationTests { - @Rule - public ExpectedException expected = ExpectedException.none(); - private AnnotationConfigApplicationContext context; - @After + @AfterEach public void init() { if (this.context != null) { this.context.close(); @@ -120,7 +115,7 @@ public class RefreshScopeConfigurationTests { @Value("${message:Hello World!}") String message; - @RequestMapping("/") + @GetMapping("/") public String hello() { return this.message; } @@ -140,7 +135,7 @@ public class RefreshScopeConfigurationTests { SpringApplication.run(Application.class, args); } - @RequestMapping("/") + @GetMapping("/") public String hello() { return this.message; } @@ -168,7 +163,7 @@ public class RefreshScopeConfigurationTests { @Value("${message:Hello World!}") String message; - @RequestMapping("/") + @GetMapping("/") // Deliberately use package scope String hello() { return this.message; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeIntegrationTests.java index 46209dbc..aecd8518 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeIntegrationTests.java @@ -18,10 +18,10 @@ package org.springframework.cloud.context.scope.refresh; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.scope.ScopedProxyUtils; @@ -40,11 +40,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class RefreshScopeIntegrationTests { @@ -57,13 +55,13 @@ public class RefreshScopeIntegrationTests { @Autowired private org.springframework.cloud.context.scope.refresh.RefreshScope scope; - @Before + @BeforeEach public void init() { then(ExampleService.getInitCount()).isEqualTo(1); ExampleService.reset(); } - @After + @AfterEach public void close() { ExampleService.reset(); } @@ -119,10 +117,12 @@ public class RefreshScopeIntegrationTests { } // see gh-349 - @Test(expected = ServiceException.class) + @Test @DirtiesContext - public void testCheckedException() throws Exception { - this.service.throwsException(); + public void testCheckedException() { + Assertions.assertThrows(ServiceException.class, () -> { + this.service.throwsException(); + }); } public interface Service { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeLazyIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeLazyIntegrationTests.java index c1186183..c0aee999 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeLazyIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeLazyIntegrationTests.java @@ -18,10 +18,9 @@ package org.springframework.cloud.context.scope.refresh; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.scope.ScopedProxyUtils; @@ -42,11 +41,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class RefreshScopeLazyIntegrationTests { @@ -59,14 +56,14 @@ public class RefreshScopeLazyIntegrationTests { @Autowired private org.springframework.cloud.context.scope.refresh.RefreshScope scope; - @Before + @BeforeEach public void init() { // The RefreshScope is lazy (eager=false) so it won't have been instantiated yet then(ExampleService.getInitCount()).isEqualTo(0); ExampleService.reset(); } - @After + @AfterEach public void close() { ExampleService.reset(); } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeListBindingIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeListBindingIntegrationTests.java index dd880ac1..2831adac 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeListBindingIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeListBindingIntegrationTests.java @@ -20,8 +20,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.annotation.Autowired; @@ -40,11 +39,9 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.PropertySource; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = { "test.messages[0]=one", "test.messages[1]=two" }) public class RefreshScopeListBindingIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeNullBeanIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeNullBeanIntegrationTests.java index 9e578bdc..8f7afa91 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeNullBeanIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeNullBeanIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.scope.refresh; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; @@ -28,11 +27,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = { RefreshScopeNullBeanIntegrationTests.TestConfiguration.class }) public class RefreshScopeNullBeanIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopePureScaleTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopePureScaleTests.java index 6af6e026..61cc3da7 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopePureScaleTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopePureScaleTests.java @@ -27,8 +27,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -43,12 +42,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Repeat; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.ObjectUtils; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) // , // properties="logging.level.org.springframework.cloud.context.scope.refresh.RefreshScopePureScaleTests=DEBUG") diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeScaleTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeScaleTests.java index 39ce6ed8..056c9065 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeScaleTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeScaleTests.java @@ -25,8 +25,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -45,11 +44,9 @@ import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Repeat; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class RefreshScopeScaleTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeSerializationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeSerializationTests.java index 3cc2ef0a..df903e29 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeSerializationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeSerializationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.context.scope.refresh; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.boot.WebApplicationType; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeWebIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeWebIntegrationTests.java index ee62fd3f..748e936a 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeWebIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeWebIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.scope.refresh; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.aop.scope.ScopedProxyUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -31,8 +30,7 @@ import org.springframework.cloud.context.environment.EnvironmentManager; import org.springframework.cloud.context.scope.refresh.RefreshScopeWebIntegrationTests.Application; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.BDDAssertions.then; @@ -41,7 +39,6 @@ import static org.assertj.core.api.BDDAssertions.then; * @author Dave Syer * */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class RefreshScopeWebIntegrationTests { @@ -94,7 +91,7 @@ public class RefreshScopeWebIntegrationTests { @Value("${message:Hello World!}") String message; - @RequestMapping("/") + @GetMapping("/") public String hello() { return this.message; } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/health/RefreshScopeHealthIndicatorTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/health/RefreshScopeHealthIndicatorTests.java index c9046519..ea549487 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/health/RefreshScopeHealthIndicatorTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/health/RefreshScopeHealthIndicatorTests.java @@ -18,8 +18,8 @@ package org.springframework.cloud.health; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.BDDMockito; import org.springframework.beans.factory.ObjectProvider; @@ -45,7 +45,7 @@ public class RefreshScopeHealthIndicatorTests { private RefreshScopeHealthIndicator indicator = new RefreshScopeHealthIndicator(this.scopeProvider, this.rebinder); - @Before + @BeforeEach public void init() { BDDMockito.willReturn(this.scope).given(this.scopeProvider).getIfAvailable(); when(this.rebinder.getErrors()).thenReturn(Collections.emptyMap()); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/logging/LoggingRebinderTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/logging/LoggingRebinderTests.java index ff1aaff7..e04401cd 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/logging/LoggingRebinderTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/logging/LoggingRebinderTests.java @@ -19,8 +19,8 @@ package org.springframework.cloud.logging; import java.util.Collections; import ch.qos.logback.classic.Level; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +43,7 @@ public class LoggingRebinderTests { private Logger logger = LoggerFactory.getLogger("org.springframework.web"); - @After + @AfterEach public void reset() { LoggingSystem.get(getClass().getClassLoader()).setLogLevel("org.springframework.web", LogLevel.INFO); } diff --git a/spring-cloud-loadbalancer/pom.xml b/spring-cloud-loadbalancer/pom.xml index efa78ed0..281b79f9 100644 --- a/spring-cloud-loadbalancer/pom.xml +++ b/spring-cloud-loadbalancer/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-commons-parent - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT .. spring-cloud-loadbalancer diff --git a/spring-cloud-starter-bootstrap/pom.xml b/spring-cloud-starter-bootstrap/pom.xml index 74a8d2e7..a30f0d00 100644 --- a/spring-cloud-starter-bootstrap/pom.xml +++ b/spring-cloud-starter-bootstrap/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-commons-parent - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT .. jar diff --git a/spring-cloud-starter-loadbalancer/pom.xml b/spring-cloud-starter-loadbalancer/pom.xml index 0c5adbee..86102d8c 100644 --- a/spring-cloud-starter-loadbalancer/pom.xml +++ b/spring-cloud-starter-loadbalancer/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-commons-parent - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT .. 4.0.0 diff --git a/spring-cloud-starter/pom.xml b/spring-cloud-starter/pom.xml index 06701095..298b8785 100644 --- a/spring-cloud-starter/pom.xml +++ b/spring-cloud-starter/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-commons-parent - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT spring-cloud-starter spring-cloud-starter diff --git a/spring-cloud-test-support/pom.xml b/spring-cloud-test-support/pom.xml index 95078dba..0553c016 100644 --- a/spring-cloud-test-support/pom.xml +++ b/spring-cloud-test-support/pom.xml @@ -7,7 +7,7 @@ org.springframework.cloud spring-cloud-commons-parent - 3.0.4-SNAPSHOT + 3.1.0-SNAPSHOT .. spring-cloud-test-support