diff --git a/pom.xml b/pom.xml index f7d563e75b..2ece35cfeb 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ 6.1.0.202203080745-r 1 2.32.0 - 5.0.0 + 6.0.0-SNAPSHOT 5.8.2 5.8.2 @@ -94,6 +94,13 @@ pom import + + io.rest-assured + rest-assured-bom + ${rest-assured.version} + pom + import + org.springframework.cloud spring-cloud-function-compiler @@ -461,16 +468,6 @@ kotlin-compiler-embeddable ${contract.kotlin.version} - - io.rest-assured - rest-assured - ${rest-assured.version} - - - io.rest-assured - spring-mock-mvc - ${rest-assured.version} - @@ -604,6 +601,14 @@ false + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + true + + diff --git a/samples/standalone/.mvn/jvm.config b/samples/standalone/.mvn/jvm.config new file mode 100644 index 0000000000..0e7dabeff6 --- /dev/null +++ b/samples/standalone/.mvn/jvm.config @@ -0,0 +1 @@ +-Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom \ No newline at end of file diff --git a/samples/standalone/.mvn/maven.config b/samples/standalone/.mvn/maven.config new file mode 100644 index 0000000000..a682990566 --- /dev/null +++ b/samples/standalone/.mvn/maven.config @@ -0,0 +1 @@ +-P spring diff --git a/samples/standalone/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000000..b901097f2d --- /dev/null +++ b/samples/standalone/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/samples/standalone/.mvn/wrapper/maven-wrapper.jar b/samples/standalone/.mvn/wrapper/maven-wrapper.jar index c6feb8bb6f..c1dd12f176 100644 Binary files a/samples/standalone/.mvn/wrapper/maven-wrapper.jar and b/samples/standalone/.mvn/wrapper/maven-wrapper.jar differ diff --git a/samples/standalone/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/.mvn/wrapper/maven-wrapper.properties index 6637cedb28..015dfe6821 100644 --- a/samples/standalone/.mvn/wrapper/maven-wrapper.properties +++ b/samples/standalone/.mvn/wrapper/maven-wrapper.properties @@ -1 +1,18 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip \ No newline at end of file +# 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. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar diff --git a/samples/standalone/dsl/http-client/.mvn/jvm.config b/samples/standalone/dsl/http-client/.mvn/jvm.config index 894bef17a5..0e7dabeff6 100644 --- a/samples/standalone/dsl/http-client/.mvn/jvm.config +++ b/samples/standalone/dsl/http-client/.mvn/jvm.config @@ -1 +1 @@ --Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true \ No newline at end of file +-Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom \ No newline at end of file diff --git a/samples/standalone/dsl/http-client/.mvn/maven.config b/samples/standalone/dsl/http-client/.mvn/maven.config index affad39a42..a682990566 100644 --- a/samples/standalone/dsl/http-client/.mvn/maven.config +++ b/samples/standalone/dsl/http-client/.mvn/maven.config @@ -1 +1 @@ --T2 \ No newline at end of file +-P spring diff --git a/samples/standalone/dsl/http-client/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/dsl/http-client/.mvn/wrapper/MavenWrapperDownloader.java old mode 100755 new mode 100644 index 959fea7b14..b901097f2d --- a/samples/standalone/dsl/http-client/.mvn/wrapper/MavenWrapperDownloader.java +++ b/samples/standalone/dsl/http-client/.mvn/wrapper/MavenWrapperDownloader.java @@ -1,117 +1,117 @@ - /* -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 - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; import java.util.Properties; public class MavenWrapperDownloader { - /** - * 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.0/maven-wrapper-0.4.0.jar"; + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl - * property to use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties"; + /** + * Path 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"; + /** + * 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"; + /** + * 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()); + 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); + // 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); - } - } + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } - private static void downloadFileFromURL(String urlString, File destination) - throws Exception { - 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(); - } + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } } diff --git a/samples/standalone/dsl/http-client/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/dsl/http-client/.mvn/wrapper/maven-wrapper.properties old mode 100755 new mode 100644 diff --git a/samples/standalone/dsl/http-client/pom.xml.changeme b/samples/standalone/dsl/http-client/pom.xml similarity index 99% rename from samples/standalone/dsl/http-client/pom.xml.changeme rename to samples/standalone/dsl/http-client/pom.xml index 1adc22ac1f..e3e8d5eeaa 100644 --- a/samples/standalone/dsl/http-client/pom.xml.changeme +++ b/samples/standalone/dsl/http-client/pom.xml @@ -22,8 +22,7 @@ UTF-8 17 4.0.0-SNAPSHOT - - true + 6.0.0-SNAPSHOT diff --git a/samples/standalone/dsl/http-server/.mvn/jvm.config b/samples/standalone/dsl/http-server/.mvn/jvm.config index 894bef17a5..0e7dabeff6 100644 --- a/samples/standalone/dsl/http-server/.mvn/jvm.config +++ b/samples/standalone/dsl/http-server/.mvn/jvm.config @@ -1 +1 @@ --Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true \ No newline at end of file +-Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom \ No newline at end of file diff --git a/samples/standalone/dsl/http-server/.mvn/maven.config b/samples/standalone/dsl/http-server/.mvn/maven.config index 7681bc67b9..a682990566 100644 --- a/samples/standalone/dsl/http-server/.mvn/maven.config +++ b/samples/standalone/dsl/http-server/.mvn/maven.config @@ -1 +1 @@ --T2 +-P spring diff --git a/samples/standalone/dsl/http-server/build.gradle b/samples/standalone/dsl/http-server/build.gradle index b62fa49a03..7a6eab0042 100644 --- a/samples/standalone/dsl/http-server/build.gradle +++ b/samples/standalone/dsl/http-server/build.gradle @@ -19,6 +19,8 @@ repositories { } // end::deps_repos[] +ext['rest-assured.version'] = "${restAssuredVersion}" + dependencyManagement { imports { mavenBom "org.springframework.cloud:spring-cloud-dependencies:$BOM_VERSION" diff --git a/samples/standalone/dsl/http-server/gradle.properties b/samples/standalone/dsl/http-server/gradle.properties index 63169ab89f..0a869972d4 100644 --- a/samples/standalone/dsl/http-server/gradle.properties +++ b/samples/standalone/dsl/http-server/gradle.properties @@ -1,4 +1,5 @@ org.gradle.daemon=false verifierVersion=4.0.0-SNAPSHOT BOM_VERSION=2022.0.0-SNAPSHOT -bootVersion=3.0.0-SNAPSHOT \ No newline at end of file +bootVersion=3.0.0-SNAPSHOT +restAssuredVersion=6.0.0-SNAPSHOT diff --git a/samples/standalone/dsl/http-server/pom.xml.changeme b/samples/standalone/dsl/http-server/pom.xml similarity index 99% rename from samples/standalone/dsl/http-server/pom.xml.changeme rename to samples/standalone/dsl/http-server/pom.xml index 664adb8b20..f2e30da53d 100644 --- a/samples/standalone/dsl/http-server/pom.xml.changeme +++ b/samples/standalone/dsl/http-server/pom.xml @@ -22,8 +22,7 @@ UTF-8 17 4.0.0-SNAPSHOT - - true + 6.0.0-SNAPSHOT diff --git a/samples/standalone/mvnw b/samples/standalone/mvnw index 2c587685fe..5643201c7d 100755 --- a/samples/standalone/mvnw +++ b/samples/standalone/mvnw @@ -8,7 +8,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# https://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script +# Maven Start Up Batch script # # Required ENV vars: # ------------------ @@ -36,6 +36,10 @@ if [ -z "$MAVEN_SKIP_RC" ] ; then + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi @@ -46,15 +50,6 @@ if [ -z "$MAVEN_SKIP_RC" ] ; then fi -VERSION=$(awk '/ 0) {$0=$0} 1' `dirname $0`/pom.xml| grep '\(.*\)<.*/\1/') -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 - # OS specific support. $var _must_ be set to either true or false. cygwin=false; darwin=false; @@ -63,38 +58,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 @@ -139,13 +112,12 @@ if $cygwin ; then CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi -# For Migwn, ensure paths are in UNIX format before anything is touched +# For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then [ -n "$M2_HOME" ] && M2_HOME="`(cd "$M2_HOME"; pwd)`" [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? fi if [ -z "$JAVA_HOME" ]; then @@ -177,7 +149,7 @@ if [ -z "$JAVACMD" ] ; then JAVACMD="$JAVA_HOME/bin/java" fi else - JAVACMD="`which java`" + JAVACMD="`\\unset -f command; \\command -v java`" fi fi @@ -193,27 +165,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}" } @@ -225,9 +198,108 @@ concat_lines() { fi } -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" @@ -237,7 +309,8 @@ WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain exec "$JAVACMD" \ $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@" - + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/samples/standalone/mvnw.cmd b/samples/standalone/mvnw.cmd index 66e928bd13..23b7079a3d 100644 --- a/samples/standalone/mvnw.cmd +++ b/samples/standalone/mvnw.cmd @@ -1,145 +1,188 @@ -@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 https://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=%MAVEN_CONFIG% %* - -@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 - -%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 Maven 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 keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@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 by 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 "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\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/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +: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 "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\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% + +cmd /C exit /B %ERROR_CODE% diff --git a/samples/standalone/pom.xml b/samples/standalone/pom.xml index 0ade8f4722..6d2e7e600f 100644 --- a/samples/standalone/pom.xml +++ b/samples/standalone/pom.xml @@ -25,8 +25,8 @@ contracts restdocs - - webclient + dsl + diff --git a/samples/standalone/restdocs/http-client/.mvn/jvm.config b/samples/standalone/restdocs/http-client/.mvn/jvm.config index 894bef17a5..0e7dabeff6 100644 --- a/samples/standalone/restdocs/http-client/.mvn/jvm.config +++ b/samples/standalone/restdocs/http-client/.mvn/jvm.config @@ -1 +1 @@ --Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true \ No newline at end of file +-Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom \ No newline at end of file diff --git a/samples/standalone/restdocs/http-client/.mvn/maven.config b/samples/standalone/restdocs/http-client/.mvn/maven.config index affad39a42..a682990566 100644 --- a/samples/standalone/restdocs/http-client/.mvn/maven.config +++ b/samples/standalone/restdocs/http-client/.mvn/maven.config @@ -1 +1 @@ --T2 \ No newline at end of file +-P spring diff --git a/samples/standalone/restdocs/http-client/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/restdocs/http-client/.mvn/wrapper/MavenWrapperDownloader.java old mode 100755 new mode 100644 index 959fea7b14..b901097f2d --- a/samples/standalone/restdocs/http-client/.mvn/wrapper/MavenWrapperDownloader.java +++ b/samples/standalone/restdocs/http-client/.mvn/wrapper/MavenWrapperDownloader.java @@ -1,117 +1,117 @@ - /* -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 - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; import java.util.Properties; public class MavenWrapperDownloader { - /** - * 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.0/maven-wrapper-0.4.0.jar"; + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl - * property to use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties"; + /** + * Path 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"; + /** + * 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"; + /** + * 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()); + 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); + // 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); - } - } + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } - private static void downloadFileFromURL(String urlString, File destination) - throws Exception { - 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(); - } + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } } diff --git a/samples/standalone/restdocs/http-client/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/restdocs/http-client/.mvn/wrapper/maven-wrapper.properties old mode 100755 new mode 100644 diff --git a/samples/standalone/restdocs/http-client/pom.xml b/samples/standalone/restdocs/http-client/pom.xml index 6a4ddd6515..e3b7d452d2 100644 --- a/samples/standalone/restdocs/http-client/pom.xml +++ b/samples/standalone/restdocs/http-client/pom.xml @@ -39,8 +39,7 @@ UTF-8 17 4.0.0-SNAPSHOT - - true + 6.0.0-SNAPSHOT diff --git a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java b/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java index a8a6b2b6ca..bc2cdc6777 100644 --- a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java +++ b/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(properties = "service.port=${wiremock.server.port}") @AutoConfigureWireMock(port = 0) -public class LoanApplicationServiceTests { +class LoanApplicationServiceTests { @Autowired private LoanApplicationService service; @@ -55,7 +55,7 @@ public class LoanApplicationServiceTests { private WireMockServer server; @Test - public void shouldSuccessfullyApplyForLoan() throws Exception { + void shouldSuccessfullyApplyForLoan() throws Exception { server.addStubMapping(StubMapping.buildFrom(StreamUtils.copyToString( markClientAsNotFraud.getInputStream(), Charset.forName("UTF-8")))); // given: @@ -70,7 +70,7 @@ public class LoanApplicationServiceTests { } @Test - public void shouldBeRejectedDueToAbnormalLoanAmount() throws Exception { + void shouldBeRejectedDueToAbnormalLoanAmount() throws Exception { server.addStubMapping(StubMapping.buildFrom(StreamUtils.copyToString( markClientAsFraud.getInputStream(), Charset.forName("UTF-8")))); // given: diff --git a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/LoanApplicationServiceusingStubRunnerTests.java b/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/LoanApplicationServiceusingStubRunnerTests.java index 4a5a4b41f2..7398319c0f 100644 --- a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/LoanApplicationServiceusingStubRunnerTests.java +++ b/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/LoanApplicationServiceusingStubRunnerTests.java @@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @AutoConfigureStubRunner(ids = "com.example:http-server-restdocs") -public class LoanApplicationServiceusingStubRunnerTests { +class LoanApplicationServiceusingStubRunnerTests { @Autowired LoanApplicationService service; @@ -49,7 +49,7 @@ public class LoanApplicationServiceusingStubRunnerTests { } @Test - public void shouldSuccessfullyApplyForLoan() throws Exception { + void shouldSuccessfullyApplyForLoan() throws Exception { // given LoanApplication application = new LoanApplication(new Client("1234567890"), 123.123); @@ -62,7 +62,7 @@ public class LoanApplicationServiceusingStubRunnerTests { } @Test - public void shouldBeRejectedDueToAbnormalLoanAmount() throws Exception { + void shouldBeRejectedDueToAbnormalLoanAmount() throws Exception { // given: LoanApplication application = new LoanApplication(new Client("1234567890"), 99999); diff --git a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/XmlServiceTests.java b/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/XmlServiceTests.java index a8d3bb65a7..cf57d978f7 100644 --- a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/XmlServiceTests.java +++ b/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/XmlServiceTests.java @@ -40,7 +40,7 @@ import org.springframework.web.client.RestTemplate; @SpringBootTest(properties = "service.port=${wiremock.server.port}") @AutoConfigureWireMock(port = 0) -public class XmlServiceTests { +class XmlServiceTests { @Value("classpath:META-INF/com.example/http-server-restdocs/0.0.1/mappings/should_return_empty_content.json") private Resource empty; @@ -52,7 +52,7 @@ public class XmlServiceTests { private WireMockServer server; @Test - public void shouldSuccessfullyReturnFullResponse() throws Exception { + void shouldSuccessfullyReturnFullResponse() throws Exception { server.addStubMapping(StubMapping.buildFrom(StreamUtils .copyToString(full.getInputStream(), Charset.forName("UTF-8")))); @@ -68,7 +68,7 @@ public class XmlServiceTests { } @Test - public void shouldSuccessfullyReturnEmptyResponse() throws Exception { + void shouldSuccessfullyReturnEmptyResponse() throws Exception { server.addStubMapping(StubMapping.buildFrom(StreamUtils .copyToString(empty.getInputStream(), Charset.forName("UTF-8")))); diff --git a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/XmlServiceUsingStubRunnerTests.java b/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/XmlServiceUsingStubRunnerTests.java index 035f43ac55..68212120c7 100644 --- a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/XmlServiceUsingStubRunnerTests.java +++ b/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/XmlServiceUsingStubRunnerTests.java @@ -34,13 +34,13 @@ import org.springframework.web.client.RestTemplate; @SpringBootTest @AutoConfigureStubRunner(ids = "com.example:http-server-restdocs") -public class XmlServiceUsingStubRunnerTests { +class XmlServiceUsingStubRunnerTests { @Value("${stubrunner.runningstubs.http-server-restdocs.port}") int port; @Test - public void shouldSuccessfullyReturnFullResponse() throws Exception { + void shouldSuccessfullyReturnFullResponse() throws Exception { ResponseEntity responseEntity = new RestTemplate() .exchange(RequestEntity .post(URI.create("http://localhost:" + this.port + "/xmlfraud")) @@ -52,7 +52,7 @@ public class XmlServiceUsingStubRunnerTests { } @Test - public void shouldSuccessfullyReturnEmptyResponse() throws Exception { + void shouldSuccessfullyReturnEmptyResponse() throws Exception { ResponseEntity responseEntity = new RestTemplate() .exchange(RequestEntity .post(URI.create("http://localhost:" + this.port + "/xmlfraud")) diff --git a/samples/standalone/restdocs/http-server/.mvn/jvm.config b/samples/standalone/restdocs/http-server/.mvn/jvm.config index 894bef17a5..0e7dabeff6 100644 --- a/samples/standalone/restdocs/http-server/.mvn/jvm.config +++ b/samples/standalone/restdocs/http-server/.mvn/jvm.config @@ -1 +1 @@ --Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true \ No newline at end of file +-Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom \ No newline at end of file diff --git a/samples/standalone/restdocs/http-server/.mvn/maven.config b/samples/standalone/restdocs/http-server/.mvn/maven.config index 7681bc67b9..a682990566 100644 --- a/samples/standalone/restdocs/http-server/.mvn/maven.config +++ b/samples/standalone/restdocs/http-server/.mvn/maven.config @@ -1 +1 @@ --T2 +-P spring diff --git a/samples/standalone/restdocs/http-server/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/restdocs/http-server/.mvn/wrapper/MavenWrapperDownloader.java old mode 100755 new mode 100644 index 959fea7b14..b901097f2d --- a/samples/standalone/restdocs/http-server/.mvn/wrapper/MavenWrapperDownloader.java +++ b/samples/standalone/restdocs/http-server/.mvn/wrapper/MavenWrapperDownloader.java @@ -1,117 +1,117 @@ - /* -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 - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; import java.util.Properties; public class MavenWrapperDownloader { - /** - * 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.0/maven-wrapper-0.4.0.jar"; + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl - * property to use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties"; + /** + * Path 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"; + /** + * 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"; + /** + * 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()); + 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); + // 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); - } - } + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } - private static void downloadFileFromURL(String urlString, File destination) - throws Exception { - 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(); - } + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } } diff --git a/samples/standalone/restdocs/http-server/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/restdocs/http-server/.mvn/wrapper/maven-wrapper.properties old mode 100755 new mode 100644 diff --git a/samples/standalone/restdocs/http-server/build.gradle b/samples/standalone/restdocs/http-server/build.gradle index de20d29621..a8c4adc181 100644 --- a/samples/standalone/restdocs/http-server/build.gradle +++ b/samples/standalone/restdocs/http-server/build.gradle @@ -17,6 +17,8 @@ repositories { maven { url "https://repo.spring.io/release" } } +ext['rest-assured.version'] = "${restAssuredVersion}" + dependencyManagement { imports { mavenBom "org.springframework.cloud:spring-cloud-dependencies:${BOM_VERSION}" diff --git a/samples/standalone/restdocs/http-server/gradle.properties b/samples/standalone/restdocs/http-server/gradle.properties index 63169ab89f..0a869972d4 100644 --- a/samples/standalone/restdocs/http-server/gradle.properties +++ b/samples/standalone/restdocs/http-server/gradle.properties @@ -1,4 +1,5 @@ org.gradle.daemon=false verifierVersion=4.0.0-SNAPSHOT BOM_VERSION=2022.0.0-SNAPSHOT -bootVersion=3.0.0-SNAPSHOT \ No newline at end of file +bootVersion=3.0.0-SNAPSHOT +restAssuredVersion=6.0.0-SNAPSHOT diff --git a/samples/standalone/restdocs/http-server/pom.xml b/samples/standalone/restdocs/http-server/pom.xml index cd301afac1..488109e399 100644 --- a/samples/standalone/restdocs/http-server/pom.xml +++ b/samples/standalone/restdocs/http-server/pom.xml @@ -24,8 +24,7 @@ 4.0.0-SNAPSHOT true - - true + 6.0.0-SNAPSHOT @@ -210,7 +209,8 @@ - + + + <!– TODO: Remove –> -x test - + <!– TODO: Remove –> -x contractTest @@ -247,7 +247,7 @@ - + --> windows diff --git a/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/XmlStubGeneratorTests.java b/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/XmlStubGeneratorTests.java index 628ef802fb..610573ee41 100644 --- a/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/XmlStubGeneratorTests.java +++ b/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/XmlStubGeneratorTests.java @@ -25,7 +25,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; @@ -35,13 +34,13 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest(classes = Application.class) @AutoConfigureRestDocs(outputDir = "target/snippets") @AutoConfigureMockMvc -public class XmlStubGeneratorTests { +class XmlStubGeneratorTests { @Autowired private MockMvc mockMvc; @Test - public void should_return_full_content() throws Exception { + void should_return_full_content() throws Exception { mockMvc.perform(post("/xmlfraud").contentType(MediaType.APPLICATION_XML) .content("foo")) .andExpect(status().is2xxSuccessful()) @@ -51,7 +50,7 @@ public class XmlStubGeneratorTests { } @Test - public void should_return_empty_content() throws Exception { + void should_return_empty_content() throws Exception { mockMvc.perform(post("/xmlfraud").contentType(MediaType.APPLICATION_XML) .content("")) .andExpect(status().is2xxSuccessful()) diff --git a/samples/standalone/webclient/http-client/.mvn/jvm.config b/samples/standalone/webclient/http-client/.mvn/jvm.config index 894bef17a5..0e7dabeff6 100644 --- a/samples/standalone/webclient/http-client/.mvn/jvm.config +++ b/samples/standalone/webclient/http-client/.mvn/jvm.config @@ -1 +1 @@ --Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true \ No newline at end of file +-Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom \ No newline at end of file diff --git a/samples/standalone/webclient/http-client/.mvn/maven.config b/samples/standalone/webclient/http-client/.mvn/maven.config index affad39a42..a682990566 100644 --- a/samples/standalone/webclient/http-client/.mvn/maven.config +++ b/samples/standalone/webclient/http-client/.mvn/maven.config @@ -1 +1 @@ --T2 \ No newline at end of file +-P spring diff --git a/samples/standalone/webclient/http-client/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/webclient/http-client/.mvn/wrapper/MavenWrapperDownloader.java old mode 100755 new mode 100644 index 959fea7b14..b901097f2d --- a/samples/standalone/webclient/http-client/.mvn/wrapper/MavenWrapperDownloader.java +++ b/samples/standalone/webclient/http-client/.mvn/wrapper/MavenWrapperDownloader.java @@ -1,117 +1,117 @@ - /* -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 - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; import java.util.Properties; public class MavenWrapperDownloader { - /** - * 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.0/maven-wrapper-0.4.0.jar"; + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl - * property to use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties"; + /** + * Path 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"; + /** + * 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"; + /** + * 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()); + 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); + // 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); - } - } + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } - private static void downloadFileFromURL(String urlString, File destination) - throws Exception { - 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(); - } + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } } diff --git a/samples/standalone/webclient/http-client/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/webclient/http-client/.mvn/wrapper/maven-wrapper.properties old mode 100755 new mode 100644 diff --git a/samples/standalone/webclient/http-client/pom.xml b/samples/standalone/webclient/http-client/pom.xml index 99d14feba0..16b5dfc905 100644 --- a/samples/standalone/webclient/http-client/pom.xml +++ b/samples/standalone/webclient/http-client/pom.xml @@ -22,8 +22,6 @@ UTF-8 17 4.0.0-SNAPSHOT - - true diff --git a/samples/standalone/webclient/http-server/.mvn/jvm.config b/samples/standalone/webclient/http-server/.mvn/jvm.config index 894bef17a5..0e7dabeff6 100644 --- a/samples/standalone/webclient/http-server/.mvn/jvm.config +++ b/samples/standalone/webclient/http-server/.mvn/jvm.config @@ -1 +1 @@ --Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true \ No newline at end of file +-Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom \ No newline at end of file diff --git a/samples/standalone/webclient/http-server/.mvn/maven.config b/samples/standalone/webclient/http-server/.mvn/maven.config index 7681bc67b9..a682990566 100644 --- a/samples/standalone/webclient/http-server/.mvn/maven.config +++ b/samples/standalone/webclient/http-server/.mvn/maven.config @@ -1 +1 @@ --T2 +-P spring diff --git a/samples/standalone/webclient/http-server/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/webclient/http-server/.mvn/wrapper/MavenWrapperDownloader.java old mode 100755 new mode 100644 index 959fea7b14..b901097f2d --- a/samples/standalone/webclient/http-server/.mvn/wrapper/MavenWrapperDownloader.java +++ b/samples/standalone/webclient/http-server/.mvn/wrapper/MavenWrapperDownloader.java @@ -1,117 +1,117 @@ - /* -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 - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; import java.util.Properties; public class MavenWrapperDownloader { - /** - * 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.0/maven-wrapper-0.4.0.jar"; + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl - * property to use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties"; + /** + * Path 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"; + /** + * 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"; + /** + * 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()); + 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); + // 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); - } - } + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } - private static void downloadFileFromURL(String urlString, File destination) - throws Exception { - 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(); - } + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } } diff --git a/samples/standalone/webclient/http-server/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/webclient/http-server/.mvn/wrapper/maven-wrapper.properties old mode 100755 new mode 100644 diff --git a/samples/standalone/webclient/http-server/build.gradle b/samples/standalone/webclient/http-server/build.gradle index 5c2efeae1c..fe3e6c0615 100644 --- a/samples/standalone/webclient/http-server/build.gradle +++ b/samples/standalone/webclient/http-server/build.gradle @@ -23,6 +23,8 @@ repositories { maven { url "https://repo.spring.io/release" } } +ext['rest-assured.version'] = "${restAssuredVersion}" + dependencyManagement { imports { mavenBom "org.springframework.cloud:spring-cloud-dependencies:${BOM_VERSION}" diff --git a/samples/standalone/webclient/http-server/gradle.properties b/samples/standalone/webclient/http-server/gradle.properties index 63169ab89f..0a869972d4 100644 --- a/samples/standalone/webclient/http-server/gradle.properties +++ b/samples/standalone/webclient/http-server/gradle.properties @@ -1,4 +1,5 @@ org.gradle.daemon=false verifierVersion=4.0.0-SNAPSHOT BOM_VERSION=2022.0.0-SNAPSHOT -bootVersion=3.0.0-SNAPSHOT \ No newline at end of file +bootVersion=3.0.0-SNAPSHOT +restAssuredVersion=6.0.0-SNAPSHOT diff --git a/samples/standalone/webclient/http-server/pom.xml b/samples/standalone/webclient/http-server/pom.xml index 995a18659d..2a7070567d 100644 --- a/samples/standalone/webclient/http-server/pom.xml +++ b/samples/standalone/webclient/http-server/pom.xml @@ -22,8 +22,7 @@ UTF-8 17 4.0.0-SNAPSHOT - - true + 6.0.0-SNAPSHOT diff --git a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/CompositeContractTemplate.java b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/CompositeContractTemplate.java index 973ec52d75..27cd59ccd4 100644 --- a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/CompositeContractTemplate.java +++ b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/CompositeContractTemplate.java @@ -27,15 +27,10 @@ import org.springframework.cloud.contract.spec.ContractTemplate; */ public class CompositeContractTemplate implements ContractTemplate { - private final CustomHandlebarsContractTemplate custom = new CustomHandlebarsContractTemplate(); - private final HandlebarsContractTemplate template = new HandlebarsContractTemplate(); @Override public boolean startsWithTemplate(String text) { - if (this.custom.startsWithTemplate(text)) { - return true; - } return template.startsWithTemplate(text); } @@ -113,7 +108,7 @@ public class CompositeContractTemplate implements ContractTemplate { public String escapedBody() { // WireMock doesn't support proper escaping of JSON body // that's why we need to use our custom handlebars extension - return this.custom.escapedBody(); + return this.template.escapedBody(); } @Override diff --git a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/CustomHandlebarsContractTemplate.java b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/CustomHandlebarsContractTemplate.java deleted file mode 100644 index 5c8c0933b0..0000000000 --- a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/CustomHandlebarsContractTemplate.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2013-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.contract.spec.internal; - -import org.springframework.cloud.contract.spec.ContractTemplate; - -/** - * Represents the structure of templates using Handlebars compatible with WireMock - * template model requirements. - * - * @author Marcin Grzejszczak - * @since 1.1.0* - * @deprecated use {@link HandlebarsContractTemplate} - */ -class CustomHandlebarsContractTemplate implements ContractTemplate { - - @Override - public String openingTemplate() { - return "{{{"; - } - - @Override - public String closingTemplate() { - return "}}}"; - } - - @Override - public String url() { - return wrapped("request.url"); - } - - @Override - public String query(String key) { - return query(key, 0); - } - - @Override - public String query(String key, int index) { - return wrapped("request.query." + key + ".[" + index + "]"); - } - - @Override - public String path() { - return wrapped("request.path"); - } - - @Override - public String path(int index) { - return wrapped("request.path.[" + index + "]"); - } - - @Override - public String header(String key) { - return header(key, 0); - } - - @Override - public String header(String key, int index) { - return wrapped("request.headers." + key + ".[" + index + "]"); - } - - @Override - public String cookie(String key) { - return wrapped("request.cookies." + key); - } - - @Override - public String body() { - return wrapped("request.body"); - } - - @Override - public String escapedBody() { - return wrapped("escapejsonbody"); - } - - @Override - public String escapedBody(String jsonPath) { - return body(jsonPath); - } - - @Override - public String body(String jsonPath) { - return wrapped("jsonpath this \'" + jsonPath + "\'"); - } - - private String wrapped(String text) { - return openingTemplate() + text + closingTemplate(); - } - -} diff --git a/spring-cloud-contract-stub-runner/pom.xml b/spring-cloud-contract-stub-runner/pom.xml index 9f46fe8a0b..edd0567b35 100644 --- a/spring-cloud-contract-stub-runner/pom.xml +++ b/spring-cloud-contract-stub-runner/pom.xml @@ -183,7 +183,6 @@ io.rest-assured spring-mock-mvc - ${rest-assured.version} test diff --git a/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/loadbalancer/SpringCloudLoadBalancerAutoConfiguration.java b/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/loadbalancer/SpringCloudLoadBalancerAutoConfiguration.java index 3376643d95..feb5d99e64 100644 --- a/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/loadbalancer/SpringCloudLoadBalancerAutoConfiguration.java +++ b/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/loadbalancer/SpringCloudLoadBalancerAutoConfiguration.java @@ -85,15 +85,6 @@ class StubRunnerLoadBalancerClientFactory extends LoadBalancerClientFactory impl private final BeanFactory beanFactory; - /** - * @deprecated in favour of - * {@link StubRunnerLoadBalancerClientFactory#StubRunnerLoadBalancerClientFactory(BeanFactory, LoadBalancerClientsProperties)} - */ - @Deprecated - StubRunnerLoadBalancerClientFactory(BeanFactory beanFactory) { - this.beanFactory = beanFactory; - } - StubRunnerLoadBalancerClientFactory(BeanFactory beanFactory, LoadBalancerClientsProperties properties) { super(properties); this.beanFactory = beanFactory; diff --git a/spring-cloud-contract-stub-runner/src/main/resources/META-INF/spring.factories b/spring-cloud-contract-stub-runner/src/main/resources/META-INF/spring.factories index f9d0bf1d28..c72d5a579c 100644 --- a/spring-cloud-contract-stub-runner/src/main/resources/META-INF/spring.factories +++ b/spring-cloud-contract-stub-runner/src/main/resources/META-INF/spring.factories @@ -7,7 +7,6 @@ org.springframework.cloud.contract.stubrunner.messaging.integration.StubRunnerIn org.springframework.cloud.contract.stubrunner.messaging.jms.StubRunnerJmsConfiguration,\ org.springframework.cloud.contract.stubrunner.messaging.stream.StubRunnerStreamConfiguration,\ org.springframework.cloud.contract.stubrunner.spring.cloud.zookeeper.StubRunnerSpringCloudZookeeperAutoConfiguration,\ -org.springframework.cloud.contract.stubrunner.spring.cloud.eureka.StubRunnerSpringCloudEurekaAutoConfiguration,\ org.springframework.cloud.contract.stubrunner.spring.cloud.consul.StubRunnerSpringCloudConsulAutoConfiguration,\ org.springframework.cloud.contract.stubrunner.messaging.StubRunnerStreamsIntegrationAutoConfiguration,\ org.springframework.cloud.contract.stubrunner.messaging.camel.StubRunnerCamelConfiguration diff --git a/spring-cloud-contract-tools/spring-cloud-contract-converters/pom.xml b/spring-cloud-contract-tools/spring-cloud-contract-converters/pom.xml index dde98593f5..50bd812662 100644 --- a/spring-cloud-contract-tools/spring-cloud-contract-converters/pom.xml +++ b/spring-cloud-contract-tools/spring-cloud-contract-converters/pom.xml @@ -79,7 +79,6 @@ io.rest-assured rest-assured - ${rest-assured.version} test diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/main/java/org/springframework/cloud/contract/verifier/plugin/ContractVerifierExtension.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/main/java/org/springframework/cloud/contract/verifier/plugin/ContractVerifierExtension.java index dca9ef283e..d79d940a90 100644 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/main/java/org/springframework/cloud/contract/verifier/plugin/ContractVerifierExtension.java +++ b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/main/java/org/springframework/cloud/contract/verifier/plugin/ContractVerifierExtension.java @@ -100,12 +100,6 @@ public class ContractVerifierExtension implements Serializable { */ private final DirectoryProperty contractsDslDir; - /** - * Test source directory where tests generated from Groovy DSL should be placed - */ - @Deprecated - private final DirectoryProperty generatedTestSourcesDir; - /** * Java test source directory where tests generated from Contract DSL should be placed */ @@ -220,14 +214,6 @@ public class ContractVerifierExtension implements Serializable { */ private final MapProperty contractsProperties; - /** - * Is set to true will not provide the default publication task - * @deprecated - with 3.0.0, the user should include stubs with their own - * publication(s) - */ - @Deprecated - private final Property disableStubPublication; - /** * Source set where the contracts are stored. If not provided will assume * {@code test}. @@ -248,7 +234,6 @@ public class ContractVerifierExtension implements Serializable { this.staticImports = objects.listProperty(String.class).convention(new ArrayList<>()); this.contractsDslDir = objects.directoryProperty() .convention(layout.getProjectDirectory().dir("src/contractTest/resources/contracts")); - this.generatedTestSourcesDir = objects.directoryProperty(); this.generatedTestJavaSourcesDir = objects.directoryProperty() .convention(layout.getBuildDirectory().dir("generated-test-sources/contractTest/java")); this.generatedTestGroovySourcesDir = objects.directoryProperty() @@ -272,7 +257,6 @@ public class ContractVerifierExtension implements Serializable { this.deleteStubsAfterTest = objects.property(Boolean.class).convention(true); this.convertToYaml = objects.property(Boolean.class).convention(false); this.contractsProperties = objects.mapProperty(String.class, String.class).convention(new HashMap<>()); - this.disableStubPublication = objects.property(Boolean.class).convention(true); this.sourceSet = objects.property(String.class); } @@ -380,16 +364,6 @@ public class ContractVerifierExtension implements Serializable { this.contractsDslDir.set(contractsDslDir); } - @Deprecated - public DirectoryProperty getGeneratedTestSourcesDir() { - return generatedTestSourcesDir; - } - - @Deprecated - public void setGeneratedTestSourcesDir(File generatedTestSourcesDir) { - this.generatedTestSourcesDir.set(generatedTestSourcesDir); - } - public DirectoryProperty getGeneratedTestJavaSourcesDir() { return generatedTestJavaSourcesDir; } @@ -550,16 +524,6 @@ public class ContractVerifierExtension implements Serializable { this.contractsProperties.set(contractsProperties); } - @Deprecated - public Property getDisableStubPublication() { - return disableStubPublication; - } - - @Deprecated - public void setDisableStubPublication(boolean disableStubPublication) { - this.disableStubPublication.set(disableStubPublication); - } - public Property getSourceSet() { return sourceSet; } diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/main/java/org/springframework/cloud/contract/verifier/plugin/SpringCloudContractVerifierGradlePlugin.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/main/java/org/springframework/cloud/contract/verifier/plugin/SpringCloudContractVerifierGradlePlugin.java index 8c52c12d25..07fe414ebb 100644 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/main/java/org/springframework/cloud/contract/verifier/plugin/SpringCloudContractVerifierGradlePlugin.java +++ b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/main/java/org/springframework/cloud/contract/verifier/plugin/SpringCloudContractVerifierGradlePlugin.java @@ -110,16 +110,18 @@ public class SpringCloudContractVerifierGradlePlugin implements Plugin project.getDependencies().add(CONTRACT_TEST_GENERATOR_RUNTIME_CLASSPATH_CONFIGURATION_NAME, "org.springframework.cloud:spring-cloud-contract-converters:" + SPRING_CLOUD_VERSION); project.afterEvaluate(inner -> { - DirectoryProperty generatedTestSourcesDir = extension.getGeneratedTestSourcesDir(); - if (generatedTestSourcesDir.isPresent()) { - if (extension.getTestFramework().get() == TestFramework.SPOCK) { + if (extension.getTestFramework().get() == TestFramework.SPOCK) { + DirectoryProperty generatedTestSourcesDir = extension.getGeneratedTestGroovySourcesDir(); + if (generatedTestSourcesDir.isPresent()) { project.getPlugins().withType(GroovyPlugin.class, groovyPlugin -> { GroovySourceSet groovy = ((HasConvention) contractTestSourceSet).getConvention() .getPlugin(GroovySourceSet.class); groovy.getGroovy().srcDirs(generatedTestSourcesDir); }); } - else { + } else { + DirectoryProperty generatedTestSourcesDir = extension.getGeneratedTestJavaSourcesDir(); + if (generatedTestSourcesDir.isPresent()) { contractTestSourceSet.getJava().srcDirs(generatedTestSourcesDir); } } @@ -222,11 +224,12 @@ public class SpringCloudContractVerifierGradlePlugin implements Plugin Property correctSourceSetDir; if (testFramework == TestFramework.SPOCK) { correctSourceSetDir = extension.getGeneratedTestGroovySourcesDir(); + return extension.getGeneratedTestGroovySourcesDir().orElse(correctSourceSetDir); } else { correctSourceSetDir = extension.getGeneratedTestJavaSourcesDir(); + return extension.getGeneratedTestJavaSourcesDir().orElse(correctSourceSetDir); } - return extension.getGeneratedTestSourcesDir().orElse(correctSourceSetDir); })); generateServerTestsTask.getGeneratedTestResourcesDir().convention(extension.getGeneratedTestResourcesDir()); @@ -320,58 +323,6 @@ public class SpringCloudContractVerifierGradlePlugin implements Plugin stubsJar.dependsOn(generateClientStubs); }); project.artifacts(artifactHandler -> artifactHandler.add("archives", verifierStubsJar)); - createAndConfigureMavenPublishPlugin(verifierStubsJar, extension); - } - - @Deprecated - private void createAndConfigureMavenPublishPlugin(TaskProvider stubsTask, - ContractVerifierExtension extension) { - if (!classIsOnClasspath("org.gradle.api.publish.maven.plugins.MavenPublishPlugin")) { - project.getLogger().debug("Maven Publish Plugin is not present - won't add default publication"); - return; - } - // This must be called within afterEvaluate due to getting data from extension, - // which must be initialised first: - project.afterEvaluate(inner -> { - project.getLogger().debug("Spring Cloud Contract Verifier Plugin: Generating default publication"); - if (extension.getDisableStubPublication().get()) { - project.getLogger().info("You've switched off the stub publication - won't add default publication"); - return; - } - project.getPlugins().withType(MavenPublishPlugin.class, publishingPlugin -> { - PublishingExtension publishingExtension = project.getExtensions().findByType(PublishingExtension.class); - if (hasStubsPublication(publishingExtension)) { - project.getLogger().info( - "Spring Cloud Contract Verifier Plugin: Stubs publication was present - won't create a new one. Remember about passing stubs as artifact"); - } - else { - project.getLogger().debug( - "Spring Cloud Contract Verifier Plugin: Stubs publication is not present - will create one"); - setPublications(publishingExtension, stubsTask); - } - }); - }); - } - - @Deprecated - private void setPublications(PublishingExtension publishingExtension, TaskProvider stubsTask) { - project.getLogger().warn("Spring Cloud Contract Verifier Plugin: Creating stubs publication is deprecated"); - publishingExtension.publications(publicationsContainer -> { - publicationsContainer.create("stubs", MavenPublication.class, stubsPublication -> { - stubsPublication.setArtifactId(project.getName()); - stubsPublication.artifact(stubsTask.get()); - }); - }); - } - - @Deprecated - private boolean hasStubsPublication(PublishingExtension publishingExtension) { - try { - return publishingExtension.getPublications().getByName("stubs") != null; - } - catch (Exception e) { - return false; - } } private TaskProvider createAndConfigureCopyContractsTask(ContractVerifierExtension extension) { @@ -438,18 +389,6 @@ public class SpringCloudContractVerifierGradlePlugin implements Plugin return task; } - @Deprecated - private boolean classIsOnClasspath(String className) { - try { - Class.forName(className); - return true; - } - catch (Exception e) { - project.getLogger().debug("Maven Publish Plugin is not available"); - } - return false; - } - private Provider buildRootPath(String path) { return project.provider(() -> { StringBuilder builder = new StringBuilder(); diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/groovy/org/springframework/cloud/contract/verifier/plugin/ContractVerifierTest.groovy b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/groovy/org/springframework/cloud/contract/verifier/plugin/ContractVerifierTest.groovy index 77ff534603..c004a5a09d 100644 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/groovy/org/springframework/cloud/contract/verifier/plugin/ContractVerifierTest.groovy +++ b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/groovy/org/springframework/cloud/contract/verifier/plugin/ContractVerifierTest.groovy @@ -134,28 +134,6 @@ class ContractVerifierTest { assert project.tasks.compileContractTestGroovy.getDependsOn().contains(project.tasks.named("generateContractTests")) } - @Test - void "should configure generatedTestSourcesDir with the appropriate directories"() { - when: - ContractVerifierExtension extension = project.extensions.findByType(ContractVerifierExtension) - GenerateServerTestsTask generateServerTestsTask = project.tasks.getByName("generateContractTests") as GenerateServerTestsTask - - then: - assert generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestJavaSourcesDir.get().asFile - - and: - extension.testFramework.set(TestFramework.SPOCK) - - then: - assert generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestGroovySourcesDir.get().asFile - - and: - extension.generatedTestSourcesDir.set(project.file("src/random")) - - then: - assert generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestSourcesDir.get().asFile - } - @Test void "should create generateClientStubs task"() { expect: @@ -192,32 +170,6 @@ class ContractVerifierTest { assert project.tasks.verifierStubsJar.getDependsOn().contains(project.tasks.named("generateClientStubs")) } - /** - * project.evaluate() is used here in order to trigger the evaluation lifecycle of a project. - * This method is currently exposed via the internal API and is subject to change, however, Gradle - * does not yet expose a way to test this portion of the lifecycle. - * - * In the next version, this test will be completely removed as publication will be fully a user - * responsibility. - */ - @Deprecated - @Test - void "should configure maven-publish plugin, if enabled"() { - given: - project.plugins.apply(MavenPublishPlugin) - project.plugins.apply(SpringCloudContractVerifierGradlePlugin) - ContractVerifierExtension extension = project.getExtensions().findByType(ContractVerifierExtension) - extension.with { - disableStubPublication = false - } - project.evaluate() // Currently internal method to trigger afterEvaluate blocks. - - expect: - PublicationContainer publications = project.extensions.getByType(PublishingExtension).publications - assert publications.size() > 0 - assert publications.named("stubs") != null - } - @Test void "should compile"() { given: diff --git a/spring-cloud-contract-verifier/pom.xml b/spring-cloud-contract-verifier/pom.xml index 0924151d26..49e36fd754 100644 --- a/spring-cloud-contract-verifier/pom.xml +++ b/spring-cloud-contract-verifier/pom.xml @@ -218,19 +218,16 @@ io.rest-assured rest-assured - ${rest-assured.version} test io.rest-assured spring-mock-mvc - ${rest-assured.version} test io.rest-assured spring-web-test-client - ${rest-assured.version} test diff --git a/spring-cloud-contract-verifier/src/main/groovy/org/springframework/cloud/contract/verifier/util/JsonToJsonPathsConverter.groovy b/spring-cloud-contract-verifier/src/main/groovy/org/springframework/cloud/contract/verifier/util/JsonToJsonPathsConverter.groovy index 460edae2a8..82a8f8f776 100644 --- a/spring-cloud-contract-verifier/src/main/groovy/org/springframework/cloud/contract/verifier/util/JsonToJsonPathsConverter.groovy +++ b/spring-cloud-contract-verifier/src/main/groovy/org/springframework/cloud/contract/verifier/util/JsonToJsonPathsConverter.groovy @@ -62,12 +62,6 @@ class JsonToJsonPathsConverter { private final boolean assertJsonSize - // Use constructor with dedicated input param instead - @Deprecated - JsonToJsonPathsConverter(ContractVerifierConfigProperties configProperties) { - assertJsonSize = configProperties.assertJsonSize - } - JsonToJsonPathsConverter(boolean assertJsonSize) { this.assertJsonSize = assertJsonSize } diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/file/ContractFileScanner.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/file/ContractFileScanner.java index d3a2bdff15..0a5921126b 100644 --- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/file/ContractFileScanner.java +++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/file/ContractFileScanner.java @@ -108,130 +108,6 @@ public class ContractFileScanner { return pathMatchers; } - /** - * @return for a map of paths for which a list of matching contracts has been found - * @deprecated use the {@link ContractFileScanner#findContractsRecursively} version - */ - @Deprecated - public ListMultimap findContracts() { - MultiValueMap contracts = findContractsRecursively(); - return new ListMultimap() { - @Override - public List get(Path key) { - return contracts.get(key); - } - - @Override - public List removeAll(Object key) { - return contracts.remove(key); - } - - @Override - public List replaceValues(Path key, Iterable values) { - return contracts.put(key, asList(values)); - } - - List asList(Iterable self) { - if (self instanceof List) { - return (List) self; - } - else { - return toList(self.iterator()); - } - } - - private List toList(Iterator self) { - List answer = new ArrayList<>(); - while (self.hasNext()) { - answer.add(self.next()); - } - return answer; - } - - @Override - public Map> asMap() { - return contracts.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - } - - @Override - public int size() { - return contracts.size(); - } - - @Override - public boolean isEmpty() { - return contracts.isEmpty(); - } - - @Override - public boolean containsKey(Object key) { - return contracts.containsKey(key); - } - - @Override - public boolean containsValue(Object value) { - return contracts.entrySet().stream().anyMatch(it -> it.getValue().contains(value)); - } - - @Override - public boolean containsEntry(Object key, Object value) { - return contracts.entrySet().stream() - .anyMatch(it -> it.getKey().equals(key) && it.getValue().contains(value)); - } - - @Override - public boolean put(Path key, ContractMetadata value) { - contracts.add(key, value); - return true; - } - - @Override - public boolean remove(Object key, Object value) { - return contracts.getOrDefault(key, new ArrayList<>()).remove(value); - } - - @Override - public boolean putAll(Path key, Iterable values) { - return contracts.getOrDefault(key, new ArrayList<>()) - .addAll(StreamSupport.stream(values.spliterator(), false).collect(Collectors.toList())); - } - - @Override - public boolean putAll(Multimap multimap) { - multimap.entries().forEach(it -> contracts.add(it.getKey(), it.getValue())); - return true; - } - - @Override - public void clear() { - contracts.clear(); - } - - @Override - public Set keySet() { - return contracts.keySet(); - } - - @Override - public Multiset keys() { - return HashMultiset.create(contracts.keySet()); - } - - @Override - public Collection values() { - return contracts.values().stream().flatMap(Collection::stream).collect(Collectors.toList()); - } - - @Override - public Collection> entries() { - Collection> entries = new LinkedList<>(); - contracts.forEach( - (path, list) -> list.forEach(c -> entries.add(new AbstractMap.SimpleEntry<>(path, c)))); - return entries; - } - }; - } - public MultiValueMap findContractsRecursively() { MultiValueMap result = CollectionUtils.toMultiValueMap(new LinkedHashMap<>()); appendRecursively(baseDir, result); diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/util/ContractVerifierDslConverter.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/util/ContractVerifierDslConverter.java index f483eb3091..a4babc3579 100644 --- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/util/ContractVerifierDslConverter.java +++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/util/ContractVerifierDslConverter.java @@ -67,25 +67,6 @@ public class ContractVerifierDslConverter implements ContractConverter convertAsCollection(String dsl) { - try { - Object object = groovyShell().evaluate(dsl); - return listOfContracts(object); - } - catch (DslParseException e) { - throw e; - } - catch (Exception e) { - LOG.error("Exception occurred while trying to evaluate the contract", e); - throw new DslParseException(e); - } - } - public static Collection convertAsCollection(File rootFolder, String dsl) { ClassLoader classLoader = ContractVerifierDslConverter.class.getClassLoader(); try { diff --git a/spring-cloud-contract-wiremock/pom.xml b/spring-cloud-contract-wiremock/pom.xml index 2803b51d96..ada8352823 100644 --- a/spring-cloud-contract-wiremock/pom.xml +++ b/spring-cloud-contract-wiremock/pom.xml @@ -84,7 +84,6 @@ io.rest-assured rest-assured - ${rest-assured.version} true diff --git a/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/restdocs/WireMockVerifyHelper.java b/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/restdocs/WireMockVerifyHelper.java index d5c1df0dfb..bb06044349 100644 --- a/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/restdocs/WireMockVerifyHelper.java +++ b/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/restdocs/WireMockVerifyHelper.java @@ -44,17 +44,6 @@ public abstract class WireMockVerifyHelperandDo(document(name)) - */ - @SuppressWarnings("unchecked") - @Deprecated - public S stub(String name) { - return (S) this; - } - public void configure(T result) { Map configuration = getConfiguration(result); byte[] requestBodyContent = getRequestBodyContent(result);