diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0679d88 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +insert_final_newline = true + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100755 index 0000000..fa4f7b4 --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,110 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you 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 { + + /** + * 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/0.4.2/maven-wrapper-0.4.2.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 direcrory '" + 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 { + 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 old mode 100644 new mode 100755 index 5fd4d50..01e6799 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 old mode 100644 new mode 100755 index a447c9f..00d32aa --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip \ No newline at end of file +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip \ No newline at end of file diff --git a/.settings.xml b/.settings.xml index 6c35512..6f542c9 100644 --- a/.settings.xml +++ b/.settings.xml @@ -1,66 +1,68 @@ - - - repo.spring.io - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - - spring - true - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - http://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - - + + + repo.spring.io + ${env.CI_DEPLOY_USERNAME} + ${env.CI_DEPLOY_PASSWORD} + + + + + + spring + + true + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + http://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + + diff --git a/.springformat b/.springformat new file mode 100644 index 0000000..e69de29 diff --git a/docs/pom.xml b/docs/pom.xml index 26a5805..44d5fec 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 org.springframework.cloud @@ -16,14 +17,14 @@ ${basedir}/.. 1.0.x,1.1.x - + - - maven-deploy-plugin - - true - - + + maven-deploy-plugin + + true + + diff --git a/mvnw b/mvnw index 25f750c..5551fde 100755 --- a/mvnw +++ b/mvnw @@ -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,7 +108,7 @@ 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)`" @@ -184,27 +162,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,38 +195,92 @@ 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 + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + 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 command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + 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" -# 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 $@" -export MAVEN_CMD_LINE_ARGS +# 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 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 old mode 100644 new mode 100755 index b0dc0e7..48363fa --- a/mvnw.cmd +++ b/mvnw.cmd @@ -1,145 +1,161 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@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 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 -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@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_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 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@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' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -: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. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="".\.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% -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@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 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 +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@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_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 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.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% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%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 + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml index 85cd06c..7029fd9 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - 4.0.0 @@ -20,6 +21,12 @@ ${basedir} 2.1.1.BUILD-SNAPSHOT 2.1.1.BUILD-SNAPSHOT + + true + true + + true + @@ -53,9 +60,26 @@ 1.8 + + org.apache.maven.plugins + maven-checkstyle-plugin + + + io.spring.javaformat + spring-javaformat-maven-plugin + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + + diff --git a/spring-cloud-cloudfoundry-commons/pom.xml b/spring-cloud-cloudfoundry-commons/pom.xml index 10b027e..c601ddf 100644 --- a/spring-cloud-cloudfoundry-commons/pom.xml +++ b/spring-cloud-cloudfoundry-commons/pom.xml @@ -1,5 +1,6 @@ - 4.0.0 diff --git a/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfiguration.java b/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfiguration.java index 4cf5c00..1515cf9 100644 --- a/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfiguration.java +++ b/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.cloudfoundry.reactor.tokenprovider.PasswordGrantTokenProvider; import org.cloudfoundry.reactor.uaa.ReactorUaaClient; import org.cloudfoundry.routing.RoutingClient; import org.cloudfoundry.uaa.UaaClient; + import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -46,9 +47,12 @@ import org.springframework.context.annotation.Lazy; * @author Scott Frederick */ @Configuration -@ConditionalOnProperty(prefix = "spring.cloud.cloudfoundry", name = {"username", "password"}) -@ConditionalOnClass(name = {"reactor.core.publisher.Flux", "org.cloudfoundry.operations.DefaultCloudFoundryOperations", - "org.cloudfoundry.reactor.client.ReactorCloudFoundryClient", "org.reactivestreams.Publisher"}) +@ConditionalOnProperty(prefix = "spring.cloud.cloudfoundry", name = { "username", + "password" }) +@ConditionalOnClass(name = { "reactor.core.publisher.Flux", + "org.cloudfoundry.operations.DefaultCloudFoundryOperations", + "org.cloudfoundry.reactor.client.ReactorCloudFoundryClient", + "org.reactivestreams.Publisher" }) @EnableConfigurationProperties(CloudFoundryProperties.class) public class CloudFoundryClientAutoConfiguration { @@ -61,67 +65,59 @@ public class CloudFoundryClientAutoConfiguration { @Bean @Lazy @ConditionalOnMissingBean - public CloudFoundryService cloudFoundryService(CloudFoundryOperations cloudFoundryOperations) { + public CloudFoundryService cloudFoundryService( + CloudFoundryOperations cloudFoundryOperations) { return new CloudFoundryService(cloudFoundryOperations); } @Bean @Lazy @ConditionalOnMissingBean - public DefaultCloudFoundryOperations cloudFoundryOperations(CloudFoundryClient cloudFoundryClient, - DopplerClient dopplerClient, - RoutingClient routingClient, - UaaClient uaaClient) { + public DefaultCloudFoundryOperations cloudFoundryOperations( + CloudFoundryClient cloudFoundryClient, DopplerClient dopplerClient, + RoutingClient routingClient, UaaClient uaaClient) { String organization = this.cloudFoundryProperties.getOrg(); String space = this.cloudFoundryProperties.getSpace(); - return DefaultCloudFoundryOperations - .builder() - .cloudFoundryClient(cloudFoundryClient) - .dopplerClient(dopplerClient) - .routingClient(routingClient) - .uaaClient(uaaClient) - .organization(organization) - .space(space) - .build(); - } - @Bean - @Lazy - @ConditionalOnMissingBean - public ReactorCloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) { - return ReactorCloudFoundryClient.builder() - .connectionContext(connectionContext) - .tokenProvider(tokenProvider) - .build(); + return DefaultCloudFoundryOperations.builder() + .cloudFoundryClient(cloudFoundryClient).dopplerClient(dopplerClient) + .routingClient(routingClient).uaaClient(uaaClient) + .organization(organization).space(space).build(); } @Bean @Lazy @ConditionalOnMissingBean - public DopplerClient dopplerClient(ConnectionContext connectionContext, TokenProvider tokenProvider) { - return ReactorDopplerClient.builder() - .connectionContext(connectionContext) - .tokenProvider(tokenProvider) - .build(); + public ReactorCloudFoundryClient cloudFoundryClient( + ConnectionContext connectionContext, TokenProvider tokenProvider) { + return ReactorCloudFoundryClient.builder().connectionContext(connectionContext) + .tokenProvider(tokenProvider).build(); } @Bean @Lazy @ConditionalOnMissingBean - public RoutingClient routingClient(ConnectionContext connectionContext, TokenProvider tokenProvider) { - return ReactorRoutingClient.builder() - .connectionContext(connectionContext) - .tokenProvider(tokenProvider) - .build(); + public DopplerClient dopplerClient(ConnectionContext connectionContext, + TokenProvider tokenProvider) { + return ReactorDopplerClient.builder().connectionContext(connectionContext) + .tokenProvider(tokenProvider).build(); } @Bean @Lazy @ConditionalOnMissingBean - public ReactorUaaClient uaaClient(ConnectionContext connectionContext, TokenProvider tokenProvider) { - return ReactorUaaClient.builder() - .connectionContext(connectionContext) - .tokenProvider(tokenProvider) - .build(); + public RoutingClient routingClient(ConnectionContext connectionContext, + TokenProvider tokenProvider) { + return ReactorRoutingClient.builder().connectionContext(connectionContext) + .tokenProvider(tokenProvider).build(); + } + + @Bean + @Lazy + @ConditionalOnMissingBean + public ReactorUaaClient uaaClient(ConnectionContext connectionContext, + TokenProvider tokenProvider) { + return ReactorUaaClient.builder().connectionContext(connectionContext) + .tokenProvider(tokenProvider).build(); } @Bean @@ -131,10 +127,8 @@ public class CloudFoundryClientAutoConfiguration { String apiHost = this.cloudFoundryProperties.getUrl(); Boolean skipSslValidation = this.cloudFoundryProperties.isSkipSslValidation(); - return DefaultConnectionContext.builder() - .apiHost(apiHost) - .skipSslValidation(skipSslValidation) - .build(); + return DefaultConnectionContext.builder().apiHost(apiHost) + .skipSslValidation(skipSslValidation).build(); } @Bean @@ -143,11 +137,8 @@ public class CloudFoundryClientAutoConfiguration { public PasswordGrantTokenProvider tokenProvider() { String username = this.cloudFoundryProperties.getUsername(); String password = this.cloudFoundryProperties.getPassword(); - return PasswordGrantTokenProvider.builder() - .password(password) - .username(username) + return PasswordGrantTokenProvider.builder().password(password).username(username) .build(); } + } - - diff --git a/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryProperties.java b/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryProperties.java index d87cb12..9906ad4 100644 --- a/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryProperties.java +++ b/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,17 +16,17 @@ package org.springframework.cloud.cloudfoundry; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.util.Assert; import org.springframework.util.StringUtils; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * Configuration properties for a connection to a Cloud Foundry platform. * @@ -69,6 +69,10 @@ public class CloudFoundryProperties implements InitializingBean { return this.url; } + public void setUrl(String cloudControllerUrl) { + this.url = cloudControllerUrl; + } + private String safeUrl(String t) { String input = t.trim().toLowerCase(); Pattern p = Pattern.compile("(http(s)?://)(.*)"); @@ -82,10 +86,6 @@ public class CloudFoundryProperties implements InitializingBean { return t; } - public void setUrl(String cloudControllerUrl) { - this.url = cloudControllerUrl; - } - public String getUsername() { return this.username; } @@ -119,7 +119,7 @@ public class CloudFoundryProperties implements InitializingBean { } public boolean isSkipSslValidation() { - return skipSslValidation; + return this.skipSslValidation; } public boolean getSkipSslValidation() { @@ -146,6 +146,8 @@ public class CloudFoundryProperties implements InitializingBean { vals.put("url", getUrl()); vals.put("username", getUsername()); vals.put("password", getPassword()); - vals.forEach((key, value) -> Assert.hasText(value, String.format("'%s' must be provided", key))); + vals.forEach((key, value) -> Assert.hasText(value, + String.format("'%s' must be provided", key))); } -} \ No newline at end of file + +} diff --git a/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryService.java b/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryService.java index 7466550..4760841 100644 --- a/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryService.java +++ b/spring-cloud-cloudfoundry-commons/src/main/java/org/springframework/cloud/cloudfoundry/CloudFoundryService.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.cloud.cloudfoundry; - import org.cloudfoundry.operations.CloudFoundryOperations; import org.cloudfoundry.operations.applications.ApplicationDetail; import org.cloudfoundry.operations.applications.GetApplicationRequest; @@ -38,15 +37,17 @@ public class CloudFoundryService { this.cloudFoundryOperations = cloudFoundryOperations; } - public Flux> getApplicationInstances(String serviceId) { - GetApplicationRequest applicationRequest = GetApplicationRequest.builder().name(serviceId).build(); - return this.cloudFoundryOperations - .applications() - .get(applicationRequest) + public Flux> getApplicationInstances( + String serviceId) { + GetApplicationRequest applicationRequest = GetApplicationRequest.builder() + .name(serviceId).build(); + return this.cloudFoundryOperations.applications().get(applicationRequest) .flatMapMany(applicationDetail -> { - Flux ids = Flux.fromStream(applicationDetail.getInstanceDetails().stream()) + Flux ids = Flux + .fromStream(applicationDetail.getInstanceDetails().stream()) .filter(id -> id.getState().equalsIgnoreCase("RUNNING")); - Flux generate = Flux.generate(sink -> sink.next(applicationDetail)); + Flux generate = Flux + .generate(sink -> sink.next(applicationDetail)); return generate.zipWith(ids); }); } diff --git a/spring-cloud-cloudfoundry-commons/src/main/resources/META-INF/spring.factories b/spring-cloud-cloudfoundry-commons/src/main/resources/META-INF/spring.factories index f4b6d26..2c71a3d 100644 --- a/spring-cloud-cloudfoundry-commons/src/main/resources/META-INF/spring.factories +++ b/spring-cloud-cloudfoundry-commons/src/main/resources/META-INF/spring.factories @@ -1,3 +1,2 @@ - org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - org.springframework.cloud.cloudfoundry.CloudFoundryClientAutoConfiguration \ No newline at end of file + org.springframework.cloud.cloudfoundry.CloudFoundryClientAutoConfiguration diff --git a/spring-cloud-cloudfoundry-commons/src/test/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfigurationTest.java b/spring-cloud-cloudfoundry-commons/src/test/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfigurationTest.java index adacc83..7446de7 100644 --- a/spring-cloud-cloudfoundry-commons/src/test/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfigurationTest.java +++ b/spring-cloud-cloudfoundry-commons/src/test/java/org/springframework/cloud/cloudfoundry/CloudFoundryClientAutoConfigurationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.cloudfoundry.reactor.uaa.ReactorUaaClient; import org.cloudfoundry.routing.RoutingClient; import org.junit.Assume; import org.junit.Test; + import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -35,13 +36,12 @@ import static org.assertj.core.api.Assertions.assertThat; public class CloudFoundryClientAutoConfigurationTest { - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(CloudFoundryClientAutoConfiguration.class)); + private final static String[] SPRING_CLOUD_PROPERTIES = { + "spring.cloud.cloudfoundry.username", "spring.cloud.cloudfoundry.password", }; - private final static String SPRING_CLOUD_PROPERTIES[] = { - "spring.cloud.cloudfoundry.username", - "spring.cloud.cloudfoundry.password", - }; + private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration( + AutoConfigurations.of(CloudFoundryClientAutoConfiguration.class)); private static boolean requiredPropertiesSet() { for (String k : SPRING_CLOUD_PROPERTIES) { @@ -53,23 +53,19 @@ public class CloudFoundryClientAutoConfigurationTest { } private static String envVarFromProperty(String propertyName) { - return propertyName - .replaceAll("\\.", "_") - .toUpperCase(); + return propertyName.replaceAll("\\.", "_").toUpperCase(); } @Test public void autoConfiguresBeansWithAllProperties() { - this.contextRunner - .withPropertyValues( - "spring.cloud.cloudfoundry.username=user", - "spring.cloud.cloudfoundry.password=secret", - "spring.cloud.cloudfoundry.org=myorg", - "spring.cloud.cloudfoundry.space=myspace") - .run((context) -> { + this.contextRunner.withPropertyValues("spring.cloud.cloudfoundry.username=user", + "spring.cloud.cloudfoundry.password=secret", + "spring.cloud.cloudfoundry.org=myorg", + "spring.cloud.cloudfoundry.space=myspace").run((context) -> { assertCloudFoundryClientBeansPresent(context); - DefaultCloudFoundryOperations operations = context.getBean(DefaultCloudFoundryOperations.class); + DefaultCloudFoundryOperations operations = context + .getBean(DefaultCloudFoundryOperations.class); assertThat(operations.getOrganization()).isEqualTo("myorg"); assertThat(operations.getSpace()).isEqualTo("myspace"); }); @@ -77,14 +73,12 @@ public class CloudFoundryClientAutoConfigurationTest { @Test public void autoConfiguresBeansWithMinimalProperties() { - this.contextRunner - .withPropertyValues( - "spring.cloud.cloudfoundry.username=user", - "spring.cloud.cloudfoundry.password=secret") - .run((context) -> { + this.contextRunner.withPropertyValues("spring.cloud.cloudfoundry.username=user", + "spring.cloud.cloudfoundry.password=secret").run((context) -> { assertCloudFoundryClientBeansPresent(context); - DefaultCloudFoundryOperations operations = context.getBean(DefaultCloudFoundryOperations.class); + DefaultCloudFoundryOperations operations = context + .getBean(DefaultCloudFoundryOperations.class); assertThat(operations.getOrganization()).isNullOrEmpty(); assertThat(operations.getSpace()).isNullOrEmpty(); }); @@ -94,23 +88,21 @@ public class CloudFoundryClientAutoConfigurationTest { public void organizationsRetrievedWithUserProvidedProperties() { Assume.assumeTrue(requiredPropertiesSet()); - this.contextRunner - .run((context) -> { - assertCloudFoundryClientBeansPresent(context); - CloudFoundryOperations operations = context.getBean(CloudFoundryOperations.class); + this.contextRunner.run((context) -> { + assertCloudFoundryClientBeansPresent(context); + CloudFoundryOperations operations = context + .getBean(CloudFoundryOperations.class); - OrganizationSummary summary = operations - .organizations() - .list() - .blockFirst(); + OrganizationSummary summary = operations.organizations().list().blockFirst(); - assertThat(summary).isNotNull(); - assertThat(summary.getId()).isNotEmpty(); - assertThat(summary.getName()).isNotEmpty(); - }); + assertThat(summary).isNotNull(); + assertThat(summary.getId()).isNotEmpty(); + assertThat(summary.getName()).isNotEmpty(); + }); } - private void assertCloudFoundryClientBeansPresent(AssertableApplicationContext context) { + private void assertCloudFoundryClientBeansPresent( + AssertableApplicationContext context) { assertThat(context).hasSingleBean(ReactorCloudFoundryClient.class); assertThat(context).hasSingleBean(DefaultCloudFoundryOperations.class); assertThat(context).hasSingleBean(DefaultConnectionContext.class); @@ -119,4 +111,5 @@ public class CloudFoundryClientAutoConfigurationTest { assertThat(context).hasSingleBean(PasswordGrantTokenProvider.class); assertThat(context).hasSingleBean(ReactorUaaClient.class); } -} \ No newline at end of file + +} diff --git a/spring-cloud-cloudfoundry-dependencies/pom.xml b/spring-cloud-cloudfoundry-dependencies/pom.xml index 24f8b24..0880488 100644 --- a/spring-cloud-cloudfoundry-dependencies/pom.xml +++ b/spring-cloud-cloudfoundry-dependencies/pom.xml @@ -1,5 +1,6 @@ - 4.0.0 diff --git a/spring-cloud-cloudfoundry-discovery/pom.xml b/spring-cloud-cloudfoundry-discovery/pom.xml index 0436711..7d575a0 100644 --- a/spring-cloud-cloudfoundry-discovery/pom.xml +++ b/spring-cloud-cloudfoundry-discovery/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 spring-cloud-cloudfoundry-discovery jar @@ -51,4 +52,4 @@ test - \ No newline at end of file + diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClient.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClient.java index a7ac2c3..d1a30da 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClient.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,14 +42,16 @@ import org.springframework.cloud.cloudfoundry.CloudFoundryService; public class CloudFoundryDiscoveryClient implements DiscoveryClient { private final CloudFoundryService cloudFoundryService; + private final CloudFoundryOperations cloudFoundryOperations; + private final CloudFoundryDiscoveryProperties properties; - private final String description = "Cloud Foundry " + DiscoveryClient.class.getName() + " implementation"; + private final String description = "Cloud Foundry " + DiscoveryClient.class.getName() + + " implementation"; CloudFoundryDiscoveryClient(CloudFoundryOperations cloudFoundryOperations, - CloudFoundryService svc, - CloudFoundryDiscoveryProperties properties) { + CloudFoundryService svc, CloudFoundryDiscoveryProperties properties) { this.cloudFoundryService = svc; this.cloudFoundryOperations = cloudFoundryOperations; this.properties = properties; @@ -62,37 +64,30 @@ public class CloudFoundryDiscoveryClient implements DiscoveryClient { @Override public List getInstances(String serviceId) { - return cloudFoundryService - .getApplicationInstances(serviceId) - .map(tuple -> { - ApplicationDetail applicationDetail = tuple.getT1(); - InstanceDetail instanceDetail = tuple.getT2(); + return this.cloudFoundryService.getApplicationInstances(serviceId).map(tuple -> { + ApplicationDetail applicationDetail = tuple.getT1(); + InstanceDetail instanceDetail = tuple.getT2(); - String applicationId = applicationDetail.getId(); - String applicationIndex = instanceDetail.getIndex(); - String name = applicationDetail.getName(); - String url = applicationDetail.getUrls().size() > 0 ? applicationDetail.getUrls().get(0) : null; - boolean secure = (url + "").toLowerCase().startsWith("https"); + String applicationId = applicationDetail.getId(); + String applicationIndex = instanceDetail.getIndex(); + String name = applicationDetail.getName(); + String url = applicationDetail.getUrls().size() > 0 + ? applicationDetail.getUrls().get(0) : null; + boolean secure = (url + "").toLowerCase().startsWith("https"); - HashMap metadata = new HashMap<>(); - metadata.put("applicationId", applicationId); - metadata.put("instanceId", applicationIndex); + HashMap metadata = new HashMap<>(); + metadata.put("applicationId", applicationId); + metadata.put("instanceId", applicationIndex); - return (ServiceInstance) new DefaultServiceInstance(name, url, 80, secure, metadata); - }) - .collectList() - .blockOptional() - .orElse(new ArrayList<>()); + return (ServiceInstance) new DefaultServiceInstance(name, url, 80, secure, + metadata); + }).collectList().blockOptional().orElse(new ArrayList<>()); } @Override public List getServices() { - return this.cloudFoundryOperations - .applications() - .list() - .map(ApplicationSummary::getName) - .collectList() - .blockOptional() + return this.cloudFoundryOperations.applications().list() + .map(ApplicationSummary::getName).collectList().blockOptional() .orElse(new ArrayList<>()); } @@ -100,4 +95,5 @@ public class CloudFoundryDiscoveryClient implements DiscoveryClient { public int getOrder() { return this.properties.getOrder(); } -} \ No newline at end of file + +} diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java index 97cc709..5350c04 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,9 @@ public class CloudFoundryDiscoveryClientConfiguration { } @Bean - public CloudFoundryHeartbeatSender cloudFoundryHeartbeatSender(CloudFoundryDiscoveryClient client) { + public CloudFoundryHeartbeatSender cloudFoundryHeartbeatSender( + CloudFoundryDiscoveryClient client) { return new CloudFoundryHeartbeatSender(client); } -} \ No newline at end of file + +} diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientProperties.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientProperties.java index 5e6c07d..b52f65a 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientProperties.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import org.springframework.core.Ordered; /** * Properties used for configuring the CloudFoundry implementation of - * {@link org.springframework.cloud.client.discovery.DiscoveryClient} + * {@link org.springframework.cloud.client.discovery.DiscoveryClient}. * * @author Olga Maciaszek-Sharma */ @@ -37,4 +37,5 @@ public class CloudFoundryDiscoveryClientProperties { public void setOrder(int order) { this.order = order; } + } diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryProperties.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryProperties.java index 92552e9..9340b27 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryProperties.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,12 +41,13 @@ public class CloudFoundryDiscoveryProperties { private int defaultServerPort = 80; /** - * Order of the discovery client used by `CompositeDiscoveryClient` for sorting available clients. + * Order of the discovery client used by `CompositeDiscoveryClient` for sorting + * available clients. */ private int order = 0; public boolean isEnabled() { - return enabled; + return this.enabled; } public void setEnabled(boolean enabled) { @@ -62,7 +63,7 @@ public class CloudFoundryDiscoveryProperties { } public int getDefaultServerPort() { - return defaultServerPort; + return this.defaultServerPort; } public void setDefaultServerPort(int defaultServerPort) { @@ -70,7 +71,7 @@ public class CloudFoundryDiscoveryProperties { } public int getOrder() { - return order; + return this.order; } public void setOrder(int order) { @@ -79,11 +80,10 @@ public class CloudFoundryDiscoveryProperties { @Override public String toString() { - return "CloudFoundryDiscoveryProperties{" + - "enabled=" + enabled + - ", heartbeatFrequency=" + heartbeatFrequency + - ", defaultServerPort=" + defaultServerPort + - ", order=" + order + - '}'; + return "CloudFoundryDiscoveryProperties{" + "enabled=" + this.enabled + + ", heartbeatFrequency=" + this.heartbeatFrequency + + ", defaultServerPort=" + this.defaultServerPort + ", order=" + + this.order + '}'; } + } diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryHeartbeatSender.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryHeartbeatSender.java index 2a00cb5..9d5b63f 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryHeartbeatSender.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryHeartbeatSender.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import org.springframework.stereotype.Component; public class CloudFoundryHeartbeatSender implements ApplicationEventPublisherAware { private final CloudFoundryDiscoveryClient client; + private ApplicationEventPublisher publisher; public CloudFoundryHeartbeatSender(CloudFoundryDiscoveryClient client) { diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryRibbonClientConfiguration.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryRibbonClientConfiguration.java index 4929b54..ac95033 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryRibbonClientConfiguration.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryRibbonClientConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,9 @@ package org.springframework.cloud.cloudfoundry.discovery; import javax.annotation.PostConstruct; +import com.netflix.client.config.IClientConfig; +import com.netflix.loadbalancer.ServerList; + import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.cloud.cloudfoundry.CloudFoundryService; import org.springframework.cloud.netflix.ribbon.RibbonClientName; @@ -25,9 +28,6 @@ import org.springframework.cloud.netflix.ribbon.RibbonUtils; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import com.netflix.client.config.IClientConfig; -import com.netflix.loadbalancer.ServerList; - /** * @author Josh Long */ @@ -47,8 +47,9 @@ public class CloudFoundryRibbonClientConfiguration { @Bean @ConditionalOnMissingBean public ServerList ribbonServerList(CloudFoundryService svc, IClientConfig config, - CloudFoundryDiscoveryProperties properties) { - CloudFoundryServerList cloudFoundryServerList = new CloudFoundryServerList(svc, properties); + CloudFoundryDiscoveryProperties properties) { + CloudFoundryServerList cloudFoundryServerList = new CloudFoundryServerList(svc, + properties); cloudFoundryServerList.initWithNiwsConfig(config); return cloudFoundryServerList; } @@ -58,4 +59,4 @@ public class CloudFoundryRibbonClientConfiguration { RibbonUtils.initializeRibbonDefaults(this.serviceId); } -} \ No newline at end of file +} diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServer.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServer.java index 1ee7d51..75c8e7f 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServer.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServer.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,4 +54,5 @@ public class CloudFoundryServer extends Server { public MetaInfo getMetaInfo() { return this.metaInfo; } -} \ No newline at end of file + +} diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServerList.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServerList.java index d5f91c4..17c5b6b 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServerList.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServerList.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,24 +19,28 @@ package org.springframework.cloud.cloudfoundry.discovery; import java.util.ArrayList; import java.util.List; +import com.netflix.client.config.IClientConfig; +import com.netflix.loadbalancer.AbstractServerList; + import org.springframework.cloud.cloudfoundry.CloudFoundryService; import org.springframework.cloud.netflix.ribbon.RibbonProperties; import org.springframework.util.Assert; -import com.netflix.client.config.IClientConfig; -import com.netflix.loadbalancer.AbstractServerList; - /** * @author Josh Long */ public class CloudFoundryServerList extends AbstractServerList { + private final CloudFoundryService cloudFoundryService; + private final CloudFoundryDiscoveryProperties properties; private IClientConfig clientConfig; + private String serviceId; - CloudFoundryServerList(CloudFoundryService svc, CloudFoundryDiscoveryProperties properties) { + CloudFoundryServerList(CloudFoundryService svc, + CloudFoundryDiscoveryProperties properties) { this.cloudFoundryService = svc; this.properties = properties; } @@ -60,7 +64,7 @@ public class CloudFoundryServerList extends AbstractServerList cloudFoundryServers() { Assert.notNull(this.clientConfig, "clientConfig may not be null"); - RibbonProperties ribbon = RibbonProperties.from(clientConfig); + RibbonProperties ribbon = RibbonProperties.from(this.clientConfig); Boolean secure = ribbon.getSecure(); Integer securePort = ribbon.getSecurePort(); @@ -69,21 +73,23 @@ public class CloudFoundryServerList extends AbstractServerList new CloudFoundryServer(tpl.getT1().getName(), tpl.getT1().getUrls().get(0), port)) - .collectList() - .blockOptional() - .orElse(new ArrayList<>()); + return this.cloudFoundryService.getApplicationInstances(this.serviceId) + .map(tpl -> new CloudFoundryServer(tpl.getT1().getName(), + tpl.getT1().getUrls().get(0), port)) + .collectList().blockOptional().orElse(new ArrayList<>()); } - /** for testing */ String getServiceId() { - return serviceId; + // for testing + String getServiceId() { + return this.serviceId; } -} \ No newline at end of file + +} diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/EnableCloudFoundryClient.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/EnableCloudFoundryClient.java index 7142989..324d2a4 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/EnableCloudFoundryClient.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/EnableCloudFoundryClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,9 +26,10 @@ import java.lang.annotation.Target; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; /** - * Convenience annotation for clients to enable Cloud Foundry discovery configuration (specifically). - * Use this (optionally) in case you want discovery and know for sure that it is Cloud Foundry you want. - * All it does is turn on discovery and let the auto-configuration find the Cloud Foundry classes. + * Convenience annotation for clients to enable Cloud Foundry discovery configuration + * (specifically). Use this (optionally) in case you want discovery and know for sure that + * it is Cloud Foundry you want. All it does is turn on discovery and let the + * auto-configuration find the Cloud Foundry classes. * * @author Josh Long */ @@ -38,4 +39,5 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @Inherited @EnableDiscoveryClient public @interface EnableCloudFoundryClient { -} \ No newline at end of file + +} diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/RibbonCloudFoundryAutoConfiguration.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/RibbonCloudFoundryAutoConfiguration.java index 4e21a63..e191e09 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/RibbonCloudFoundryAutoConfiguration.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/RibbonCloudFoundryAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package org.springframework.cloud.cloudfoundry.discovery; +import com.netflix.client.IClient; + import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -26,8 +28,11 @@ import org.springframework.cloud.netflix.ribbon.RibbonClients; import org.springframework.cloud.netflix.ribbon.SpringClientFactory; import org.springframework.context.annotation.Configuration; -import com.netflix.client.IClient; - +/** + * Auto configuration for Ribbon. + * + * @author Josh Long + */ @Configuration @EnableConfigurationProperties @ConditionalOnClass(IClient.class) @@ -36,4 +41,5 @@ import com.netflix.client.IClient; @AutoConfigureAfter(RibbonAutoConfiguration.class) @RibbonClients(defaultConfiguration = CloudFoundryRibbonClientConfiguration.class) public class RibbonCloudFoundryAutoConfiguration { -} \ No newline at end of file + +} diff --git a/spring-cloud-cloudfoundry-discovery/src/main/resources/META-INF/spring.factories b/spring-cloud-cloudfoundry-discovery/src/main/resources/META-INF/spring.factories index 5b452c3..07b467a 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/resources/META-INF/spring.factories +++ b/spring-cloud-cloudfoundry-discovery/src/main/resources/META-INF/spring.factories @@ -1,6 +1,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ org.springframework.cloud.cloudfoundry.discovery.RibbonCloudFoundryAutoConfiguration - # Discovery Client Configuration org.springframework.cloud.client.discovery.EnableDiscoveryClient=\ org.springframework.cloud.cloudfoundry.discovery.CloudFoundryDiscoveryClientConfiguration diff --git a/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/AdhocTestSuite.java b/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/AdhocTestSuite.java index b70a263..d8e3368 100644 --- a/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/AdhocTestSuite.java +++ b/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/AdhocTestSuite.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.junit.runners.Suite.SuiteClasses; * @author Dave Syer */ @RunWith(Suite.class) -@SuiteClasses({CloudFoundryServerListTest.class}) +@SuiteClasses({ CloudFoundryServerListTest.class }) @Ignore public class AdhocTestSuite { diff --git a/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientTest.java b/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientTest.java index 2b3e853..3173b9d 100644 --- a/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientTest.java +++ b/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,9 @@ package org.springframework.cloud.cloudfoundry.discovery; +import java.util.List; +import java.util.UUID; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.cloudfoundry.operations.CloudFoundryOperations; @@ -23,20 +26,17 @@ import org.cloudfoundry.operations.applications.ApplicationDetail; import org.cloudfoundry.operations.applications.ApplicationSummary; import org.cloudfoundry.operations.applications.Applications; import org.cloudfoundry.operations.applications.InstanceDetail; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.cloudfoundry.CloudFoundryService; import reactor.core.publisher.Flux; import reactor.util.function.Tuple2; import reactor.util.function.Tuples; -import java.util.List; -import java.util.UUID; +import org.springframework.cloud.client.ServiceInstance; +import org.springframework.cloud.cloudfoundry.CloudFoundryService; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; /** @@ -45,60 +45,53 @@ import static org.mockito.Mockito.mock; public class CloudFoundryDiscoveryClientTest { private final Log log = LogFactory.getLog(getClass()); + private CloudFoundryDiscoveryClient cloudFoundryDiscoveryClient; + private String hiServiceServiceId = "hi-service"; + private CloudFoundryOperations ops; + private CloudFoundryService svc; @Before public void setUp() { this.ops = mock(CloudFoundryOperations.class); this.svc = mock(CloudFoundryService.class); - this.cloudFoundryDiscoveryClient = new CloudFoundryDiscoveryClient(this.ops, this.svc, - new CloudFoundryDiscoveryProperties()); + this.cloudFoundryDiscoveryClient = new CloudFoundryDiscoveryClient(this.ops, + this.svc, new CloudFoundryDiscoveryProperties()); } @Test public void testServiceResolution() { Applications apps = mock(Applications.class); ApplicationSummary s = ApplicationSummary.builder() - .id(UUID.randomUUID().toString()) - .instances(2) - .memoryLimit(1024) - .requestedState("requestedState") - .diskQuota(1024) - .name(this.hiServiceServiceId) - .runningInstances(2) - .build(); + .id(UUID.randomUUID().toString()).instances(2).memoryLimit(1024) + .requestedState("requestedState").diskQuota(1024) + .name(this.hiServiceServiceId).runningInstances(2).build(); Mockito.when(apps.list()).thenReturn(Flux.just(s)); Mockito.when(this.ops.applications()).thenReturn(apps); List serviceNames = this.cloudFoundryDiscoveryClient.getServices(); - Assert.assertTrue("there should be one registered service.", serviceNames.contains(this.hiServiceServiceId)); - serviceNames.forEach(serviceName -> this.log.debug("\t discovered serviceName: " + serviceName)); + assertThat(serviceNames.contains(this.hiServiceServiceId)) + .as("there should be one registered service.").isTrue(); + serviceNames.forEach(serviceName -> this.log + .debug("\t discovered serviceName: " + serviceName)); } @Test public void testInstances() { - ApplicationDetail applicationDetail = ApplicationDetail - .builder() - .instances(2) - .name("my-app") - .stack("stack") - .memoryLimit(1024) - .id("id") - .requestedState("requestedState") - .runningInstances(2) - .url("http://my-app.cfapps.io") - .diskQuota(20) - .build(); - InstanceDetail instanceDetail = InstanceDetail - .builder() - .index("0") - .build(); - Tuple2 tuple2 = Tuples.of(applicationDetail, instanceDetail); - Mockito.when(svc.getApplicationInstances(this.hiServiceServiceId)).thenReturn(Flux.just(tuple2)); + ApplicationDetail applicationDetail = ApplicationDetail.builder().instances(2) + .name("my-app").stack("stack").memoryLimit(1024).id("id") + .requestedState("requestedState").runningInstances(2) + .url("http://my-app.cfapps.io").diskQuota(20).build(); + InstanceDetail instanceDetail = InstanceDetail.builder().index("0").build(); + Tuple2 tuple2 = Tuples.of(applicationDetail, + instanceDetail); + Mockito.when(this.svc.getApplicationInstances(this.hiServiceServiceId)) + .thenReturn(Flux.just(tuple2)); List instances = this.cloudFoundryDiscoveryClient .getInstances(this.hiServiceServiceId); - assertEquals("Wrong instances: " + instances, 1, instances.size()); + assertThat(instances.size()).as("Wrong instances: " + instances).isEqualTo(1); } -} \ No newline at end of file + +} diff --git a/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServerListTest.java b/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServerListTest.java index 9474cc0..2347102 100644 --- a/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServerListTest.java +++ b/spring-cloud-cloudfoundry-discovery/src/test/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryServerListTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,36 +18,35 @@ package org.springframework.cloud.cloudfoundry.discovery; import java.util.List; +import com.netflix.client.config.CommonClientConfigKey; +import com.netflix.client.config.IClientConfig; import org.cloudfoundry.operations.applications.ApplicationDetail; import org.cloudfoundry.operations.applications.InstanceDetail; import org.junit.Before; import org.junit.Test; -import org.springframework.cloud.cloudfoundry.CloudFoundryService; +import reactor.core.publisher.Flux; +import reactor.util.function.Tuple2; +import reactor.util.function.Tuples; -import com.netflix.client.config.CommonClientConfigKey; -import com.netflix.client.config.IClientConfig; +import org.springframework.cloud.cloudfoundry.CloudFoundryService; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import reactor.core.publisher.Flux; -import reactor.util.function.Tuple2; -import reactor.util.function.Tuples; - /** * @author Josh Long */ public class CloudFoundryServerListTest { private CloudFoundryServerList cloudFoundryServerList; + private String serviceId = "foo-service"; @Before public void setUp() { IClientConfig iClientConfig = IClientConfig.Builder.newBuilder(this.serviceId) - .withSecure(true) - .build(); + .withSecure(true).build(); iClientConfig.set(CommonClientConfigKey.SecurePort, 443); Tuple2 tuple2 = getInstanceDetail(); @@ -55,7 +54,8 @@ public class CloudFoundryServerListTest { CloudFoundryService cfs = mock(CloudFoundryService.class); when(cfs.getApplicationInstances(this.serviceId)).thenReturn(Flux.just(tuple2)); - this.cloudFoundryServerList = new CloudFoundryServerList(cfs, new CloudFoundryDiscoveryProperties()); + this.cloudFoundryServerList = new CloudFoundryServerList(cfs, + new CloudFoundryDiscoveryProperties()); this.cloudFoundryServerList.initWithNiwsConfig(iClientConfig); } @@ -85,8 +85,10 @@ public class CloudFoundryServerListTest { @Test public void testListOfServers() { - List initialListOfServers = this.cloudFoundryServerList.getInitialListOfServers(); - List updatedListOfServers = this.cloudFoundryServerList.getUpdatedListOfServers(); + List initialListOfServers = this.cloudFoundryServerList + .getInitialListOfServers(); + List updatedListOfServers = this.cloudFoundryServerList + .getUpdatedListOfServers(); assertThat(initialListOfServers) .containsExactly(updatedListOfServers.toArray(new CloudFoundryServer[0])) .hasSize(1); @@ -105,7 +107,8 @@ public class CloudFoundryServerListTest { CloudFoundryService cfs = mock(CloudFoundryService.class); when(cfs.getApplicationInstances(this.serviceId)).thenReturn(Flux.just(tuple2)); - CloudFoundryServerList serverList = new CloudFoundryServerList(cfs, new CloudFoundryDiscoveryProperties()); + CloudFoundryServerList serverList = new CloudFoundryServerList(cfs, + new CloudFoundryDiscoveryProperties()); serverList.initWithNiwsConfig(iClientConfig); CloudFoundryServer server = serverList.getInitialListOfServers().get(0); diff --git a/spring-cloud-cloudfoundry-sample/hi-service.groovy b/spring-cloud-cloudfoundry-sample/hi-service.groovy index 05babba..a65e161 100644 --- a/spring-cloud-cloudfoundry-sample/hi-service.groovy +++ b/spring-cloud-cloudfoundry-sample/hi-service.groovy @@ -13,8 +13,8 @@ import org.springframework.web.bind.annotation.RestController @RestController class GreetingRestController { - @RequestMapping("/hi/{name}") - def hi(@PathVariable String name) { - [greeting: "Hello, " + name + "!"] - } -} \ No newline at end of file + @RequestMapping("/hi/{name}") + def hi(@PathVariable String name) { + [greeting: "Hello, " + name + "!"] + } +} diff --git a/spring-cloud-cloudfoundry-sample/pom.xml b/spring-cloud-cloudfoundry-sample/pom.xml index d766fa3..94b6b81 100644 --- a/spring-cloud-cloudfoundry-sample/pom.xml +++ b/spring-cloud-cloudfoundry-sample/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 spring-cloud-cloudfoundry-sample diff --git a/spring-cloud-cloudfoundry-sample/src/main/java/org/springframework/cloud/cloudfoundry/sample/CloudFoundryApplication.java b/spring-cloud-cloudfoundry-sample/src/main/java/org/springframework/cloud/cloudfoundry/sample/CloudFoundryApplication.java index 173a868..8f3cdc2 100644 --- a/spring-cloud-cloudfoundry-sample/src/main/java/org/springframework/cloud/cloudfoundry/sample/CloudFoundryApplication.java +++ b/spring-cloud-cloudfoundry-sample/src/main/java/org/springframework/cloud/cloudfoundry/sample/CloudFoundryApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.cloud.cloudfoundry.sample; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -26,22 +27,19 @@ import org.springframework.cloud.cloudfoundry.discovery.EnableCloudFoundryClient import org.springframework.context.annotation.Bean; /** - * This example uses the Spring Cloud {@code DiscoveryClient} abstraction to list all services - * available to the application. It should deployed to a Cloud Foundry organization and space that - * has other applications deployed to it. + * This example uses the Spring Cloud {@code DiscoveryClient} abstraction to list all + * services available to the application. It should deployed to a Cloud Foundry + * organization and space that has other applications deployed to it. * - * There is a sample file in the project root called {@code hi-service.groovy} which can be - * deployed using the {@code spring} CLI and the {@code cf} CLI that works appropriately for - * this example. + * There is a sample file in the project root called {@code hi-service.groovy} which can + * be deployed using the {@code spring} CLI and the {@code cf} CLI that works + * appropriately for this example. * - * Either modify this application's {@code application.yml} configuration file to provide credentials - * and other information for the Cloud Foundry the app is deployed to, or set the following - * environment variables on the application (using {@code cf set-env}): + * Either modify this application's {@code application.yml} configuration file to provide + * credentials and other information for the Cloud Foundry the app is deployed to, or set + * the following environment variables on the application (using {@code cf set-env}): * - * * {@code CF_USERNAME} - * * {@code CF_PASSWORD} - * * {@code CF_ORG} - * * {@code CF_SPACE} + * * {@code CF_USERNAME} * {@code CF_PASSWORD} * {@code CF_ORG} * {@code CF_SPACE} * * @author Josh Long * @author Spencer Gibb @@ -59,10 +57,11 @@ public class CloudFoundryApplication { @Bean CommandLineRunner demo(CloudFoundryDiscoveryClient discoveryClient) { Log log = LogFactory.getLog(getClass()); - return args -> - discoveryClient.getServices().forEach(svc -> { - log.info("service = " + svc); - discoveryClient.getInstances(svc).forEach(si -> log.info("\tinstance = " + si)); - }); + return args -> discoveryClient.getServices().forEach(svc -> { + log.info("service = " + svc); + discoveryClient.getInstances(svc) + .forEach(si -> log.info("\tinstance = " + si)); + }); } + } diff --git a/spring-cloud-cloudfoundry-sample/src/main/resources/application.yaml b/spring-cloud-cloudfoundry-sample/src/main/resources/application.yaml index c814d81..e1079d5 100644 --- a/spring-cloud-cloudfoundry-sample/src/main/resources/application.yaml +++ b/spring-cloud-cloudfoundry-sample/src/main/resources/application.yaml @@ -1,9 +1,9 @@ spring: - application: - name: test-app - cloud: - cloudfoundry: - username: ${CF_USERNAME:starbuxman@gmail.com} - password: ${CF_PASSWORD:xxxx} - org: ${CF_ORG:} - space: ${CF_SPACE:} \ No newline at end of file + application: + name: test-app + cloud: + cloudfoundry: + username: ${CF_USERNAME:starbuxman@gmail.com} + password: ${CF_PASSWORD:xxxx} + org: ${CF_ORG:} + space: ${CF_SPACE:} diff --git a/spring-cloud-cloudfoundry-sample/src/test/java/org/springframework/cloud/cloudfoundry/sample/CloudFoundryApplicationTests.java b/spring-cloud-cloudfoundry-sample/src/test/java/org/springframework/cloud/cloudfoundry/sample/CloudFoundryApplicationTests.java index 82dd1bb..8e0d64f 100644 --- a/spring-cloud-cloudfoundry-sample/src/test/java/org/springframework/cloud/cloudfoundry/sample/CloudFoundryApplicationTests.java +++ b/spring-cloud-cloudfoundry-sample/src/test/java/org/springframework/cloud/cloudfoundry/sample/CloudFoundryApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,11 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.cloud.cloudfoundry.sample; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; diff --git a/spring-cloud-cloudfoundry-web/pom.xml b/spring-cloud-cloudfoundry-web/pom.xml index 9e7babc..0fd306e 100644 --- a/spring-cloud-cloudfoundry-web/pom.xml +++ b/spring-cloud-cloudfoundry-web/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 spring-cloud-cloudfoundry-web diff --git a/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsEnvironmentPostProcessor.java b/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsEnvironmentPostProcessor.java index 847b4f0..7e97be6 100644 --- a/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsEnvironmentPostProcessor.java +++ b/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsEnvironmentPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.cloud.cloudfoundry.environment; import java.util.Collections; diff --git a/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/session/EnableStickyFilter.java b/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/session/EnableStickyFilter.java index 152e83c..7c0166f 100644 --- a/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/session/EnableStickyFilter.java +++ b/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/session/EnableStickyFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.cloud.cloudfoundry.session; import java.lang.annotation.Documented; @@ -33,4 +34,4 @@ import org.springframework.context.annotation.Import; @Import(StickyFilterConfiguration.class) public @interface EnableStickyFilter { -} \ No newline at end of file +} diff --git a/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/session/StickyFilterConfiguration.java b/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/session/StickyFilterConfiguration.java index 959964b..7dbd95c 100644 --- a/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/session/StickyFilterConfiguration.java +++ b/spring-cloud-cloudfoundry-web/src/main/java/org/springframework/cloud/cloudfoundry/session/StickyFilterConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.cloud.cloudfoundry.session; import java.io.IOException; @@ -52,7 +53,8 @@ public class StickyFilterConfiguration { HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (!response.containsHeader("Set-Cookie")) { - response.addCookie(new Cookie("JSESSIONID", cookie)); + response.addCookie(new Cookie("JSESSIONID", + StickyFilterConfiguration.this.cookie)); } filterChain.doFilter(request, response); } diff --git a/spring-cloud-cloudfoundry-web/src/main/resources/spring-cloud-cloudfoundry.properties b/spring-cloud-cloudfoundry-web/src/main/resources/spring-cloud-cloudfoundry.properties index 3e84a60..46a187d 100644 --- a/spring-cloud-cloudfoundry-web/src/main/resources/spring-cloud-cloudfoundry.properties +++ b/spring-cloud-cloudfoundry-web/src/main/resources/spring-cloud-cloudfoundry.properties @@ -1,2 +1,2 @@ spring.cloud.cloudfoundry.web.cookie=${random} -eureka.instance.metadata-map.cookie=${spring.cloud.cloudfoundry.web.cookie} \ No newline at end of file +eureka.instance.metadata-map.cookie=${spring.cloud.cloudfoundry.web.cookie} diff --git a/spring-cloud-cloudfoundry-web/src/test/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsEnvironmentPostProcessorTests.java b/spring-cloud-cloudfoundry-web/src/test/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsEnvironmentPostProcessorTests.java index b2f8375..0c48981 100644 --- a/spring-cloud-cloudfoundry-web/src/test/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsEnvironmentPostProcessorTests.java +++ b/spring-cloud-cloudfoundry-web/src/test/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsEnvironmentPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,20 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.cloud.cloudfoundry.environment; import java.util.Collections; import java.util.Map; import org.junit.Test; + import org.springframework.boot.SpringApplication; import org.springframework.boot.context.properties.bind.Binder; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.StandardEnvironment; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.cloud.cloudfoundry.environment.VcapServiceCredentialsEnvironmentPostProcessor.STRING_OBJECT_MAP; /** @@ -42,66 +43,85 @@ public class VcapServiceCredentialsEnvironmentPostProcessorTests { @Test public void noop() { this.listener.postProcessEnvironment(this.environment, new SpringApplication()); - Map properties = Binder.get(environment) - .bind("security.oauth2", STRING_OBJECT_MAP).orElseGet(Collections::emptyMap); - assertTrue(properties.isEmpty()); + Map properties = Binder.get(this.environment) + .bind("security.oauth2", STRING_OBJECT_MAP) + .orElseGet(Collections::emptyMap); + assertThat(properties.isEmpty()).isTrue(); } @Test public void addClientId() { - TestPropertyValues.of("vcap.services.sso.credentials.clientId:foo").applyTo(this.environment); + TestPropertyValues.of("vcap.services.sso.credentials.clientId:foo") + .applyTo(this.environment); this.listener.postProcessEnvironment(this.environment, new SpringApplication()); - assertEquals("foo", this.environment - .resolvePlaceholders("${security.oauth2.client.client-id}")); + assertThat(this.environment + .resolvePlaceholders("${security.oauth2.client.client-id}")) + .isEqualTo("foo"); } @Test public void addClientIdUnderscores() { - TestPropertyValues.of("vcap.services.sso.credentials.client-id:foo").applyTo(this.environment); + TestPropertyValues.of("vcap.services.sso.credentials.client-id:foo") + .applyTo(this.environment); this.listener.postProcessEnvironment(this.environment, new SpringApplication()); - assertEquals("foo", this.environment - .resolvePlaceholders("${security.oauth2.client.client-id}")); + assertThat(this.environment + .resolvePlaceholders("${security.oauth2.client.client-id}")) + .isEqualTo("foo"); } @Test public void addTokenUri() { - TestPropertyValues.of( "vcap.services.sso.credentials.accessTokenUri:http://example.com").applyTo(this.environment); + TestPropertyValues + .of("vcap.services.sso.credentials.accessTokenUri:http://example.com") + .applyTo(this.environment); this.listener.postProcessEnvironment(this.environment, new SpringApplication()); - assertEquals("http://example.com", this.environment - .resolvePlaceholders("${security.oauth2.client.access-token-uri}")); + assertThat(this.environment + .resolvePlaceholders("${security.oauth2.client.access-token-uri}")) + .isEqualTo("http://example.com"); } @Test public void addTokenUriAuthDomain() { - TestPropertyValues.of("vcap.services.sso.credentials.auth-domain:http://example.com").applyTo(this.environment); + TestPropertyValues + .of("vcap.services.sso.credentials.auth-domain:http://example.com") + .applyTo(this.environment); this.listener.postProcessEnvironment(this.environment, new SpringApplication()); - assertEquals("http://example.com/oauth/token", this.environment - .resolvePlaceholders("${security.oauth2.client.access-token-uri}")); + assertThat(this.environment + .resolvePlaceholders("${security.oauth2.client.access-token-uri}")) + .isEqualTo("http://example.com/oauth/token"); } @Test public void addUserInfoUri() { - TestPropertyValues.of( "vcap.services.sso.credentials.userInfoUri:http://example.com").applyTo(this.environment); + TestPropertyValues + .of("vcap.services.sso.credentials.userInfoUri:http://example.com") + .applyTo(this.environment); this.listener.postProcessEnvironment(this.environment, new SpringApplication()); - assertEquals("http://example.com", this.environment - .resolvePlaceholders("${security.oauth2.resource.user-info-uri}")); + assertThat(this.environment + .resolvePlaceholders("${security.oauth2.resource.user-info-uri}")) + .isEqualTo("http://example.com"); } @Test public void addServiceId() { - TestPropertyValues.of("vcap.services.my.credentials.accessTokenUri:http://example.com", - "security.oauth2.sso.serviceId:my").applyTo(this.environment); + TestPropertyValues + .of("vcap.services.my.credentials.accessTokenUri:http://example.com", + "security.oauth2.sso.serviceId:my") + .applyTo(this.environment); this.listener.postProcessEnvironment(this.environment, new SpringApplication()); - assertEquals("http://example.com", this.environment - .resolvePlaceholders("${security.oauth2.client.access-token-uri}")); + assertThat(this.environment + .resolvePlaceholders("${security.oauth2.client.access-token-uri}")) + .isEqualTo("http://example.com"); } @Test public void addJwtKeyUri() { - TestPropertyValues.of("vcap.services.sso.credentials.keyUri:http://example.com").applyTo(this.environment); + TestPropertyValues.of("vcap.services.sso.credentials.keyUri:http://example.com") + .applyTo(this.environment); this.listener.postProcessEnvironment(this.environment, new SpringApplication()); - assertEquals("http://example.com", this.environment - .resolvePlaceholders("${security.oauth2.resource.jwt.key-uri}")); + assertThat(this.environment + .resolvePlaceholders("${security.oauth2.resource.jwt.key-uri}")) + .isEqualTo("http://example.com"); } } diff --git a/spring-cloud-starter-cloudfoundry/pom.xml b/spring-cloud-starter-cloudfoundry/pom.xml index f49e124..693402b 100644 --- a/spring-cloud-starter-cloudfoundry/pom.xml +++ b/spring-cloud-starter-cloudfoundry/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 org.springframework.cloud diff --git a/spring-cloud-starter-cloudfoundry/src/main/resources/META-INF/spring.provides b/spring-cloud-starter-cloudfoundry/src/main/resources/META-INF/spring.provides index 15c5022..3ca5984 100644 --- a/spring-cloud-starter-cloudfoundry/src/main/resources/META-INF/spring.provides +++ b/spring-cloud-starter-cloudfoundry/src/main/resources/META-INF/spring.provides @@ -1 +1 @@ -provides: spring-cloud-security \ No newline at end of file +provides: spring-cloud-security